1
0

MechComponent.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using Content.Shared.FixedPoint;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Shared.Mech.Components;
  7. /// <summary>
  8. /// A large, pilotable machine that has equipment that is
  9. /// powered via an internal battery.
  10. /// </summary>
  11. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  12. public sealed partial class MechComponent : Component
  13. {
  14. /// <summary>
  15. /// How much "health" the mech has left.
  16. /// </summary>
  17. [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  18. public FixedPoint2 Integrity;
  19. /// <summary>
  20. /// The maximum amount of damage the mech can take.
  21. /// </summary>
  22. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  23. public FixedPoint2 MaxIntegrity = 250;
  24. /// <summary>
  25. /// How much energy the mech has.
  26. /// Derived from the currently inserted battery.
  27. /// </summary>
  28. [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  29. public FixedPoint2 Energy = 0;
  30. /// <summary>
  31. /// The maximum amount of energy the mech can have.
  32. /// Derived from the currently inserted battery.
  33. /// </summary>
  34. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  35. public FixedPoint2 MaxEnergy = 0;
  36. /// <summary>
  37. /// The slot the battery is stored in.
  38. /// </summary>
  39. [ViewVariables]
  40. public ContainerSlot BatterySlot = default!;
  41. [ViewVariables]
  42. public readonly string BatterySlotId = "mech-battery-slot";
  43. /// <summary>
  44. /// A multiplier used to calculate how much of the damage done to a mech
  45. /// is transfered to the pilot
  46. /// </summary>
  47. [DataField, ViewVariables(VVAccess.ReadWrite)]
  48. public float MechToPilotDamageMultiplier;
  49. /// <summary>
  50. /// Whether the mech has been destroyed and is no longer pilotable.
  51. /// </summary>
  52. [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  53. public bool Broken = false;
  54. /// <summary>
  55. /// The slot the pilot is stored in.
  56. /// </summary>
  57. [ViewVariables(VVAccess.ReadWrite)]
  58. public ContainerSlot PilotSlot = default!;
  59. [ViewVariables]
  60. public readonly string PilotSlotId = "mech-pilot-slot";
  61. /// <summary>
  62. /// The current selected equipment of the mech.
  63. /// If null, the mech is using just its fists.
  64. /// </summary>
  65. [ViewVariables, AutoNetworkedField]
  66. public EntityUid? CurrentSelectedEquipment;
  67. /// <summary>
  68. /// The maximum amount of equipment items that can be installed in the mech
  69. /// </summary>
  70. [DataField("maxEquipmentAmount"), ViewVariables(VVAccess.ReadWrite)]
  71. public int MaxEquipmentAmount = 3;
  72. /// <summary>
  73. /// A whitelist for inserting equipment items.
  74. /// </summary>
  75. [DataField]
  76. public EntityWhitelist? EquipmentWhitelist;
  77. [DataField]
  78. public EntityWhitelist? PilotWhitelist;
  79. /// <summary>
  80. /// A container for storing the equipment entities.
  81. /// </summary>
  82. [ViewVariables(VVAccess.ReadWrite)]
  83. public Container EquipmentContainer = default!;
  84. [ViewVariables]
  85. public readonly string EquipmentContainerId = "mech-equipment-container";
  86. /// <summary>
  87. /// How long it takes to enter the mech.
  88. /// </summary>
  89. [DataField, ViewVariables(VVAccess.ReadWrite)]
  90. public float EntryDelay = 3;
  91. /// <summary>
  92. /// How long it takes to pull *another person*
  93. /// outside of the mech. You can exit instantly yourself.
  94. /// </summary>
  95. [DataField, ViewVariables(VVAccess.ReadWrite)]
  96. public float ExitDelay = 3;
  97. /// <summary>
  98. /// How long it takes to pull out the battery.
  99. /// </summary>
  100. [DataField, ViewVariables(VVAccess.ReadWrite)]
  101. public float BatteryRemovalDelay = 2;
  102. /// <summary>
  103. /// Whether or not the mech is airtight.
  104. /// </summary>
  105. /// <remarks>
  106. /// This needs to be redone
  107. /// when mech internals are added
  108. /// </remarks>
  109. [DataField, ViewVariables(VVAccess.ReadWrite)]
  110. public bool Airtight;
  111. /// <summary>
  112. /// The equipment that the mech initially has when it spawns.
  113. /// Good for things like nukie mechs that start with guns.
  114. /// </summary>
  115. [DataField]
  116. public List<EntProtoId> StartingEquipment = new();
  117. #region Action Prototypes
  118. [DataField]
  119. public EntProtoId MechCycleAction = "ActionMechCycleEquipment";
  120. [DataField]
  121. public EntProtoId MechUiAction = "ActionMechOpenUI";
  122. [DataField]
  123. public EntProtoId MechEjectAction = "ActionMechEject";
  124. #endregion
  125. #region Visualizer States
  126. [DataField]
  127. public string? BaseState;
  128. [DataField]
  129. public string? OpenState;
  130. [DataField]
  131. public string? BrokenState;
  132. #endregion
  133. [DataField] public EntityUid? MechCycleActionEntity;
  134. [DataField] public EntityUid? MechUiActionEntity;
  135. [DataField] public EntityUid? MechEjectActionEntity;
  136. }