AtmosphereSystem subscribes to RotateEvent instead of AirtightComponent.

Fixes a crime against humanity
This commit is contained in:
Víctor Aguilera Puerto
2020-10-20 12:21:13 +02:00
parent 90b7239dcb
commit b409901806
2 changed files with 21 additions and 3 deletions

View File

@@ -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<RotateEvent>(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;

View File

@@ -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<GasReactionPrototype>();
@@ -51,6 +53,24 @@ namespace Content.Server.GameObjects.EntitySystems
IoCManager.InjectDependencies(_spaceAtmos);
_mapManager.TileChanged += OnTileChanged;
// Required for airtight components.
_eventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
}
public override void Shutdown()
{
base.Shutdown();
_eventBus.UnsubscribeEvent<RotateEvent>(EventSource.Local, this);
}
private void RotateEvent(RotateEvent ev)
{
if (ev.Sender.TryGetComponent(out AirtightComponent? airtight))
{
airtight.RotateEvent(ev);
}
}
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)