diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 0e1f82f04f..e2c4357d58 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -88,15 +88,13 @@ namespace Content.Server.GameObjects.Components.Atmos if (!Owner.EnsureComponent(out SnapGridComponent _)) Logger.Warning($"Entity {Owner} at {Owner.Transform.MapPosition} didn't have a {nameof(SnapGridComponent)}"); - Owner.EntityManager.EventBus.SubscribeEvent(EventSource.Local, this, RotateEvent); - if(_fixAirBlockedDirectionInitialize) RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.LocalRotation)); UpdatePosition(); } - private void RotateEvent(RotateEvent ev) + public void RotateEvent(RotateEvent ev) { if (!_rotateAirBlocked || ev.Sender != Owner || _initialAirBlockedDirection == (int)AtmosDirection.Invalid) return; diff --git a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs index 55e07380ed..5a83503e23 100644 --- a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs @@ -11,6 +11,7 @@ using Robust.Server.GameObjects.EntitySystems.TileLookup; using Robust.Server.Interfaces.Timing; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Map; +using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; @@ -26,6 +27,7 @@ namespace Content.Server.GameObjects.EntitySystems [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPauseManager _pauseManager = default!; + [Dependency] private readonly IEventBus _eventBus = default!; private GasReactionPrototype[] _gasReactions = Array.Empty(); @@ -51,6 +53,24 @@ namespace Content.Server.GameObjects.EntitySystems IoCManager.InjectDependencies(_spaceAtmos); _mapManager.TileChanged += OnTileChanged; + + // Required for airtight components. + _eventBus.SubscribeEvent(EventSource.Local, this, RotateEvent); + } + + public override void Shutdown() + { + base.Shutdown(); + + _eventBus.UnsubscribeEvent(EventSource.Local, this); + } + + private void RotateEvent(RotateEvent ev) + { + if (ev.Sender.TryGetComponent(out AirtightComponent? airtight)) + { + airtight.RotateEvent(ev); + } } public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)