GameMapPrototype.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. [DataField("stations", required: true)]
  41. private Dictionary<string, StationConfig> _stations = new();
  42. /// <summary>
  43. /// The stations this map contains. The names should match with the BecomesStation components.
  44. /// </summary>
  45. public IReadOnlyDictionary<string, StationConfig> Stations => _stations;
  46. /// <summary>
  47. /// Performs a shallow clone of this map prototype, replacing <c>MapPath</c> with the argument.
  48. /// </summary>
  49. public GameMapPrototype Persistence(ResPath mapPath)
  50. {
  51. return new()
  52. {
  53. ID = ID,
  54. MapName = MapName,
  55. MapPath = mapPath,
  56. _stations = _stations
  57. };
  58. }
  59. }