RCDPrototype.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using Content.Shared.Physics;
  2. using Robust.Shared.Physics.Collision.Shapes;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Utility;
  5. namespace Content.Shared.RCD;
  6. /// <summary>
  7. /// Contains the parameters for a RCD construction / operation
  8. /// </summary>
  9. [Prototype("rcd")]
  10. public sealed partial class RCDPrototype : IPrototype
  11. {
  12. [IdDataField]
  13. public string ID { get; private set; } = default!;
  14. /// <summary>
  15. /// The RCD mode associated with the operation
  16. /// </summary>
  17. [DataField(required: true), ViewVariables(VVAccess.ReadOnly)]
  18. public RcdMode Mode { get; private set; } = RcdMode.Invalid;
  19. /// <summary>
  20. /// The name associated with the prototype
  21. /// </summary>
  22. [DataField("name"), ViewVariables(VVAccess.ReadOnly)]
  23. public string SetName { get; private set; } = "Unknown";
  24. /// <summary>
  25. /// The name of the radial container that this prototype will be listed under on the RCD menu
  26. /// </summary>
  27. [DataField, ViewVariables(VVAccess.ReadOnly)]
  28. public string Category { get; private set; } = "Undefined";
  29. /// <summary>
  30. /// Texture path for this prototypes menu icon
  31. /// </summary>
  32. [DataField, ViewVariables(VVAccess.ReadOnly)]
  33. public SpriteSpecifier? Sprite { get; private set; } = null;
  34. /// <summary>
  35. /// The entity prototype that will be constructed (mode dependent)
  36. /// </summary>
  37. [DataField, ViewVariables(VVAccess.ReadOnly)]
  38. public string? Prototype { get; private set; } = string.Empty;
  39. /// <summary>
  40. /// Number of charges consumed when the operation is completed
  41. /// </summary>
  42. [DataField, ViewVariables(VVAccess.ReadOnly)]
  43. public int Cost { get; private set; } = 1;
  44. /// <summary>
  45. /// The length of the operation
  46. /// </summary>
  47. [DataField, ViewVariables(VVAccess.ReadOnly)]
  48. public float Delay { get; private set; } = 1f;
  49. /// <summary>
  50. /// The visual effect that plays during this operation
  51. /// </summary>
  52. [DataField("fx"), ViewVariables(VVAccess.ReadOnly)]
  53. public EntProtoId? Effect { get; private set; } = null;
  54. /// <summary>
  55. /// A list of rules that govern where the entity prototype can be contructed
  56. /// </summary>
  57. [DataField("rules"), ViewVariables(VVAccess.ReadOnly)]
  58. public HashSet<RcdConstructionRule> ConstructionRules { get; private set; } = new();
  59. /// <summary>
  60. /// The collision mask used for determining whether the entity prototype will fit into a target tile
  61. /// </summary>
  62. [DataField, ViewVariables(VVAccess.ReadOnly)]
  63. public CollisionGroup CollisionMask { get; private set; } = CollisionGroup.None;
  64. /// <summary>
  65. /// Specifies a set of custom collision bounds for determining whether the entity prototype will fit into a target tile
  66. /// </summary>
  67. /// <remarks>
  68. /// Should be set assuming that the entity faces south.
  69. /// Make sure that Rotation is set to RcdRotation.User if the entity is to be rotated by the user
  70. /// </remarks>
  71. [DataField, ViewVariables(VVAccess.ReadOnly)]
  72. public Box2? CollisionBounds
  73. {
  74. get
  75. {
  76. return _collisionBounds;
  77. }
  78. private set
  79. {
  80. _collisionBounds = value;
  81. if (_collisionBounds != null)
  82. {
  83. var poly = new PolygonShape();
  84. poly.SetAsBox(_collisionBounds.Value);
  85. CollisionPolygon = poly;
  86. }
  87. }
  88. }
  89. private Box2? _collisionBounds = null;
  90. /// <summary>
  91. /// The polygon shape associated with the prototype CollisionBounds (if set)
  92. /// </summary>
  93. [ViewVariables(VVAccess.ReadOnly)]
  94. public PolygonShape? CollisionPolygon { get; private set; } = null;
  95. /// <summary>
  96. /// Governs how the local rotation of the constructed entity will be set
  97. /// </summary>
  98. [DataField, ViewVariables(VVAccess.ReadOnly)]
  99. public RcdRotation Rotation { get; private set; } = RcdRotation.User;
  100. }
  101. public enum RcdMode : byte
  102. {
  103. Invalid,
  104. Deconstruct,
  105. ConstructTile,
  106. ConstructObject,
  107. }
  108. // These are to be replaced with more flexible 'RulesRule' at a later time
  109. public enum RcdConstructionRule : byte
  110. {
  111. MustBuildOnEmptyTile, // Can only be built on empty space (e.g. lattice)
  112. CanBuildOnEmptyTile, // Can be built on empty space or replace an existing tile (e.g. hull plating)
  113. MustBuildOnSubfloor, // Can only be built on exposed subfloor (e.g. catwalks on lattice or hull plating)
  114. IsWindow, // The entity is a window and can be built on grilles
  115. IsCatwalk, // The entity is a catwalk
  116. }
  117. public enum RcdRotation : byte
  118. {
  119. Fixed, // The entity has a local rotation of zero
  120. Camera, // The rotation of the entity matches the local player camera
  121. User, // The entity can be rotated by the local player prior to placement
  122. }