Content changes for grid splitting (#7645)

Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
This commit is contained in:
metalgearsloth
2022-04-24 00:59:38 +10:00
committed by GitHub
parent fd4cdbb2e0
commit 8c7772630c
35 changed files with 290 additions and 149 deletions

View File

@@ -22,6 +22,7 @@ namespace Content.Server.Atmos.EntitySystems
SubscribeLocalEvent<AirtightComponent, ComponentInit>(OnAirtightInit);
SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown);
SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged);
SubscribeLocalEvent<AirtightComponent, ReAnchorEvent>(OnAirtightReAnchor);
SubscribeLocalEvent<AirtightComponent, RotateEvent>(OnAirtightRotated);
}
@@ -57,7 +58,7 @@ namespace Content.Server.Atmos.EntitySystems
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
{
var xform = EntityManager.GetComponent<TransformComponent>(uid);
var xform = Transform(uid);
var gridId = xform.GridID;
var coords = xform.Coordinates;
@@ -70,6 +71,16 @@ namespace Content.Server.Atmos.EntitySystems
InvalidatePosition(gridId, tilePos);
}
private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args)
{
foreach (var gridId in new[] { args.OldGrid, args.GridId })
{
// Update and invalidate new position.
airtight.LastPosition = (gridId, args.TilePos);
InvalidatePosition(gridId, args.TilePos);
}
}
private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, ref RotateEvent ev)
{
if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)