Decouples starting gear from UtilityAI (#8512)

This commit is contained in:
EmoGarbage404
2022-05-29 18:14:47 -04:00
committed by GitHub
parent cbf1f6322f
commit 86ee423449
5 changed files with 48 additions and 21 deletions

View File

@@ -39,10 +39,6 @@ namespace Content.Server.AI.Components
[DataField("awake")] [DataField("awake")]
private bool _awake = true; private bool _awake = true;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("startingGear")]
public string? StartingGearPrototype { get; set; }
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public float VisionRadius public float VisionRadius
{ {
@@ -59,20 +55,6 @@ namespace Content.Server.AI.Components
Owner.EnsureComponent<PhysicsComponent>(); Owner.EnsureComponent<PhysicsComponent>();
} }
protected override void Startup()
{
base.Startup();
if (StartingGearPrototype != null)
{
var stationSpawning = EntitySystem.Get<StationSpawningSystem>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var startingGear = protoManager.Index<StartingGearPrototype>(StartingGearPrototype);
stationSpawning.EquipStartingGear(Owner, startingGear, null);
}
}
/// <summary> /// <summary>
/// Movement speed (m/s) that the entity walks, after modifiers /// Movement speed (m/s) that the entity walks, after modifiers
/// </summary> /// </summary>

View File

@@ -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<StartingGearPrototype>))]
public string Prototype = string.Empty;
}
}

View File

@@ -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
{
/// <summary>
/// Assigns a loadout to an entity based on the startingGear prototype
/// </summary>
public sealed class LoadoutSystem : EntitySystem
{
[Dependency] private readonly StationSpawningSystem _station = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LoadoutComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(EntityUid uid, LoadoutComponent component, ComponentStartup args)
{
if (component.Prototype == string.Empty)
return;
var proto = _protoMan.Index<StartingGearPrototype>(component.Prototype);
_station.EquipStartingGear(uid, proto, null);
}
}
}

View File

@@ -10,7 +10,8 @@
- Hunger - Hunger
- Thirst - Thirst
- Idle - Idle
startingGear: PassengerGear - type: Loadout
prototype: PassengerGear
- type: AiFactionTag - type: AiFactionTag
factions: factions:
- NanoTrasen - NanoTrasen

View File

@@ -49,6 +49,6 @@
makeSentient: false makeSentient: false
name: centcom official name: centcom official
description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain. description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain.
- type: UtilityAI - type: Loadout
startingGear: CentcomGear prototype: CentcomGear
- type: RandomHumanoidAppearance - type: RandomHumanoidAppearance