1
0

GridSpawnComponent.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Content.Server.Shuttles.Systems;
  2. using Content.Shared.Dataset;
  3. using Content.Shared.Procedural;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Utility;
  6. namespace Content.Server.Shuttles.Components;
  7. /// <summary>
  8. /// Similar to <see cref="GridFillComponent"/> except spawns the grid near to the station.
  9. /// </summary>
  10. [RegisterComponent, Access(typeof(ShuttleSystem))]
  11. public sealed partial class GridSpawnComponent : Component
  12. {
  13. /// <summary>
  14. /// Dictionary of groups where each group will have entries selected.
  15. /// String is just an identifier to make yaml easier.
  16. /// </summary>
  17. [DataField(required: true)] public Dictionary<string, IGridSpawnGroup> Groups = new();
  18. }
  19. public interface IGridSpawnGroup
  20. {
  21. /// <summary>
  22. /// Minimum distance to spawn away from the station.
  23. /// </summary>
  24. public float MinimumDistance { get; }
  25. /// <summary>
  26. /// Maximum distance to spawn away from the station.
  27. /// </summary>
  28. public float MaximumDistance { get; }
  29. /// <inheritdoc />
  30. public ProtoId<LocalizedDatasetPrototype>? NameDataset { get; }
  31. /// <inheritdoc />
  32. int MinCount { get; set; }
  33. /// <inheritdoc />
  34. int MaxCount { get; set; }
  35. /// <summary>
  36. /// Components to be added to any spawned grids.
  37. /// </summary>
  38. public ComponentRegistry AddComponents { get; set; }
  39. /// <summary>
  40. /// Hide the IFF label of the grid.
  41. /// </summary>
  42. public bool Hide { get; set; }
  43. /// <summary>
  44. /// Should we set the metadata name of a grid. Useful for admin purposes.
  45. /// </summary>
  46. public bool NameGrid { get; set; }
  47. /// <summary>
  48. /// Should we add this to the station's grids (if possible / relevant).
  49. /// </summary>
  50. public bool StationGrid { get; set; }
  51. }
  52. [DataRecord]
  53. public sealed partial class DungeonSpawnGroup : IGridSpawnGroup
  54. {
  55. /// <summary>
  56. /// Prototypes we can choose from to spawn.
  57. /// </summary>
  58. public List<ProtoId<DungeonConfigPrototype>> Protos = new();
  59. /// <inheritdoc />
  60. public float MinimumDistance { get; }
  61. public float MaximumDistance { get; }
  62. /// <inheritdoc />
  63. public ProtoId<LocalizedDatasetPrototype>? NameDataset { get; }
  64. /// <inheritdoc />
  65. public int MinCount { get; set; } = 1;
  66. /// <inheritdoc />
  67. public int MaxCount { get; set; } = 1;
  68. /// <inheritdoc />
  69. public ComponentRegistry AddComponents { get; set; } = new();
  70. /// <inheritdoc />
  71. public bool Hide { get; set; } = false;
  72. /// <inheritdoc />
  73. public bool NameGrid { get; set; } = false;
  74. /// <inheritdoc />
  75. public bool StationGrid { get; set; } = false;
  76. }
  77. [DataRecord]
  78. public sealed partial class GridSpawnGroup : IGridSpawnGroup
  79. {
  80. public List<ResPath> Paths = new();
  81. /// <inheritdoc />
  82. public float MinimumDistance { get; }
  83. /// <inheritdoc />
  84. public float MaximumDistance { get; }
  85. public ProtoId<LocalizedDatasetPrototype>? NameDataset { get; }
  86. public int MinCount { get; set; } = 1;
  87. public int MaxCount { get; set; } = 1;
  88. public ComponentRegistry AddComponents { get; set; } = new();
  89. public bool Hide { get; set; } = false;
  90. public bool NameGrid { get; set; } = true;
  91. public bool StationGrid { get; set; } = true;
  92. }