Skip to content

Commit

Permalink
Revert "improve BiomeDunGen (#33113)"
Browse files Browse the repository at this point in the history
This reverts commit b94731c.
  • Loading branch information
deltanedas committed Nov 24, 2024
1 parent 3a0ec3d commit fdc509d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
25 changes: 9 additions & 16 deletions Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,43 +15,35 @@ public sealed partial class DungeonJob
/// </summary>
private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon, HashSet<Vector2i> reservedTiles, Random random)
{
if (!_prototype.TryIndex(dunGen.BiomeTemplate, out var indexedBiome))
if (_entManager.TryGetComponent(_gridUid, out BiomeComponent? biomeComp))
return;

biomeComp = _entManager.AddComponent<BiomeComponent>(_gridUid);
var biomeSystem = _entManager.System<BiomeSystem>();

biomeSystem.SetTemplate(_gridUid, biomeComp, _prototype.Index(dunGen.BiomeTemplate));
var seed = random.Next();
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();

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)
{
_decals.TryAddDecal(decal.ID, new EntityCoordinates(_gridUid, decal.Position), out _);
}
}

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);
Expand All @@ -70,5 +61,7 @@ private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon
if (!ValidateResume())
return;
}

biomeComp.Enabled = false;
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public bool TryGetEntity(Vector2i indices, BiomeComponent component, MapGridComp
}


public bool TryGetEntity(Vector2i indices, List<IBiomeLayer> layers, Tile tileRef, int seed, MapGridComponent grid,
private bool TryGetEntity(Vector2i indices, List<IBiomeLayer> layers, Tile tileRef, int seed, MapGridComponent grid,
[NotNullWhen(true)] out string? entity)
{
var tileId = TileDefManager[tileRef.TypeId].ID;
Expand Down
7 changes: 0 additions & 7 deletions Content.Shared/Procedural/PostGeneration/BiomeDunGen.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Content.Shared.Maps;
using Content.Shared.Parallax.Biomes;
using Robust.Shared.Prototypes;

Expand All @@ -12,10 +11,4 @@ public sealed partial class BiomeDunGen : IDunGenLayer
{
[DataField(required: true)]
public ProtoId<BiomeTemplatePrototype> BiomeTemplate;

/// <summary>
/// creates a biome only on the specified tiles
/// </summary>
[DataField]
public HashSet<ProtoId<ContentTileDefinition>>? TileMask;
}

0 comments on commit fdc509d

Please sign in to comment.