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.
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)
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;
}
}
}
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)
{
}
if (toDelete.Count == 0)
- return;
+ continue;
foreach (var decalId in toDelete)
{
/// </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))
{
}
}
- return;
+ continue;
}
// the tile is not empty space, but was previously. So update directly adjacent neighbours, which may no longer
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));
}
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);
{
tileData = 0;
if (PruneEmpty((ev.Entity, navMap), chunk))
- return;
+ continue;
}
else
{
{
// 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);
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))
{
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);
}