diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs index fdadcb7849d..65f6d2d14f9 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Content.Server.Parallax; -using Content.Shared.Maps; using Content.Shared.Parallax.Biomes; using Content.Shared.Procedural; using Content.Shared.Procedural.PostGeneration; @@ -16,35 +15,27 @@ public sealed partial class DungeonJob /// private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon, HashSet reservedTiles, Random random) { - if (!_prototype.TryIndex(dunGen.BiomeTemplate, out var indexedBiome)) + if (_entManager.TryGetComponent(_gridUid, out BiomeComponent? biomeComp)) return; + biomeComp = _entManager.AddComponent(_gridUid); var biomeSystem = _entManager.System(); - + biomeSystem.SetTemplate(_gridUid, biomeComp, _prototype.Index(dunGen.BiomeTemplate)); var seed = random.Next(); var xformQuery = _entManager.GetEntityQuery(); - var tiles = _maps.GetAllTilesEnumerator(_gridUid, _grid); - while (tiles.MoveNext(out var tileRef)) + foreach (var node in dungeon.RoomTiles) { - var node = tileRef.Value.GridIndices; - if (reservedTiles.Contains(node)) continue; - - if (dunGen.TileMask is not null) - { - if (!dunGen.TileMask.Contains(((ContentTileDefinition) _tileDefManager[tileRef.Value.Tile.TypeId]).ID)) - continue; - } // Need to set per-tile to override data. - if (biomeSystem.TryGetTile(node, indexedBiome.Layers, seed, _grid, out var tile)) + if (biomeSystem.TryGetTile(node, biomeComp.Layers, seed, _grid, out var tile)) { _maps.SetTile(_gridUid, _grid, node, tile.Value); } - if (biomeSystem.TryGetDecals(node, indexedBiome.Layers, seed, _grid, out var decals)) + if (biomeSystem.TryGetDecals(node, biomeComp.Layers, seed, _grid, out var decals)) { foreach (var decal in decals) { @@ -52,7 +43,7 @@ private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon } } - if (tile is not null && biomeSystem.TryGetEntity(node, indexedBiome.Layers, tile.Value, seed, _grid, out var entityProto)) + if (biomeSystem.TryGetEntity(node, biomeComp, _grid, out var entityProto)) { var ent = _entManager.SpawnEntity(entityProto, new EntityCoordinates(_gridUid, node + _grid.TileSizeHalfVector)); var xform = xformQuery.Get(ent); @@ -70,5 +61,7 @@ private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon if (!ValidateResume()) return; } + + biomeComp.Enabled = false; } } diff --git a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs index 250b0f70a54..b14baba9817 100644 --- a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs +++ b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs @@ -183,7 +183,7 @@ public bool TryGetEntity(Vector2i indices, BiomeComponent component, MapGridComp } - public bool TryGetEntity(Vector2i indices, List layers, Tile tileRef, int seed, MapGridComponent grid, + private bool TryGetEntity(Vector2i indices, List layers, Tile tileRef, int seed, MapGridComponent grid, [NotNullWhen(true)] out string? entity) { var tileId = TileDefManager[tileRef.TypeId].ID; diff --git a/Content.Shared/Procedural/PostGeneration/BiomeDunGen.cs b/Content.Shared/Procedural/PostGeneration/BiomeDunGen.cs index e21e582211b..833cf2dec76 100644 --- a/Content.Shared/Procedural/PostGeneration/BiomeDunGen.cs +++ b/Content.Shared/Procedural/PostGeneration/BiomeDunGen.cs @@ -1,4 +1,3 @@ -using Content.Shared.Maps; using Content.Shared.Parallax.Biomes; using Robust.Shared.Prototypes; @@ -12,10 +11,4 @@ public sealed partial class BiomeDunGen : IDunGenLayer { [DataField(required: true)] public ProtoId BiomeTemplate; - - /// - /// creates a biome only on the specified tiles - /// - [DataField] - public HashSet>? TileMask; }