diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index c4cda4a73c..e2811abc2d 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -1,8 +1,15 @@ +#nullable enable using Content.Server.Eui; using Content.Server.GameObjects.Components.GUI; using Content.Server.GameObjects.Components.Items.Storage; +using Content.Server.GameObjects.Components.PDA; +using Content.Server.Interfaces; using Content.Shared.Administration; +using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.Preferences; using Content.Shared.Roles; +using NFluidsynth; +using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.GameObjects; @@ -17,7 +24,8 @@ namespace Content.Server.Administration.Commands { public string Command => "setoutfit"; - public string Description => Loc.GetString("Sets the outfit of the specified entity. The entity must have an InventoryComponent"); + public string Description => + Loc.GetString("Sets the outfit of the specified entity. The entity must have an InventoryComponent"); public string Help => Loc.GetString("Usage: {0} | {0} ", Command); @@ -55,9 +63,16 @@ namespace Content.Server.Administration.Commands if (args.Length == 1) { + if (!(shell.Player is IPlayerSession player)) + { + shell.WriteError( + Loc.GetString( + "This does not work from the server console. You must pass the outfit id aswell.")); + return; + } + var eui = IoCManager.Resolve(); var ui = new SetOutfitEui(target); - var player = shell.Player as IPlayerSession; eui.OpenEui(ui, player); return; } @@ -69,17 +84,31 @@ namespace Content.Server.Administration.Commands return; } + HumanoidCharacterProfile? profile = null; + // Check if we are setting the outfit of a player to respect the preferences + if (target.TryGetComponent(out var actorComponent)) + { + var userId = actorComponent.playerSession.UserId; + var preferencesManager = IoCManager.Resolve(); + var prefs = preferencesManager.GetPreferences(userId); + profile = prefs.SelectedCharacter as HumanoidCharacterProfile; + } + foreach (var slot in inventoryComponent.Slots) { inventoryComponent.ForceUnequip(slot); - var gearStr = startingGear.GetGear(slot, null); - if (gearStr != "") + var gearStr = startingGear.GetGear(slot, profile); + if (gearStr == "") continue; + var equipmentEntity = entityManager.SpawnEntity(gearStr, target.Transform.Coordinates); + if (slot == EquipmentSlotDefines.Slots.IDCARD && + equipmentEntity.TryGetComponent(out var pdaComponent) && + pdaComponent.ContainedID != null) { - var equipmentEntity = entityManager.SpawnEntity(gearStr, target.Transform.Coordinates); - inventoryComponent.Equip(slot, equipmentEntity.GetComponent(), false); + pdaComponent.ContainedID.FullName = target.Name; } - } + inventoryComponent.Equip(slot, equipmentEntity.GetComponent(), false); + } } } }