Fix spreaders not re-spreading on deletion (#42016)
* Fix spreaders not re-spreading on deletion * Rename another variable for clarity
This commit is contained in:
parent
402cc65477
commit
503052bca7
1 changed files with 19 additions and 14 deletions
|
|
@ -295,35 +295,38 @@ public sealed class SpreaderSystem : EntitySystem
|
||||||
/// This function activates all spreaders that are adjacent to a given entity. This also activates other spreaders
|
/// This function activates all spreaders that are adjacent to a given entity. This also activates other spreaders
|
||||||
/// on the same tile as the current entity (for thin airtight entities like windoors).
|
/// on the same tile as the current entity (for thin airtight entities like windoors).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ActivateSpreadableNeighbors(EntityUid uid, (EntityUid Grid, Vector2i Tile)? position = null)
|
public void ActivateSpreadableNeighbors(EntityUid origin, (EntityUid Grid, Vector2i Tile)? position = null)
|
||||||
{
|
{
|
||||||
Vector2i tile;
|
Vector2i tile;
|
||||||
EntityUid ent;
|
EntityUid gridUid;
|
||||||
MapGridComponent? grid;
|
MapGridComponent? gridComp;
|
||||||
|
|
||||||
if (position == null)
|
if (position == null)
|
||||||
{
|
{
|
||||||
var transform = Transform(uid);
|
var transform = Transform(origin);
|
||||||
if (!TryComp(transform.GridUid, out grid) || TerminatingOrDeleted(transform.GridUid.Value))
|
if (!TryComp(transform.GridUid, out gridComp) || TerminatingOrDeleted(transform.GridUid.Value))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tile = _map.TileIndicesFor(transform.GridUid.Value, grid, transform.Coordinates);
|
tile = _map.TileIndicesFor(transform.GridUid.Value, gridComp, transform.Coordinates);
|
||||||
ent = transform.GridUid.Value;
|
gridUid = transform.GridUid.Value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!TryComp(position.Value.Grid, out grid))
|
if (!TryComp(position.Value.Grid, out gridComp))
|
||||||
return;
|
return;
|
||||||
(ent, tile) = position.Value;
|
(gridUid, tile) = position.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var anchored = _map.GetAnchoredEntitiesEnumerator(ent, grid, tile);
|
var anchored = _map.GetAnchoredEntitiesEnumerator(gridUid, gridComp, tile);
|
||||||
while (anchored.MoveNext(out var entity))
|
while (anchored.MoveNext(out var entity))
|
||||||
{
|
{
|
||||||
if (entity == ent)
|
// Don't re-activate the terminating entity
|
||||||
|
if (entity == origin)
|
||||||
continue;
|
continue;
|
||||||
DebugTools.Assert(Transform(entity.Value).Anchored);
|
DebugTools.Assert(Transform(entity.Value).Anchored);
|
||||||
if (_query.HasComponent(ent) && !TerminatingOrDeleted(entity.Value))
|
|
||||||
|
// Activate any edge spreaders that are non-terminating
|
||||||
|
if (_query.HasComponent(entity) && !TerminatingOrDeleted(entity))
|
||||||
EnsureComp<ActiveEdgeSpreaderComponent>(entity.Value);
|
EnsureComp<ActiveEdgeSpreaderComponent>(entity.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,12 +334,14 @@ public sealed class SpreaderSystem : EntitySystem
|
||||||
{
|
{
|
||||||
var direction = (AtmosDirection) (1 << i);
|
var direction = (AtmosDirection) (1 << i);
|
||||||
var adjacentTile = SharedMapSystem.GetDirection(tile, direction.ToDirection());
|
var adjacentTile = SharedMapSystem.GetDirection(tile, direction.ToDirection());
|
||||||
anchored = _map.GetAnchoredEntitiesEnumerator(ent, grid, adjacentTile);
|
anchored = _map.GetAnchoredEntitiesEnumerator(gridUid, gridComp, adjacentTile);
|
||||||
|
|
||||||
while (anchored.MoveNext(out var entity))
|
while (anchored.MoveNext(out var entity))
|
||||||
{
|
{
|
||||||
DebugTools.Assert(Transform(entity.Value).Anchored);
|
DebugTools.Assert(Transform(entity.Value).Anchored);
|
||||||
if (_query.HasComponent(ent) && !TerminatingOrDeleted(entity.Value))
|
|
||||||
|
// Activate any edge spreaders that are non-terminating
|
||||||
|
if (_query.HasComponent(entity) && !TerminatingOrDeleted(entity))
|
||||||
EnsureComp<ActiveEdgeSpreaderComponent>(entity.Value);
|
EnsureComp<ActiveEdgeSpreaderComponent>(entity.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue