Update SharedBiomeSystem methods to use Entity<T> (#37698)

* Fix warning in TryGetBiomeTile

* Overload TryGetBiomeTile

* Overload more methods, fix internal warnings

* Update TryGetEntity uses

* Update TryGetTile uses

* Cleanup TryGetDecals use

* Formatting

* Two more warnings while we're here
This commit is contained in:
Tayrtahn
2025-05-21 22:10:52 -04:00
committed by GitHub
parent db0fb6118f
commit 5a93099509
4 changed files with 77 additions and 32 deletions

View File

@@ -109,7 +109,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
if (biome.Template == null || !reloads.Modified.TryGetValue(biome.Template, out var proto))
continue;
SetTemplate(uid, biome, (BiomeTemplatePrototype) proto);
SetTemplate(uid, biome, (BiomeTemplatePrototype)proto);
}
}
@@ -257,7 +257,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
private void OnFTLStarted(ref FTLStartedEvent ev)
{
var targetMap = _transform.ToMapCoordinates(ev.TargetCoordinates);
var targetMapUid = _mapManager.GetMapEntityId(targetMap.MapId);
var targetMapUid = _mapSystem.GetMapOrInvalid(targetMap.MapId);
if (!TryComp<BiomeComponent>(targetMapUid, out var biome))
return;
@@ -283,12 +283,12 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
{
for (var y = Math.Floor(aabb.Bottom); y <= Math.Ceiling(aabb.Top); y++)
{
var index = new Vector2i((int) x, (int) y);
var index = new Vector2i((int)x, (int)y);
var chunk = SharedMapSystem.GetChunkIndices(index, ChunkSize);
var mod = biome.ModifiedTiles.GetOrNew(chunk * ChunkSize);
if (!mod.Add(index) || !TryGetBiomeTile(index, biome.Layers, biome.Seed, grid, out var tile))
if (!mod.Add(index) || !TryGetBiomeTile(index, biome.Layers, biome.Seed, (ev.MapUid, grid), out var tile))
continue;
// If we flag it as modified then the tile is never set so need to do it ourselves.
@@ -493,9 +493,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
var layerProto = ProtoManager.Index<BiomeMarkerLayerPrototype>(layer);
var markerSeed = seed + chunk.X * ChunkSize + chunk.Y + localIdx;
var rand = new Random(markerSeed);
var buffer = (int) (layerProto.Radius / 2f);
var buffer = (int)(layerProto.Radius / 2f);
var bounds = new Box2i(chunk + buffer, chunk + layerProto.Size - buffer);
var count = (int) (bounds.Area / (layerProto.Radius * layerProto.Radius));
var count = (int)(bounds.Area / (layerProto.Radius * layerProto.Radius));
count = Math.Min(count, layerProto.MaxCount);
GetMarkerNodes(gridUid, component, grid, layerProto, forced, bounds, count, rand,
@@ -607,7 +607,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
continue;
// Check if mask matches // anything blocking.
TryGetEntity(node, biome, grid, out var proto);
TryGetEntity(node, biome, (gridUid, grid), out var proto);
// If there's an existing entity and it doesn't match the mask then skip.
if (layerProto.EntityMask.Count > 0 &&
@@ -727,14 +727,14 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
continue;
// Need to ensure the tile under it has loaded for anchoring.
if (TryGetBiomeTile(node, component.Layers, seed, grid, out var tile))
if (TryGetBiomeTile(node, component.Layers, seed, (gridUid, grid), out var tile))
{
_mapSystem.SetTile(gridUid, grid, node, tile.Value);
}
string? prototype;
if (TryGetEntity(node, component, grid, out var proto) &&
if (TryGetEntity(node, component, (gridUid, grid), out var proto) &&
layerProto.EntityMask.TryGetValue(proto, out var maskedProto))
{
prototype = maskedProto;
@@ -793,7 +793,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
if (_mapSystem.TryGetTileRef(gridUid, grid, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
continue;
if (!TryGetBiomeTile(indices, component.Layers, seed, grid, out var biomeTile))
if (!TryGetBiomeTile(indices, component.Layers, seed, (gridUid, grid), out var biomeTile))
continue;
_tiles.Add((indices, biomeTile.Value));
@@ -819,7 +819,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
// Don't mess with anything that's potentially anchored.
var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
if (anchored.MoveNext(out _) || !TryGetEntity(indices, component, grid, out var entPrototype))
if (anchored.MoveNext(out _) || !TryGetEntity(indices, component, (gridUid, grid), out var entPrototype))
continue;
// TODO: Fix non-anchored ents spawning.
@@ -852,7 +852,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
// Don't mess with anything that's potentially anchored.
var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
if (anchored.MoveNext(out _) || !TryGetDecals(indices, component.Layers, seed, grid, out var decals))
if (anchored.MoveNext(out _) || !TryGetDecals(indices, component.Layers, seed, (gridUid, grid), out var decals))
continue;
foreach (var decal in decals)
@@ -966,7 +966,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
continue;
// Don't mess with anything that's potentially anchored.
var anchored = grid.GetAnchoredEntitiesEnumerator(indices);
var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
if (anchored.MoveNext(out _))
{
@@ -1040,8 +1040,8 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
EnsureComp<SunShadowCycleComponent>(mapUid);
var moles = new float[Atmospherics.AdjustedNumberOfGases];
moles[(int) Gas.Oxygen] = 21.824779f;
moles[(int) Gas.Nitrogen] = 82.10312f;
moles[(int)Gas.Oxygen] = 21.824779f;
moles[(int)Gas.Nitrogen] = 82.10312f;
var mixture = new GasMixture(moles, Atmospherics.T20C);
@@ -1070,7 +1070,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
continue;
}
if (!TryGetBiomeTile(tileSet.GridIndices, biome.Layers, biome.Seed, mapGrid, out var tile))
if (!TryGetBiomeTile(tileSet.GridIndices, biome.Layers, biome.Seed, (mapUid, mapGrid), out var tile))
{
continue;
}