Refactoring body system to use containers and general body cleanup (#20202)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Jezithyr
2023-09-21 00:23:02 -07:00
committed by GitHub
parent d888d9ad67
commit 31b2c9f830
38 changed files with 1298 additions and 1098 deletions

View File

@@ -1,9 +1,10 @@
using Content.Shared.Body.Part;
using Content.Shared.Body.Prototypes;
using Content.Shared.Body.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Body.Components;
@@ -11,19 +12,52 @@ namespace Content.Shared.Body.Components;
[Access(typeof(SharedBodySystem))]
public sealed partial class BodyComponent : Component
{
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<BodyPrototype>))]
public string? Prototype;
/// <summary>
/// Relevant template to spawn for this body.
/// </summary>
[DataField]
public ProtoId<BodyPrototype>? Prototype;
[DataField("root")]
public BodyPartSlot? Root;
/// <summary>
/// Container that holds the root body part.
/// </summary>
/// <remarks>
/// Typically is the torso.
/// </remarks>
[ViewVariables] public ContainerSlot RootContainer = default!;
[DataField("gibSound")]
public SoundSpecifier GibSound = new SoundCollectionSpecifier("gib");
[ViewVariables]
public string RootPartSlot => RootContainer.ID;
[DataField] public SoundSpecifier GibSound = new SoundCollectionSpecifier("gib");
/// <summary>
/// The amount of legs required to move at full speed.
/// If 0, then legs do not impact speed.
/// </summary>
[DataField("requiredLegs")]
public int RequiredLegs;
[DataField] public int RequiredLegs;
[ViewVariables]
[DataField]
public HashSet<EntityUid> LegEntities = new();
}
[Serializable, NetSerializable]
public sealed class BodyComponentState : ComponentState
{
public string? Prototype;
public string? RootPartSlot;
public SoundSpecifier GibSound;
public int RequiredLegs;
public HashSet<NetEntity> LegNetEntities;
public BodyComponentState(string? prototype, string? rootPartSlot, SoundSpecifier gibSound,
int requiredLegs, HashSet<NetEntity> legNetEntities)
{
Prototype = prototype;
RootPartSlot = rootPartSlot;
GibSound = gibSound;
RequiredLegs = requiredLegs;
LegNetEntities = legNetEntities;
}
}