Content changes for SetTiles change (#37229)

* Content changes for SetTiles change

* Retest with new engine changes

* Derp

* Update for new engine PR changes
This commit is contained in:
Tayrtahn
2025-05-15 06:26:47 -04:00
committed by GitHub
parent 715165f9cc
commit 4dc1c4c3d6
9 changed files with 187 additions and 161 deletions

View File

@@ -94,41 +94,45 @@ public sealed class ThrusterSystem : EntitySystem
private void OnShuttleTileChange(EntityUid uid, ShuttleComponent component, ref TileChangedEvent args)
{
// If the old tile was space but the new one isn't then disable all adjacent thrusters
if (args.NewTile.IsSpace(_tileDefManager) || !args.OldTile.IsSpace(_tileDefManager))
return;
var tilePos = args.NewTile.GridIndices;
var grid = Comp<MapGridComponent>(uid);
var xformQuery = GetEntityQuery<TransformComponent>();
var thrusterQuery = GetEntityQuery<ThrusterComponent>();
for (var x = -1; x <= 1; x++)
foreach (var change in args.Changes)
{
for (var y = -1; y <= 1; y++)
// 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;
var tilePos = change.GridIndices;
var grid = Comp<MapGridComponent>(uid);
var xformQuery = GetEntityQuery<TransformComponent>();
var thrusterQuery = GetEntityQuery<ThrusterComponent>();
for (var x = -1; x <= 1; x++)
{
if (x != 0 && y != 0)
continue;
var checkPos = tilePos + new Vector2i(x, y);
var enumerator = _mapSystem.GetAnchoredEntitiesEnumerator(uid, grid, checkPos);
while (enumerator.MoveNext(out var ent))
for (var y = -1; y <= 1; y++)
{
if (!thrusterQuery.TryGetComponent(ent.Value, out var thruster) || !thruster.RequireSpace)
if (x != 0 && y != 0)
continue;
// Work out if the thruster is facing this direction
var xform = xformQuery.GetComponent(ent.Value);
var direction = xform.LocalRotation.ToWorldVec();
var checkPos = tilePos + new Vector2i(x, y);
var enumerator = _mapSystem.GetAnchoredEntitiesEnumerator(uid, grid, checkPos);
if (new Vector2i((int)direction.X, (int)direction.Y) != new Vector2i(x, y))
continue;
while (enumerator.MoveNext(out var ent))
{
if (!thrusterQuery.TryGetComponent(ent.Value, out var thruster) || !thruster.RequireSpace)
continue;
DisableThruster(ent.Value, thruster, xform.GridUid);
// Work out if the thruster is facing this direction
var xform = xformQuery.GetComponent(ent.Value);
var direction = xform.LocalRotation.ToWorldVec();
if (new Vector2i((int)direction.X, (int)direction.Y) != new Vector2i(x, y))
continue;
DisableThruster(ent.Value, thruster, xform.GridUid);
}
}
}
}
}
private void OnActivateThruster(EntityUid uid, ThrusterComponent component, ActivateInWorldEvent args)