Decouples starting gear from UtilityAI (#8512)
This commit is contained in:
@@ -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<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>
|
||||
/// Movement speed (m/s) that the entity walks, after modifiers
|
||||
/// </summary>
|
||||
|
||||
12
Content.Server/Clothing/Components/LoadoutComponent.cs
Normal file
12
Content.Server/Clothing/Components/LoadoutComponent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
32
Content.Server/Clothing/LoadoutSystem.cs
Normal file
32
Content.Server/Clothing/LoadoutSystem.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,8 @@
|
||||
- Hunger
|
||||
- Thirst
|
||||
- Idle
|
||||
startingGear: PassengerGear
|
||||
- type: Loadout
|
||||
prototype: PassengerGear
|
||||
- type: AiFactionTag
|
||||
factions:
|
||||
- NanoTrasen
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user