From 42d2334334e496c5a137d4ed4d2917d179a402ce Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 23 Aug 2020 17:17:19 +0200 Subject: [PATCH] Fix airtight entities not getting invalidated and their vacuum not being fixed (#1876) --- .../Components/Atmos/AirtightComponent.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 5e50bd0c64..3703eff58d 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -4,6 +4,8 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.Map; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Serialization; @@ -14,6 +16,8 @@ namespace Content.Server.GameObjects.Components.Atmos [RegisterComponent] public class AirtightComponent : Component, IMapInit { + [Dependency] private readonly IMapManager _mapManager = default!; + private (GridId, MapIndices) _lastPosition; public override string Name => "Airtight"; @@ -56,7 +60,7 @@ namespace Content.Server.GameObjects.Components.Atmos // down than the object magically not being airtight, so log one if the SnapGrid component // is missing. if (!Owner.EnsureComponent(out SnapGridComponent _)) - Logger.Warning($"Entity {Owner} at {Owner.Transform.MapPosition.ToString()} doesn't have a {nameof(SnapGridComponent)}"); + Logger.Warning($"Entity {Owner} at {Owner.Transform.MapPosition.ToString()} didn't have a {nameof(SnapGridComponent)}"); UpdatePosition(); } @@ -81,12 +85,13 @@ namespace Content.Server.GameObjects.Components.Atmos if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) { snapGrid.OnPositionChanged -= OnTransformMove; - - if (_fixVacuum) - EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID)? - .FixVacuum(snapGrid.Position); } + if (_fixVacuum) + { + var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager); + EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID)?.FixVacuum(mapIndices); + } UpdatePosition(); } @@ -104,10 +109,8 @@ namespace Content.Server.GameObjects.Components.Atmos private void UpdatePosition() { - if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) - { - UpdatePosition(Owner.Transform.GridID, snapGrid.Position); - } + var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager); + UpdatePosition(Owner.Transform.GridID, mapIndices); } private void UpdatePosition(GridId gridId, MapIndices pos)