| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using Content.Shared.Body.Components;
- using Content.Shared.Body.Systems;
- using Robust.Shared.Containers;
- using Robust.Shared.GameStates;
- using Robust.Shared.Serialization;
- namespace Content.Shared.Body.Part;
- [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
- [Access(typeof(SharedBodySystem))]
- public sealed partial class BodyPartComponent : Component
- {
- // 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;
- [DataField, AutoNetworkedField]
- public BodyPartType PartType = BodyPartType.Other;
- // TODO BODY Replace with a simulation of organs
- /// <summary>
- /// 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"), AutoNetworkedField]
- public bool IsVital;
- [DataField, AutoNetworkedField]
- public BodyPartSymmetry Symmetry = BodyPartSymmetry.None;
- /// <summary>
- /// Child body parts attached to this body part.
- /// </summary>
- [DataField, AutoNetworkedField]
- public Dictionary<string, BodyPartSlot> Children = new();
- /// <summary>
- /// Organs attached to this body part.
- /// </summary>
- [DataField, AutoNetworkedField]
- 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, SharedBodySystem.PartSlotContainerIdPrefix+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, SharedBodySystem.OrganSlotContainerIdPrefix+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;
- }
- };
|