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:
@@ -1,32 +1,23 @@
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Organ;
|
||||
using Content.Shared.Body.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Body.Part;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(SharedBodySystem))]
|
||||
public sealed partial class BodyPartComponent : Component
|
||||
{
|
||||
[DataField("body")]
|
||||
// Need to set this on container changes as it may be several transform parents up the hierarchy.
|
||||
/// <summary>
|
||||
/// Parent body for this part.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? Body;
|
||||
|
||||
// This inter-entity relationship makes be deeply uncomfortable because its probably going to re-encounter all of the
|
||||
// networking issues that containers and joints have.
|
||||
// TODO just use containers. Please.
|
||||
// Do not use set or get data from this in client-side code.
|
||||
public BodyPartSlot? ParentSlot;
|
||||
|
||||
// Do not use set or get data from this in client-side code.
|
||||
[DataField("children")]
|
||||
public Dictionary<string, BodyPartSlot> Children = new();
|
||||
|
||||
// See all the above ccomments.
|
||||
[DataField("organs")]
|
||||
public Dictionary<string, OrganSlot> Organs = new();
|
||||
|
||||
[DataField("partType")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public BodyPartType PartType = BodyPartType.Other;
|
||||
|
||||
// TODO BODY Replace with a simulation of organs
|
||||
@@ -34,9 +25,90 @@ public sealed partial class BodyPartComponent : Component
|
||||
/// Whether or not the owning <see cref="Body"/> will die if all
|
||||
/// <see cref="BodyComponent"/>s of this type are removed from it.
|
||||
/// </summary>
|
||||
[DataField("vital")]
|
||||
[DataField("vital"), AutoNetworkedField]
|
||||
public bool IsVital;
|
||||
|
||||
[DataField("symmetry")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public BodyPartSymmetry Symmetry = BodyPartSymmetry.None;
|
||||
|
||||
/// <summary>
|
||||
/// Child body parts attached to this body part.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField(CloneData = true)]
|
||||
public Dictionary<string, BodyPartSlot> Children = new();
|
||||
|
||||
/// <summary>
|
||||
/// Organs attached to this body part.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField(CloneData = true)]
|
||||
public Dictionary<string, OrganSlot> Organs = new();
|
||||
|
||||
/// <summary>
|
||||
/// These are only for VV/Debug do not use these for gameplay/systems
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
private List<ContainerSlot> BodyPartSlotsVV
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ContainerSlot> temp = new();
|
||||
var containerSystem = IoCManager.Resolve<IEntityManager>().System<SharedContainerSystem>();
|
||||
|
||||
foreach (var slotId in Children.Keys)
|
||||
{
|
||||
temp.Add((ContainerSlot) containerSystem.GetContainer(Owner, slotId));
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
private List<ContainerSlot> OrganSlotsVV
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ContainerSlot> temp = new();
|
||||
var containerSystem = IoCManager.Resolve<IEntityManager>().System<SharedContainerSystem>();
|
||||
|
||||
foreach (var slotId in Organs.Keys)
|
||||
{
|
||||
temp.Add((ContainerSlot) containerSystem.GetContainer(Owner, slotId));
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains metadata about a body part in relation to its slot.
|
||||
/// </summary>
|
||||
[NetSerializable, Serializable]
|
||||
[DataRecord]
|
||||
public partial struct BodyPartSlot
|
||||
{
|
||||
public string Id;
|
||||
public BodyPartType Type;
|
||||
|
||||
public BodyPartSlot(string id, BodyPartType type)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Contains metadata about an organ part in relation to its slot.
|
||||
/// </summary>
|
||||
[NetSerializable, Serializable]
|
||||
[DataRecord]
|
||||
public partial struct OrganSlot
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public OrganSlot(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user