Minor biomes change (#23494)
Maybe fixes void if there's exceptions, idk
This commit is contained in:
@@ -57,6 +57,8 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
|||||||
private const float DefaultLoadRange = 16f;
|
private const float DefaultLoadRange = 16f;
|
||||||
private float _loadRange = DefaultLoadRange;
|
private float _loadRange = DefaultLoadRange;
|
||||||
|
|
||||||
|
private List<(Vector2i, Tile)> _tiles = new();
|
||||||
|
|
||||||
private ObjectPool<HashSet<Vector2i>> _tilePool =
|
private ObjectPool<HashSet<Vector2i>> _tilePool =
|
||||||
new DefaultObjectPool<HashSet<Vector2i>>(new SetPolicy<Vector2i>(), 256);
|
new DefaultObjectPool<HashSet<Vector2i>>(new SetPolicy<Vector2i>(), 256);
|
||||||
|
|
||||||
@@ -582,7 +584,6 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
|||||||
|
|
||||||
component.ForcedMarkerLayers.Clear();
|
component.ForcedMarkerLayers.Clear();
|
||||||
var active = _activeChunks[component];
|
var active = _activeChunks[component];
|
||||||
List<(Vector2i, Tile)>? tiles = null;
|
|
||||||
|
|
||||||
foreach (var chunk in active)
|
foreach (var chunk in active)
|
||||||
{
|
{
|
||||||
@@ -591,9 +592,8 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
|||||||
if (!component.LoadedChunks.Add(chunk))
|
if (!component.LoadedChunks.Add(chunk))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tiles ??= new List<(Vector2i, Tile)>(ChunkSize * ChunkSize);
|
|
||||||
// Load NOW!
|
// Load NOW!
|
||||||
LoadChunk(component, gridUid, grid, chunk, seed, tiles);
|
LoadChunk(component, gridUid, grid, chunk, seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,11 +665,11 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
|||||||
EntityUid gridUid,
|
EntityUid gridUid,
|
||||||
MapGridComponent grid,
|
MapGridComponent grid,
|
||||||
Vector2i chunk,
|
Vector2i chunk,
|
||||||
int seed,
|
int seed)
|
||||||
List<(Vector2i, Tile)> tiles)
|
|
||||||
{
|
{
|
||||||
component.ModifiedTiles.TryGetValue(chunk, out var modified);
|
component.ModifiedTiles.TryGetValue(chunk, out var modified);
|
||||||
modified ??= _tilePool.Get();
|
modified ??= _tilePool.Get();
|
||||||
|
_tiles.Clear();
|
||||||
|
|
||||||
// Set tiles first
|
// Set tiles first
|
||||||
for (var x = 0; x < ChunkSize; x++)
|
for (var x = 0; x < ChunkSize; x++)
|
||||||
@@ -686,15 +686,15 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
|||||||
if (_mapSystem.TryGetTileRef(gridUid, grid, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
|
if (_mapSystem.TryGetTileRef(gridUid, grid, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!TryGetBiomeTile(indices, component.Layers, seed, grid, out var biomeTile) || biomeTile.Value == tileRef.Tile)
|
if (!TryGetBiomeTile(indices, component.Layers, seed, grid, out var biomeTile))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tiles.Add((indices, biomeTile.Value));
|
_tiles.Add((indices, biomeTile.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mapSystem.SetTiles(gridUid, grid, tiles);
|
_mapSystem.SetTiles(gridUid, grid, _tiles);
|
||||||
tiles.Clear();
|
_tiles.Clear();
|
||||||
|
|
||||||
// Now do entities
|
// Now do entities
|
||||||
var loadedEntities = new Dictionary<EntityUid, Vector2i>();
|
var loadedEntities = new Dictionary<EntityUid, Vector2i>();
|
||||||
|
|||||||
Reference in New Issue
Block a user