GameMapPrototype.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Content.Server.Station;
  2. using JetBrains.Annotations;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Utility;
  5. using System.Diagnostics;
  6. using System.Numerics;
  7. namespace Content.Server.Maps;
  8. /// <summary>
  9. /// Prototype data for a game map.
  10. /// </summary>
  11. /// <remarks>
  12. /// Forks should not directly edit existing parts of this class.
  13. /// Make a new partial for your fancy new feature, it'll save you time later.
  14. /// </remarks>
  15. [Prototype, PublicAPI]
  16. [DebuggerDisplay("GameMapPrototype [{ID} - {MapName}]")]
  17. public sealed partial class GameMapPrototype : IPrototype
  18. {
  19. /// <inheritdoc/>
  20. [IdDataField]
  21. public string ID { get; private set; } = default!;
  22. [DataField]
  23. public float MaxRandomOffset = 1000f;
  24. /// <summary>
  25. /// Turns out some of the map files are actually secretly grids. Excellent. I love map loading code.
  26. /// </summary>
  27. [DataField] public bool IsGrid;
  28. [DataField]
  29. public bool RandomRotation = true;
  30. /// <summary>
  31. /// Name of the map to use in generic messages, like the map vote.
  32. /// </summary>
  33. [DataField(required: true)]
  34. public string MapName { get; private set; } = default!;
  35. /// <summary>
  36. /// Relative directory path to the given map, i.e. `/Maps/saltern.yml`
  37. /// </summary>
  38. [DataField(required: true)]
  39. public ResPath MapPath { get; private set; } = default!;
  40. /// <summary>
  41. /// If this map requires a specific preset
  42. /// </summary>
  43. [DataField("fixedPreset")]
  44. public string FixedPreset { get; private set; } = "";
  45. [DataField("stations", required: true)]
  46. private Dictionary<string, StationConfig> _stations = new();
  47. /// <summary>
  48. /// The stations this map contains. The names should match with the BecomesStation components.
  49. /// </summary>
  50. public IReadOnlyDictionary<string, StationConfig> Stations => _stations;
  51. /// <summary>
  52. /// Performs a shallow clone of this map prototype, replacing <c>MapPath</c> with the argument.
  53. /// </summary>
  54. public GameMapPrototype Persistence(ResPath mapPath)
  55. {
  56. return new()
  57. {
  58. ID = ID,
  59. MapName = MapName,
  60. MapPath = mapPath,
  61. _stations = _stations
  62. };
  63. }
  64. }