]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix toggle mask issues (#22496)
authorthemias <89101928+themias@users.noreply.github.com>
Thu, 14 Dec 2023 20:49:26 +0000 (15:49 -0500)
committerGitHub <noreply@github.com>
Thu, 14 Dec 2023 20:49:26 +0000 (13:49 -0700)
Content.Server/Body/Systems/LungSystem.cs
Content.Shared/Clothing/EntitySystems/MaskSystem.cs

index 954b55322778a35164be4dbe33ae6ef60a186787..1843ae033e6f1fe5329a62e2b738d225ad2bda35 100644 (file)
@@ -53,22 +53,18 @@ public sealed class LungSystem : EntitySystem
 
     private void OnMaskToggled(Entity<BreathToolComponent> ent, ref ItemMaskToggledEvent args)
     {
-        // toggle breath tool connection (skip during equip since that is handled in LungSystem)
-        if (args.IsEquip)
+        if (args.IsToggled || args.IsEquip)
         {
-            if (args.IsToggled)
-            {
-                _atmos.DisconnectInternals(ent.Comp);
-            }
-            else
-            {
-                ent.Comp.IsFunctional = true;
+            _atmos.DisconnectInternals(ent.Comp);
+        }
+        else
+        {
+            ent.Comp.IsFunctional = true;
 
-                if (TryComp(args.Wearer, out InternalsComponent? internals))
-                {
-                    ent.Comp.ConnectedInternalsEntity = args.Wearer;
-                    _internals.ConnectBreathTool((args.Wearer, internals), ent);
-                }
+            if (TryComp(args.Wearer, out InternalsComponent? internals))
+            {
+                ent.Comp.ConnectedInternalsEntity = args.Wearer;
+                _internals.ConnectBreathTool((args.Wearer, internals), ent);
             }
         }
     }
index 50cf3afe50a2d21210633863043793dfe698fbe5..6c135e1a07a95bc47f668c6eb458e44f5aaf0e27 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.Clothing.Components;
 using Content.Shared.Inventory;
 using Content.Shared.Inventory.Events;
 using Content.Shared.Popups;
+using Robust.Shared.Timing;
 
 namespace Content.Shared.Clothing.EntitySystems;
 
@@ -11,6 +12,7 @@ public sealed class MaskSystem : EntitySystem
     [Dependency] private readonly SharedActionsSystem _actionSystem = default!;
     [Dependency] private readonly InventorySystem _inventorySystem = default!;
     [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+    [Dependency] private readonly IGameTiming _timing = default!;
 
     public override void Initialize()
     {
@@ -30,7 +32,7 @@ public sealed class MaskSystem : EntitySystem
     private void OnToggleMask(Entity<MaskComponent> ent, ref ToggleMaskEvent args)
     {
         var (uid, mask) = ent;
-        if (mask.ToggleActionEntity == null)
+        if (mask.ToggleActionEntity == null || !_timing.IsFirstTimePredicted)
             return;
 
         if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !uid.Equals(existing))