BodyPartComponent.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Content.Shared.Body.Components;
  2. using Content.Shared.Body.Systems;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.Body.Part;
  7. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  8. [Access(typeof(SharedBodySystem))]
  9. public sealed partial class BodyPartComponent : Component
  10. {
  11. // Need to set this on container changes as it may be several transform parents up the hierarchy.
  12. /// <summary>
  13. /// Parent body for this part.
  14. /// </summary>
  15. [DataField, AutoNetworkedField]
  16. public EntityUid? Body;
  17. [DataField, AutoNetworkedField]
  18. public BodyPartType PartType = BodyPartType.Other;
  19. // TODO BODY Replace with a simulation of organs
  20. /// <summary>
  21. /// Whether or not the owning <see cref="Body"/> will die if all
  22. /// <see cref="BodyComponent"/>s of this type are removed from it.
  23. /// </summary>
  24. [DataField("vital"), AutoNetworkedField]
  25. public bool IsVital;
  26. [DataField, AutoNetworkedField]
  27. public BodyPartSymmetry Symmetry = BodyPartSymmetry.None;
  28. /// <summary>
  29. /// Child body parts attached to this body part.
  30. /// </summary>
  31. [DataField, AutoNetworkedField]
  32. public Dictionary<string, BodyPartSlot> Children = new();
  33. /// <summary>
  34. /// Organs attached to this body part.
  35. /// </summary>
  36. [DataField, AutoNetworkedField]
  37. public Dictionary<string, OrganSlot> Organs = new();
  38. /// <summary>
  39. /// These are only for VV/Debug do not use these for gameplay/systems
  40. /// </summary>
  41. [ViewVariables]
  42. private List<ContainerSlot> BodyPartSlotsVV
  43. {
  44. get
  45. {
  46. List<ContainerSlot> temp = new();
  47. var containerSystem = IoCManager.Resolve<IEntityManager>().System<SharedContainerSystem>();
  48. foreach (var slotId in Children.Keys)
  49. {
  50. temp.Add((ContainerSlot) containerSystem.GetContainer(Owner, SharedBodySystem.PartSlotContainerIdPrefix+slotId));
  51. }
  52. return temp;
  53. }
  54. }
  55. [ViewVariables]
  56. private List<ContainerSlot> OrganSlotsVV
  57. {
  58. get
  59. {
  60. List<ContainerSlot> temp = new();
  61. var containerSystem = IoCManager.Resolve<IEntityManager>().System<SharedContainerSystem>();
  62. foreach (var slotId in Organs.Keys)
  63. {
  64. temp.Add((ContainerSlot) containerSystem.GetContainer(Owner, SharedBodySystem.OrganSlotContainerIdPrefix+slotId));
  65. }
  66. return temp;
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// Contains metadata about a body part in relation to its slot.
  72. /// </summary>
  73. [NetSerializable, Serializable]
  74. [DataRecord]
  75. public partial struct BodyPartSlot
  76. {
  77. public string Id;
  78. public BodyPartType Type;
  79. public BodyPartSlot(string id, BodyPartType type)
  80. {
  81. Id = id;
  82. Type = type;
  83. }
  84. };
  85. /// <summary>
  86. /// Contains metadata about an organ part in relation to its slot.
  87. /// </summary>
  88. [NetSerializable, Serializable]
  89. [DataRecord]
  90. public partial struct OrganSlot
  91. {
  92. public string Id;
  93. public OrganSlot(string id)
  94. {
  95. Id = id;
  96. }
  97. };