]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Internals are kept on as long as any breathing tool is on (#28595)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Thu, 6 Jun 2024 07:01:45 +0000 (00:01 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2024 07:01:45 +0000 (03:01 -0400)
Content.Server/Atmos/EntitySystems/AtmosphereSystem.BreathTool.cs
Content.Server/Atmos/EntitySystems/GasTankSystem.cs
Content.Server/Body/Components/InternalsComponent.cs
Content.Server/Body/Systems/InternalsSystem.cs
Content.Server/Body/Systems/LungSystem.cs

index 741a9341e79ed54f040e8e9a0e68002c75907813..327804f39a4f0ad4ed4d3d9303693f8580b81207 100644 (file)
@@ -10,21 +10,21 @@ public sealed partial class AtmosphereSystem
         SubscribeLocalEvent<BreathToolComponent, ComponentShutdown>(OnBreathToolShutdown);
     }
 
-    private void OnBreathToolShutdown(EntityUid uid, BreathToolComponent component, ComponentShutdown args)
+    private void OnBreathToolShutdown(Entity<BreathToolComponent> entity, ref ComponentShutdown args)
     {
-        DisconnectInternals(component);
+        DisconnectInternals(entity);
     }
 
-    public void DisconnectInternals(BreathToolComponent component)
+    public void DisconnectInternals(Entity<BreathToolComponent> entity)
     {
-        var old = component.ConnectedInternalsEntity;
-        component.ConnectedInternalsEntity = null;
+        var old = entity.Comp.ConnectedInternalsEntity;
+        entity.Comp.ConnectedInternalsEntity = null;
 
         if (TryComp<InternalsComponent>(old, out var internalsComponent))
         {
-            _internals.DisconnectBreathTool((old.Value, internalsComponent));
+            _internals.DisconnectBreathTool((old.Value, internalsComponent), entity.Owner);
         }
 
-        component.IsFunctional = false;
+        entity.Comp.IsFunctional = false;
     }
 }
index 07594820fcc409eed7991cc9b4cb803f13d07752..baad739804b80ed91e6895a4a11ddf2c2bc47b65 100644 (file)
@@ -220,7 +220,7 @@ namespace Content.Server.Atmos.EntitySystems
         public bool CanConnectToInternals(GasTankComponent component)
         {
             var internals = GetInternalsComponent(component, component.User);
-            return internals != null && internals.BreathToolEntity != null && !component.IsValveOpen;
+            return internals != null && internals.BreathTools.Count != 0 && !component.IsValveOpen;
         }
 
         public void ConnectToInternals(Entity<GasTankComponent> ent)
index 098f1789218f327dd411f55e368383e8cd697631..ef908f96553cd0b905981765caa75e861f60fee9 100644 (file)
@@ -13,7 +13,7 @@ namespace Content.Server.Body.Components
         public EntityUid? GasTankEntity;
 
         [ViewVariables]
-        public EntityUid? BreathToolEntity;
+        public HashSet<EntityUid> BreathTools { get; set; } = new();
 
         /// <summary>
         /// Toggle Internals delay when the target is not you.
index b79e083bd467ce6e5a8cf94d28808143f5b3a32b..0e568b77cb48217596d2843b6b5dec4b1f31810a 100644 (file)
@@ -44,7 +44,7 @@ public sealed class InternalsSystem : EntitySystem
 
     private void OnStartingGear(EntityUid uid, InternalsComponent component, ref StartingGearEquippedEvent args)
     {
-        if (component.BreathToolEntity == null)
+        if (component.BreathTools.Count == 0)
             return;
 
         if (component.GasTankEntity != null)
@@ -111,7 +111,7 @@ public sealed class InternalsSystem : EntitySystem
         }
 
         // If they're not on then check if we have a mask to use
-        if (internals.BreathToolEntity is null)
+        if (internals.BreathTools.Count == 0)
         {
             _popupSystem.PopupEntity(Loc.GetString("internals-no-breath-tool"), uid, user);
             return;
@@ -178,28 +178,24 @@ public sealed class InternalsSystem : EntitySystem
             _alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
         }
     }
-    public void DisconnectBreathTool(Entity<InternalsComponent> ent)
+    public void DisconnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
     {
-        var old = ent.Comp.BreathToolEntity;
-        ent.Comp.BreathToolEntity = null;
+        ent.Comp.BreathTools.Remove(toolEntity);
 
-        if (TryComp(old, out BreathToolComponent? breathTool))
-        {
-            _atmos.DisconnectInternals(breathTool);
+        if (TryComp(toolEntity, out BreathToolComponent? breathTool))
+            _atmos.DisconnectInternals((toolEntity, breathTool));
+
+        if (ent.Comp.BreathTools.Count == 0)
             DisconnectTank(ent);
-        }
 
         _alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
     }
 
     public void ConnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
     {
-        if (TryComp(ent.Comp.BreathToolEntity, out BreathToolComponent? tool))
-        {
-            _atmos.DisconnectInternals(tool);
-        }
+        if (!ent.Comp.BreathTools.Add(toolEntity))
+            return;
 
-        ent.Comp.BreathToolEntity = toolEntity;
         _alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
     }
 
@@ -217,7 +213,7 @@ public sealed class InternalsSystem : EntitySystem
 
     public bool TryConnectTank(Entity<InternalsComponent> ent, EntityUid tankEntity)
     {
-        if (ent.Comp.BreathToolEntity is null)
+        if (ent.Comp.BreathTools.Count == 0)
             return false;
 
         if (TryComp(ent.Comp.GasTankEntity, out GasTankComponent? tank))
@@ -236,14 +232,14 @@ public sealed class InternalsSystem : EntitySystem
 
     public bool AreInternalsWorking(InternalsComponent component)
     {
-        return TryComp(component.BreathToolEntity, out BreathToolComponent? breathTool)
+        return TryComp(component.BreathTools.FirstOrNull(), out BreathToolComponent? breathTool)
             && breathTool.IsFunctional
             && HasComp<GasTankComponent>(component.GasTankEntity);
     }
 
     private short GetSeverity(InternalsComponent component)
     {
-        if (component.BreathToolEntity is null || !AreInternalsWorking(component))
+        if (component.BreathTools.Count == 0 || !AreInternalsWorking(component))
             return 2;
 
         // If pressure in the tank is below low pressure threshold, flash warning on internals UI
index 7e58c24f7e4a1163652cbf58e4c8da25ef6a2b0b..a3c185d5cc67e6f69d03273dbf31455af7b988c2 100644 (file)
@@ -59,7 +59,7 @@ public sealed class LungSystem : EntitySystem
     {
         if (args.IsToggled || args.IsEquip)
         {
-            _atmos.DisconnectInternals(ent.Comp);
+            _atmos.DisconnectInternals(ent);
         }
         else
         {