Fix tile-events returns (#37502)

* Fix tile-events returns

Should really be continues.

* More

* More optimisations
This commit is contained in:
metalgearsloth
2025-05-16 22:22:20 +10:00
committed by GitHub
parent 1b79b97d2c
commit fca7337bcf
8 changed files with 34 additions and 26 deletions

View File

@@ -23,6 +23,9 @@ public sealed class AutomaticAtmosSystem : EntitySystem
private void OnTileChanged(ref TileChangedEvent ev)
{
if (_atmosphereSystem.HasAtmosphere(ev.Entity) || !TryComp<PhysicsComponent>(ev.Entity, out var physics))
return;
foreach (var change in ev.Changes)
{
// Only if a atmos-holding tile has been added or removed.
@@ -34,12 +37,10 @@ public sealed class AutomaticAtmosSystem : EntitySystem
var newSpace = change.NewTile.IsSpace(_tileDefinitionManager);
if (!(oldSpace && !newSpace ||
!oldSpace && newSpace) ||
_atmosphereSystem.HasAtmosphere(ev.Entity))
!oldSpace && newSpace))
{
continue;
if (!TryComp<PhysicsComponent>(ev.Entity, out var physics))
return;
}
// We can't actually count how many tiles there are efficiently, so instead estimate with the mass.
if (physics.Mass / ShuttleSystem.TileMassMultiplier >= 7.0f)
@@ -47,8 +48,10 @@ public sealed class AutomaticAtmosSystem : EntitySystem
AddComp<GridAtmosphereComponent>(ev.Entity);
Log.Info($"Giving grid {ev.Entity} GridAtmosphereComponent.");
}
// It's not super important to remove it should the grid become too small again.
// If explosions ever gain the ability to outright shatter grids, do rethink this.
return;
}
}
}

View File

@@ -160,18 +160,22 @@ namespace Content.Server.Decals
private void OnTileChanged(ref TileChangedEvent args)
{
if (!TryComp(args.Entity, out DecalGridComponent? grid))
return;
var toDelete = new HashSet<uint>();
foreach (var change in args.Changes)
{
if (!change.NewTile.IsSpace(_tileDefMan))
return;
if (!TryComp(args.Entity, out DecalGridComponent? grid))
return;
continue;
var indices = GetChunkIndices(change.GridIndices);
var toDelete = new HashSet<uint>();
if (!grid.ChunkCollection.ChunkCollection.TryGetValue(indices, out var chunk))
return;
continue;
toDelete.Clear();
foreach (var (uid, decal) in chunk.Decals)
{
@@ -183,7 +187,7 @@ namespace Content.Server.Decals
}
if (toDelete.Count == 0)
return;
continue;
foreach (var decalId in toDelete)
{

View File

@@ -233,14 +233,14 @@ public sealed partial class ExplosionSystem
/// </summary>
private void OnTileChanged(ref TileChangedEvent ev)
{
if (!TryComp(ev.Entity, out MapGridComponent? grid))
return;
foreach (var change in ev.Changes)
{
// only need to update the grid-edge map if a tile was added or removed from the grid.
if (!change.NewTile.IsEmpty && !change.OldTile.IsEmpty)
return;
if (!TryComp(ev.Entity, out MapGridComponent? grid))
return;
continue;
if (!_gridEdges.TryGetValue(ev.Entity, out var edges))
{
@@ -265,7 +265,7 @@ public sealed partial class ExplosionSystem
}
}
return;
continue;
}
// the tile is not empty space, but was previously. So update directly adjacent neighbours, which may no longer

View File

@@ -53,7 +53,7 @@ public sealed partial class PathfindingSystem
foreach (var change in ev.Changes)
{
if (change.OldTile.IsEmpty == change.NewTile.IsEmpty)
return;
continue;
DirtyChunk(ev.Entity, _maps.GridTileToLocal(ev.Entity, ev.Entity.Comp, change.GridIndices));
}

View File

@@ -101,10 +101,13 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
private void OnTileChanged(ref TileChangedEvent ev)
{
if (!_navQuery.TryComp(ev.Entity, out var navMap))
return;
foreach (var change in ev.Changes)
{
if (!change.EmptyChanged || !_navQuery.TryComp(ev.Entity, out var navMap))
return;
if (!change.EmptyChanged)
continue;
var tile = change.GridIndices;
var chunkOrigin = SharedMapSystem.GetChunkIndices(tile, ChunkSize);
@@ -119,7 +122,7 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
{
tileData = 0;
if (PruneEmpty((ev.Entity, navMap), chunk))
return;
continue;
}
else
{

View File

@@ -98,7 +98,7 @@ public sealed class ThrusterSystem : EntitySystem
{
// If the old tile was space but the new one isn't then disable all adjacent thrusters
if (change.NewTile.IsSpace(_tileDefManager) || !change.OldTile.IsSpace(_tileDefManager))
return;
continue;
var tilePos = change.GridIndices;
var grid = Comp<MapGridComponent>(uid);

View File

@@ -29,8 +29,6 @@ public sealed class RequiresTileSystem : EntitySystem
foreach (var change in ev.Changes)
{
var anchored = _maps.GetAnchoredEntitiesEnumerator(ev.Entity, grid, change.GridIndices);
if (anchored.Equals(AnchoredEntitiesEnumerator.Empty))
return;
while (anchored.MoveNext(out var ent))
{

View File

@@ -125,10 +125,10 @@ namespace Content.Shared.SubFloor
foreach (var change in args.Changes)
{
if (change.OldTile.IsEmpty)
return; // Nothing is anchored here anyways.
continue; // Nothing is anchored here anyways.
if (change.NewTile.IsEmpty)
return; // Anything that was here will be unanchored anyways.
continue; // Anything that was here will be unanchored anyways.
UpdateTile(args.Entity, args.Entity.Comp, change.GridIndices);
}