From d048682a1561342a4974ae30ef14426a0e2e4ec6 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 2 Jul 2024 14:58:55 -0400 Subject: [PATCH 1/4] Filter Set Outfit menu to exclude loadout sets --- .../UI/SetOutfit/SetOutfitMenu.xaml.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs index a2faf208d92f7f..dcd4cad6fec2cd 100644 --- a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs +++ b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs @@ -1,13 +1,12 @@ +using System.Linq; using System.Numerics; +using Content.Shared.Preferences.Loadouts; using Content.Shared.Roles; using Robust.Client.AutoGenerated; using Robust.Client.Console; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Prototypes; namespace Content.Client.Administration.UI.SetOutfit @@ -64,9 +63,18 @@ private void SearchBarOnOnTextChanged(LineEdit.LineEditEventArgs obj) PopulateByFilter(SearchBar.Text); } + private IEnumerable GetPrototypes() + { + // Filter out any StartingGearPrototypes that belong to loadouts + var loadouts = _prototypeManager.EnumeratePrototypes(); + var loadoutGears = loadouts.Select(l => l.Equipment); + return _prototypeManager.EnumeratePrototypes() + .Where(p => !loadoutGears.Contains(p.ID)); + } + private void PopulateList() { - foreach (var gear in _prototypeManager.EnumeratePrototypes()) + foreach (var gear in GetPrototypes()) { OutfitList.Add(GetItem(gear, OutfitList)); } @@ -75,7 +83,7 @@ private void PopulateList() private void PopulateByFilter(string filter) { OutfitList.Clear(); - foreach (var gear in _prototypeManager.EnumeratePrototypes()) + foreach (var gear in GetPrototypes()) { if (!string.IsNullOrEmpty(filter) && gear.ID.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant())) From 95749d9d33be97c99b2077d6fe3520823249f772 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 2 Jul 2024 18:36:20 -0400 Subject: [PATCH 2/4] Apply loadouts to job outfits --- .../Commands/SetOutfitCommand.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index 15d8d4afb7b7eb..04c223ad38eef2 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -4,11 +4,14 @@ using Content.Server.Preferences.Managers; using Content.Shared.Access.Components; using Content.Shared.Administration; +using Content.Shared.Clothing; using Content.Shared.Hands.Components; using Content.Shared.Inventory; using Content.Shared.PDA; using Content.Shared.Preferences; +using Content.Shared.Preferences.Loadouts; using Content.Shared.Roles; +using Content.Shared.Station; using Robust.Shared.Console; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -82,9 +85,11 @@ public static bool SetOutfit(EntityUid target, string gear, IEntityManager entit return false; HumanoidCharacterProfile? profile = null; + ICommonSession? session = null; // Check if we are setting the outfit of a player to respect the preferences if (entityManager.TryGetComponent(target, out ActorComponent? actorComponent)) { + session = actorComponent.PlayerSession; var userId = actorComponent.PlayerSession.UserId; var preferencesManager = IoCManager.Resolve(); var prefs = preferencesManager.GetPreferences(userId); @@ -127,6 +132,34 @@ public static bool SetOutfit(EntityUid target, string gear, IEntityManager entit } } + // See if this starting gear is associated with a job + var jobs = prototypeManager.EnumeratePrototypes(); + foreach (var job in jobs) + { + if (job.StartingGear != gear) + continue; + + var jobProtoId = LoadoutSystem.GetJobPrototype(job.ID); + if (!prototypeManager.TryIndex(jobProtoId, out var jobProto)) + break; + + // Don't require a player, so this works on Urists + profile ??= new HumanoidCharacterProfile(); + // Try to get the user's existing loadout for the role + profile.Loadouts.TryGetValue(jobProtoId, out var roleLoadout); + + if (roleLoadout == null) + { + // If they don't have a loadout for the role, make a default one + roleLoadout = new RoleLoadout(jobProtoId); + roleLoadout.SetDefault(profile, session, prototypeManager); + } + + // Equip the target with the job loadout + var stationSpawning = entityManager.System(); + stationSpawning.EquipRoleLoadout(target, roleLoadout, jobProto); + } + return true; } } From 5c817b8a6ba8ea1961de7dfc2e41f87b15e3e3a9 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 2 Jul 2024 20:13:59 -0400 Subject: [PATCH 3/4] Use appropriate species for Urists --- Content.Server/Administration/Commands/SetOutfitCommand.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index 04c223ad38eef2..f70cf1a1959427 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -6,6 +6,7 @@ using Content.Shared.Administration; using Content.Shared.Clothing; using Content.Shared.Hands.Components; +using Content.Shared.Humanoid; using Content.Shared.Inventory; using Content.Shared.PDA; using Content.Shared.Preferences; @@ -144,7 +145,9 @@ public static bool SetOutfit(EntityUid target, string gear, IEntityManager entit break; // Don't require a player, so this works on Urists - profile ??= new HumanoidCharacterProfile(); + profile ??= entityManager.TryGetComponent(target, out var comp) + ? HumanoidCharacterProfile.DefaultWithSpecies(comp.Species) + : new HumanoidCharacterProfile(); // Try to get the user's existing loadout for the role profile.Loadouts.TryGetValue(jobProtoId, out var roleLoadout); From b49a39748b579d559d66a1e1b3d7acc94ff44fa1 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Thu, 19 Sep 2024 17:57:15 +1000 Subject: [PATCH 4/4] squishy --- .../Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs index 3ad64a2130ef51..615f1434df229d 100644 --- a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs +++ b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs @@ -68,7 +68,7 @@ private IEnumerable GetPrototypes() { // Filter out any StartingGearPrototypes that belong to loadouts var loadouts = _prototypeManager.EnumeratePrototypes(); - var loadoutGears = loadouts.Select(l => l.Equipment); + var loadoutGears = loadouts.Select(l => l.StartingGear); return _prototypeManager.EnumeratePrototypes() .Where(p => !loadoutGears.Contains(p.ID)); }