Fix tile-events returns (#37502)
* Fix tile-events returns Should really be continues. * More * More optimisations
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user