1
0

ConstructionPrototype.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Content.Shared.Construction.Conditions;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  5. using Robust.Shared.Utility;
  6. namespace Content.Shared.Construction.Prototypes;
  7. [Prototype]
  8. public sealed partial class ConstructionPrototype : IPrototype
  9. {
  10. [DataField("conditions")] private List<IConstructionCondition> _conditions = new();
  11. /// <summary>
  12. /// Hide from the construction list
  13. /// </summary>
  14. [DataField("hide")]
  15. public bool Hide = false;
  16. /// <summary>
  17. /// Friendly name displayed in the construction GUI.
  18. /// </summary>
  19. [DataField("name")]
  20. public string Name = string.Empty;
  21. /// <summary>
  22. /// "Useful" description displayed in the construction GUI.
  23. /// </summary>
  24. [DataField("description")]
  25. public string Description = string.Empty;
  26. /// <summary>
  27. /// The <see cref="ConstructionGraphPrototype"/> this construction will be using.
  28. /// </summary>
  29. [DataField("graph", customTypeSerializer: typeof(PrototypeIdSerializer<ConstructionGraphPrototype>), required: true)]
  30. public string Graph = string.Empty;
  31. /// <summary>
  32. /// The target <see cref="ConstructionGraphNode"/> this construction will guide the user to.
  33. /// </summary>
  34. [DataField("targetNode")]
  35. public string TargetNode = string.Empty;
  36. /// <summary>
  37. /// The starting <see cref="ConstructionGraphNode"/> this construction will start at.
  38. /// </summary>
  39. [DataField("startNode")]
  40. public string StartNode = string.Empty;
  41. /// <summary>
  42. /// Texture path inside the construction GUI.
  43. /// </summary>
  44. [DataField("icon")]
  45. public SpriteSpecifier Icon = SpriteSpecifier.Invalid;
  46. /// <summary>
  47. /// Texture paths used for the construction ghost.
  48. /// </summary>
  49. [DataField("layers")]
  50. private List<SpriteSpecifier>? _layers;
  51. /// <summary>
  52. /// If you can start building or complete steps on impassable terrain.
  53. /// </summary>
  54. [DataField("canBuildInImpassable")]
  55. public bool CanBuildInImpassable { get; private set; }
  56. [DataField("agemax")]
  57. public int AgeMax { get; set; } = 8;
  58. [DataField("agemin")]
  59. public int AgeMin { get; set; } = 8;
  60. /// <summary>
  61. /// If this crafting recipe is available in TDM.
  62. /// </summary>
  63. [DataField("tdm")]
  64. public bool TDM { get; set; } = false;
  65. /// <summary>
  66. /// If not null, then this is used to check if the entity trying to construct this is whitelisted.
  67. /// If they're not whitelisted, hide the item.
  68. /// </summary>
  69. [DataField("entityWhitelist")]
  70. public EntityWhitelist? EntityWhitelist = null;
  71. [DataField("category")] public string Category { get; private set; } = "";
  72. [DataField("objectType")] public ConstructionType Type { get; private set; } = ConstructionType.Structure;
  73. [ViewVariables]
  74. [IdDataField]
  75. public string ID { get; private set; } = default!;
  76. [DataField("placementMode")]
  77. public string PlacementMode = "PlaceFree";
  78. /// <summary>
  79. /// Whether this construction can be constructed rotated or not.
  80. /// </summary>
  81. [DataField("canRotate")]
  82. public bool CanRotate = true;
  83. /// <summary>
  84. /// Construction to replace this construction with when the current one is 'flipped'
  85. /// </summary>
  86. [DataField("mirror", customTypeSerializer: typeof(PrototypeIdSerializer<ConstructionPrototype>))]
  87. public string? Mirror;
  88. public IReadOnlyList<IConstructionCondition> Conditions => _conditions;
  89. public IReadOnlyList<SpriteSpecifier> Layers => _layers ?? new List<SpriteSpecifier> { Icon };
  90. }
  91. public enum ConstructionType
  92. {
  93. Structure,
  94. Item,
  95. }