BiomeComponent.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Content.Shared.Parallax.Biomes.Layers;
  2. using Content.Shared.Parallax.Biomes.Markers;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Noise;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
  8. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
  9. namespace Content.Shared.Parallax.Biomes;
  10. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), Access(typeof(SharedBiomeSystem))]
  11. public sealed partial class BiomeComponent : Component
  12. {
  13. /// <summary>
  14. /// Do we load / deload.
  15. /// </summary>
  16. [DataField, ViewVariables(VVAccess.ReadWrite), Access(Other = AccessPermissions.ReadWriteExecute)]
  17. public bool Enabled = true;
  18. [ViewVariables(VVAccess.ReadWrite), DataField("seed")]
  19. [AutoNetworkedField]
  20. public int Seed = -1;
  21. /// <summary>
  22. /// The underlying entity, decal, and tile layers for the biome.
  23. /// </summary>
  24. [DataField("layers")]
  25. [AutoNetworkedField]
  26. public List<IBiomeLayer> Layers = new();
  27. /// <summary>
  28. /// Templates to use for <see cref="Layers"/>.
  29. /// If this is set on mapinit, it will fill out layers automatically.
  30. /// If not set, use <c>BiomeSystem</c> to do it.
  31. /// Prototype reloading will also use this.
  32. /// </summary>
  33. [DataField]
  34. public ProtoId<BiomeTemplatePrototype>? Template;
  35. /// <summary>
  36. /// If we've already generated a tile and couldn't deload it then we won't ever reload it in future.
  37. /// Stored by [Chunkorigin, Tiles]
  38. /// </summary>
  39. [DataField("modifiedTiles")]
  40. public Dictionary<Vector2i, HashSet<Vector2i>> ModifiedTiles = new();
  41. /// <summary>
  42. /// Decals that have been loaded as a part of this biome.
  43. /// </summary>
  44. [DataField("decals")]
  45. public Dictionary<Vector2i, Dictionary<uint, Vector2i>> LoadedDecals = new();
  46. [DataField("entities")]
  47. public Dictionary<Vector2i, Dictionary<EntityUid, Vector2i>> LoadedEntities = new();
  48. /// <summary>
  49. /// Currently active chunks
  50. /// </summary>
  51. [DataField("loadedChunks")]
  52. public HashSet<Vector2i> LoadedChunks = new();
  53. #region Markers
  54. /// <summary>
  55. /// Work out entire marker tiles in advance but only load the entities when in range.
  56. /// </summary>
  57. [DataField("pendingMarkers")]
  58. public Dictionary<Vector2i, Dictionary<string, List<Vector2i>>> PendingMarkers = new();
  59. /// <summary>
  60. /// Track what markers we've loaded already to avoid double-loading.
  61. /// </summary>
  62. [DataField("loadedMarkers", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<HashSet<Vector2i>, BiomeMarkerLayerPrototype>))]
  63. public Dictionary<string, HashSet<Vector2i>> LoadedMarkers = new();
  64. [DataField]
  65. public HashSet<ProtoId<BiomeMarkerLayerPrototype>> MarkerLayers = new();
  66. /// <summary>
  67. /// One-tick forcing of marker layers to bulldoze any entities in the way.
  68. /// </summary>
  69. [DataField]
  70. public HashSet<ProtoId<BiomeMarkerLayerPrototype>> ForcedMarkerLayers = new();
  71. #endregion
  72. }