private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args) { SetAirblocked(airtight, false); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum); RaiseLocalEvent(new AirtightChanged(airtight)); }
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, RotateEvent ev) { if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid) { return; } airtight.CurrentAirBlockedDirection = (int)Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation); UpdatePosition(airtight); }
private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args) { SetAirblocked(airtight, false); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); if (airtight.FixVacuum) { _atmosphereSystem.FixVacuum(airtight.LastPosition.Item1, airtight.LastPosition.Item2); } }
public void SetAirblocked(AirtightComponent airtight, bool airblocked, TransformComponent?xform = null) { if (!Resolve(airtight.Owner, ref xform)) { return; } airtight.AirBlocked = airblocked; UpdatePosition(airtight, xform); RaiseLocalEvent(airtight.Owner, new AirtightChanged(airtight)); }
public void UpdatePosition(AirtightComponent airtight) { if (!airtight.Owner.Transform.Anchored || !airtight.Owner.Transform.GridID.IsValid()) { return; } var grid = _mapManager.GetGrid(airtight.Owner.Transform.GridID); airtight.LastPosition = (airtight.Owner.Transform.GridID, grid.TileIndicesFor(airtight.Owner.Transform.Coordinates)); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); }
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, AnchorStateChangedEvent args) { var gridId = airtight.Owner.Transform.GridID; var coords = airtight.Owner.Transform.Coordinates; var grid = _mapManager.GetGrid(gridId); var tilePos = grid.TileIndicesFor(coords); // Update and invalidate new position. airtight.LastPosition = (gridId, tilePos); InvalidatePosition(gridId, tilePos); }
private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args) { if (airtight.FixAirBlockedDirectionInitialize) { OnAirtightRotated(uid, airtight, new RotateEvent(airtight.Owner, Angle.Zero, airtight.Owner.Transform.WorldRotation)); } // Adding this component will immediately anchor the entity, because the atmos system // requires airtight entities to be anchored for performance. airtight.Owner.Transform.Anchored = true; UpdatePosition(airtight); }
public void UpdatePosition(AirtightComponent airtight) { var xform = EntityManager.GetComponent <TransformComponent>(airtight.Owner); if (!xform.Anchored || !xform.GridID.IsValid()) { return; } var grid = _mapManager.GetGrid(xform.GridID); airtight.LastPosition = (xform.GridID, grid.TileIndicesFor(xform.Coordinates)); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked); }
public void UpdatePosition(AirtightComponent airtight, TransformComponent?xform = null) { if (!Resolve(airtight.Owner, ref xform)) { return; } if (!xform.Anchored || !_mapManager.TryGetGrid(xform.GridUid, out var grid)) { return; } airtight.LastPosition = (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates)); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked); }
private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args) { var xform = Transform(uid); // If the grid is deleting no point updating atmos. if (_mapManager.TryGetGrid(xform.GridID, out var grid)) { if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) { return; } } SetAirblocked(airtight, false, xform); }
private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args) { var xform = EntityManager.GetComponent <TransformComponent>(uid); if (airtight.FixAirBlockedDirectionInitialize) { var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, xform.LocalRotation, xform); OnAirtightRotated(uid, airtight, ref rotateEvent); } // Adding this component will immediately anchor the entity, because the atmos system // requires airtight entities to be anchored for performance. xform.Anchored = true; UpdatePosition(airtight); }
private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args) { var xform = Transform(uid); // If the grid is deleting no point updating atmos. if (_mapManager.TryGetGrid(xform.GridID, out var grid)) { if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) { return; } } SetAirblocked(airtight, false, xform); InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum); RaiseLocalEvent(new AirtightChanged(airtight)); }
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args) { var xform = Transform(uid); if (!TryComp(xform.GridUid, out IMapGridComponent? grid)) { return; } var gridId = xform.GridUid; var coords = xform.Coordinates; var tilePos = grid.Grid.TileIndicesFor(coords); // Update and invalidate new position. airtight.LastPosition = (gridId.Value, tilePos); InvalidatePosition(gridId.Value, tilePos); }
public AirtightChanged(AirtightComponent airtight) { Airtight = airtight; }
private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args) { }
private static void HandleSnapGridMove(EntityUid uid, AirtightComponent component, SnapGridPositionChangedEvent args) { component.OnTransformMove(); }
private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, RotateEvent ev) { airtight.RotateEvent(ev); }
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent component, AnchorStateChangedEvent args) { component.AnchorStateChanged(); }
public void SetAirblocked(AirtightComponent airtight, bool airblocked) { airtight.AirBlocked = airblocked; UpdatePosition(airtight); }
public void SetAirblocked(AirtightComponent airtight, bool airblocked) { airtight.AirBlocked = airblocked; UpdatePosition(airtight); RaiseLocalEvent((airtight).Owner, new AirtightChanged(airtight)); }