From 5d66a08ac9ac20ee9042b7fc70405061fca01f3f Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Tue, 9 Nov 2021 13:00:08 +0100 Subject: [PATCH] GasCanisterSystem cleanup, use EntityUid more. --- .../Unary/EntitySystems/GasCanisterSystem.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index 4a2eeaedd5..2b38b35158 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -29,6 +29,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems { [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; public override void Initialize() { @@ -53,7 +54,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems /// public void PurgeContents(EntityUid uid, GasCanisterComponent? canister = null, TransformComponent? transform = null) { - if (!Resolve(uid, ref canister, ref transform)) return; + if (!Resolve(uid, ref canister, ref transform)) + return; var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true); @@ -66,10 +68,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnCanisterStartup(EntityUid uid, GasCanisterComponent canister, ComponentStartup args) { // Ensure container manager. - if (!EntityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager)) - { - containerManager = EntityManager.AddComponent(EntityManager.GetEntity(uid)); - } + var containerManager = EntityManager.EnsureComponent(uid); // Ensure container. if (!containerManager.TryGetContainer(canister.ContainerName, out _)) @@ -80,9 +79,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private bool CheckInteract(ICommonSession session) { - if (session.AttachedEntity is not {} entity - || !Get().CanInteract(entity) - || !Get().CanUse(entity)) + if (session.AttachedEntityUid is not {} uid + || !_actionBlockerSystem.CanInteract(uid) + || !_actionBlockerSystem.CanUse(uid)) return false; return true; @@ -105,9 +104,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems if (containerManager.TryGetContainer(canister.ContainerName, out var tankContainer) && tankContainer.ContainedEntities.Count > 0) { - var tank = tankContainer.ContainedEntities[0]; - var tankComponent = tank.GetComponent(); - tankLabel = tank.Name; + var tank = tankContainer.ContainedEntities[0].Uid; + var tankComponent = EntityManager.GetComponent(tank); + tankLabel = EntityManager.GetComponent(tank).EntityName; tankPressure = tankComponent.Air.Pressure; } @@ -231,7 +230,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems if (!args.User.TryGetComponent(out ActorComponent? actor)) return; - component.Owner.GetUIOrNull(GasCanisterUiKey.Key)?.Open(actor.PlayerSession); + _userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession); args.Handled = true; } @@ -241,7 +240,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems if (!args.User.TryGetComponent(out ActorComponent? actor)) return; - component.Owner.GetUIOrNull(GasCanisterUiKey.Key)?.Open(actor.PlayerSession); + _userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession); args.Handled = true; }