Add Secrets inventory loadout

This commit is contained in:
Morb0 2024-05-15 17:49:35 +03:00
parent f0dea8a8cd
commit 34bfec199a
8 changed files with 101 additions and 4 deletions

View file

@ -1,4 +1,5 @@
using System.Linq;
using Content.Corvax.Interfaces.Shared;
using Content.Shared.Clothing;
using Content.Shared.Preferences.Loadouts;
using Robust.Client.AutoGenerated;
@ -66,7 +67,15 @@ public sealed partial class LoadoutGroupContainer : BoxContainer
var selected = loadout.SelectedLoadouts[_groupProto.ID];
foreach (var loadoutProto in _groupProto.Loadouts)
// Corvax-Loadouts-Start
var groupLoadouts = _groupProto.Loadouts;
if (collection.TryResolveType<ISharedLoadoutsManager>(out var loadoutsManager) && _groupProto.ID == "Inventory")
{
groupLoadouts = loadoutsManager.GetClientPrototypes().Select(id => (ProtoId<LoadoutPrototype>)id).ToList();
}
// Corvax-Loadouts-End
foreach (var loadoutProto in groupLoadouts) // Corvax-Loadouts
{
if (!protoMan.TryIndex(loadoutProto, out var loadProto))
continue;

View file

@ -1,6 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Corvax.Interfaces.Shared;
using Content.Shared.Random;
using Robust.Shared.Collections;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
@ -48,6 +51,7 @@ public sealed class RoleLoadout
{
var groupRemove = new ValueList<string>();
var protoManager = collection.Resolve<IPrototypeManager>();
var netManager = collection.Resolve<INetManager>(); // Corvax-Loadouts
if (!protoManager.TryIndex(Role, out var roleProto))
{
@ -67,6 +71,24 @@ public sealed class RoleLoadout
continue;
}
// Corvax-Loadouts-Start
var groupProtoLoadouts = groupProto.Loadouts;
if (collection.TryResolveType<ISharedLoadoutsManager>(out var loadoutsManager) && group.Id == "Inventory")
{
var prototypes = new List<string>();
if (netManager.IsClient)
{
prototypes = loadoutsManager.GetClientPrototypes();
}
else if (loadoutsManager.TryGetServerPrototypes(session.UserId, out var protos))
{
prototypes = protos;
}
groupProtoLoadouts = prototypes.Select(id => (ProtoId<LoadoutPrototype>)id).ToList();
}
// Corvax-Loadouts-End
var loadouts = groupLoadouts[..Math.Min(groupLoadouts.Count, groupProto.MaxLimit)];
// Validate first
@ -80,6 +102,14 @@ public sealed class RoleLoadout
continue;
}
// Corvax-Loadouts-Start: Validate if loadout exist in group. It's can't be f real
if (!groupProtoLoadouts.Contains(loadout.Prototype))
{
loadouts.RemoveAt(i);
continue;
}
// Corvax-Loadouts-End
// Validate the loadout can be applied (e.g. points).
if (!IsValid(session, loadout.Prototype, collection, out _))
{
@ -95,9 +125,9 @@ public sealed class RoleLoadout
// If you put invalid ones first but that's your fault for not using sensible defaults
if (loadouts.Count < groupProto.MinLimit)
{
for (var i = 0; i < Math.Min(groupProto.MinLimit, groupProto.Loadouts.Count); i++)
for (var i = 0; i < Math.Min(groupProto.MinLimit, groupProtoLoadouts.Count); i++) // Corvax-Loadout: Use groupProtoLoadouts instead of groupProto.Loadouts
{
if (!protoManager.TryIndex(groupProto.Loadouts[i], out var loadoutProto))
if (!protoManager.TryIndex(groupProtoLoadouts[i], out var loadoutProto)) // Corvax-Loadout
continue;
var defaultLoadout = new Loadout()

View file

@ -0,0 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Network;
namespace Content.Corvax.Interfaces.Shared;
public interface ISharedLoadoutsManager
{
public void Initialize();
public bool TryGetServerPrototypes(NetUserId userId, [NotNullWhen(true)] out List<string>? prototypes);
public List<string> GetClientPrototypes();
}

View file

@ -1 +1,2 @@
loadout-group-inventory = Мой инвентарь
loadout-group-psychologist-backpack = Рюкзак психолога

View file

@ -1,3 +1,10 @@
- type: loadoutGroup
id: Inventory
name: loadout-group-inventory
minLimit: 0
maxLimit: 5
loadouts: []
- type: loadoutGroup
id: PsychologistBackpack
name: loadout-group-psychologist-backpack

View file

@ -5,3 +5,4 @@
- LawyerJumpsuit
- CommonBackpack
- Trinkets
- Inventory # Corvax-Loadouts

View file

@ -8,6 +8,7 @@
- CaptainBackpack
- CaptainOuterClothing
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobHeadOfPersonnel
@ -19,6 +20,7 @@
- HoPOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
# Civilian
- type: roleLoadout
@ -32,6 +34,7 @@
- PassengerShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobBartender
@ -42,6 +45,7 @@
- BartenderOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobServiceWorker
@ -50,6 +54,7 @@
- CommonBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobChef
@ -61,6 +66,7 @@
- ChefOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobLibrarian
@ -69,6 +75,7 @@
- CommonBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobLawyer
@ -78,6 +85,7 @@
- LawyerBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobChaplain
@ -90,6 +98,7 @@
- ChaplainOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobJanitor
@ -101,6 +110,7 @@
- JanitorOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobBotanist
@ -111,6 +121,7 @@
- BotanistOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobClown
@ -122,6 +133,7 @@
- ClownShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobMime
@ -133,6 +145,7 @@
- MimeOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobMusician
@ -141,6 +154,7 @@
- MusicianOuterClothing
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
# Cargo
- type: roleLoadout
@ -154,6 +168,7 @@
- QuartermasterShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobCargoTechnician
@ -165,6 +180,7 @@
- CargoTechnicianShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobSalvageSpecialist
@ -174,6 +190,7 @@
- SalvageSpecialistShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
# Engineering
- type: roleLoadout
@ -186,6 +203,7 @@
- ChiefEngineerOuterClothing
- ChiefEngineerShoes
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobTechnicalAssistant
@ -193,6 +211,7 @@
- TechnicalAssistantJumpsuit
- StationEngineerBackpack
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobStationEngineer
@ -204,6 +223,7 @@
- StationEngineerShoes
- StationEngineerID
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobAtmosphericTechnician
@ -213,6 +233,7 @@
- AtmosphericTechnicianOuterClothing
- AtmosphericTechnicianShoes
- Trinkets
- Inventory # Corvax-Loadouts
# Science
- type: roleLoadout
@ -227,6 +248,7 @@
- ResearchDirectorShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobScientist
@ -241,6 +263,7 @@
- ScientistPDA
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobResearchAssistant
@ -249,6 +272,7 @@
- ScientistBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
# Security
- type: roleLoadout
@ -262,6 +286,7 @@
- HeadofSecurityOuterClothing
- SecurityShoes
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobWarden
@ -273,6 +298,7 @@
- WardenOuterClothing
- SecurityShoes
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobSecurityOfficer
@ -285,6 +311,7 @@
- SecurityPDA
- SecurityBelt
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobDetective
@ -296,6 +323,7 @@
- DetectiveOuterClothing
- SecurityShoes
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobSecurityCadet
@ -303,6 +331,7 @@
- SecurityCadetJumpsuit
- SecurityBackpack
- Trinkets
- Inventory # Corvax-Loadouts
# Medical
- type: roleLoadout
@ -318,6 +347,7 @@
- ChiefMedicalOfficerShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobMedicalDoctor
@ -332,6 +362,7 @@
- MedicalDoctorPDA
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobMedicalIntern
@ -340,6 +371,7 @@
- MedicalBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobChemist
@ -351,6 +383,7 @@
- ChemistOuterClothing
- MedicalShoes
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobParamedic
@ -364,6 +397,7 @@
- ParamedicShoes
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
# Wildcards
- type: roleLoadout
@ -372,6 +406,7 @@
- CommonBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobReporter
@ -380,6 +415,7 @@
- CommonBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobPsychologist
@ -387,6 +423,7 @@
- PsychologistBackpack # Corvax-MRP
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts
- type: roleLoadout
id: JobBoxer
@ -396,3 +433,4 @@
- CommonBackpack
- Glasses
- Trinkets
- Inventory # Corvax-Loadouts

@ -1 +1 @@
Subproject commit eca67902c227da4163d619ffb1a382b8a1815d51
Subproject commit fe71e8bfe65973a0361bda118477d471de85844f