diff --git a/Content.Server/AI/Components/AiControllerComponent.cs b/Content.Server/AI/Components/AiControllerComponent.cs index 26f1bc15e3..d6eb2a9fc7 100644 --- a/Content.Server/AI/Components/AiControllerComponent.cs +++ b/Content.Server/AI/Components/AiControllerComponent.cs @@ -39,10 +39,6 @@ namespace Content.Server.AI.Components [DataField("awake")] private bool _awake = true; - [ViewVariables(VVAccess.ReadWrite)] - [DataField("startingGear")] - public string? StartingGearPrototype { get; set; } - [ViewVariables(VVAccess.ReadWrite)] public float VisionRadius { @@ -59,20 +55,6 @@ namespace Content.Server.AI.Components Owner.EnsureComponent(); } - protected override void Startup() - { - base.Startup(); - - if (StartingGearPrototype != null) - { - var stationSpawning = EntitySystem.Get(); - var protoManager = IoCManager.Resolve(); - - var startingGear = protoManager.Index(StartingGearPrototype); - stationSpawning.EquipStartingGear(Owner, startingGear, null); - } - } - /// /// Movement speed (m/s) that the entity walks, after modifiers /// diff --git a/Content.Server/Clothing/Components/LoadoutComponent.cs b/Content.Server/Clothing/Components/LoadoutComponent.cs new file mode 100644 index 0000000000..f224f5718f --- /dev/null +++ b/Content.Server/Clothing/Components/LoadoutComponent.cs @@ -0,0 +1,12 @@ +using Content.Shared.Roles; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Clothing.Components +{ + [RegisterComponent] + public sealed class LoadoutComponent : Component + { + [DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] + public string Prototype = string.Empty; + } +} diff --git a/Content.Server/Clothing/LoadoutSystem.cs b/Content.Server/Clothing/LoadoutSystem.cs new file mode 100644 index 0000000000..f1f1e9a917 --- /dev/null +++ b/Content.Server/Clothing/LoadoutSystem.cs @@ -0,0 +1,32 @@ +using Content.Server.Clothing.Components; +using Content.Server.Station.Systems; +using Content.Shared.Roles; +using Robust.Shared.Prototypes; + +namespace Content.Server.Clothing +{ + /// + /// Assigns a loadout to an entity based on the startingGear prototype + /// + public sealed class LoadoutSystem : EntitySystem + { + [Dependency] private readonly StationSpawningSystem _station = default!; + [Dependency] private readonly IPrototypeManager _protoMan = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnStartup); + } + + private void OnStartup(EntityUid uid, LoadoutComponent component, ComponentStartup args) + { + if (component.Prototype == string.Empty) + return; + + var proto = _protoMan.Index(component.Prototype); + _station.EquipStartingGear(uid, proto, null); + } + } +} diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/human.yml b/Resources/Prototypes/Entities/Mobs/NPCs/human.yml index c63f374525..d74d8f96ee 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/human.yml @@ -10,7 +10,8 @@ - Hunger - Thirst - Idle - startingGear: PassengerGear + - type: Loadout + prototype: PassengerGear - type: AiFactionTag factions: - NanoTrasen diff --git a/Resources/Prototypes/Entities/Mobs/Player/human.yml b/Resources/Prototypes/Entities/Mobs/Player/human.yml index 41a5842144..cc9c340268 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/human.yml @@ -49,6 +49,6 @@ makeSentient: false name: centcom official description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain. - - type: UtilityAI - startingGear: CentcomGear + - type: Loadout + prototype: CentcomGear - type: RandomHumanoidAppearance