]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Internals: prioritize gas tanks over jetpacks (#35068)
authorpsykana <36602558+psykana@users.noreply.github.com>
Sun, 26 Oct 2025 15:36:36 +0000 (15:36 +0000)
committerGitHub <noreply@github.com>
Sun, 26 Oct 2025 15:36:36 +0000 (15:36 +0000)
* Internals: prioritize gas tanks over jetpacks

* Use HasComp

Content.Shared/Body/Systems/SharedInternalsSystem.cs

index 7db02a376c31280a29bc6f79fb0f13b6cb0cf858..c0dc6c11727e6d7e12d6826a17dc68cd6380e7ed 100644 (file)
@@ -7,6 +7,7 @@ using Content.Shared.Hands.Components;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Internals;
 using Content.Shared.Inventory;
+using Content.Shared.Movement.Components;
 using Content.Shared.Popups;
 using Content.Shared.Verbs;
 using Robust.Shared.Containers;
@@ -258,11 +259,15 @@ public abstract class SharedInternalsSystem : EntitySystem
         Entity<HandsComponent?, InventoryComponent?, ContainerManagerComponent?> user)
     {
         // TODO use _respirator.CanMetabolizeGas() to prioritize metabolizable gasses
-        // Prioritise
-        // 1. back equipped tanks
-        // 2. exo-slot tanks
-        // 3. in-hand tanks
-        // 4. pocket/belt tanks
+        // Lookup order:
+        // 1. Back
+        // 2. Exo-slot
+        // 3. In-hand
+        // 4. Pocket/belt
+        // Jetpacks will only be used as a fallback if no other tank is found
+
+        // Store the first jetpack seen
+        Entity<GasTankComponent>? found = null;
 
         if (!Resolve(user, ref user.Comp2, ref user.Comp3))
             return null;
@@ -271,22 +276,36 @@ public abstract class SharedInternalsSystem : EntitySystem
             TryComp<GasTankComponent>(backEntity, out var backGasTank) &&
             _gasTank.CanConnectToInternals((backEntity.Value, backGasTank)))
         {
-            return (backEntity.Value, backGasTank);
+            found = (backEntity.Value, backGasTank);
+            if (!HasComp<JetpackComponent>(backEntity.Value))
+            {
+                return found;
+            }
         }
 
         if (_inventory.TryGetSlotEntity(user, "suitstorage", out var entity, user.Comp2, user.Comp3) &&
             TryComp<GasTankComponent>(entity, out var gasTank) &&
             _gasTank.CanConnectToInternals((entity.Value, gasTank)))
         {
-            return (entity.Value, gasTank);
+            found ??= (entity.Value, gasTank);
+            if (!HasComp<JetpackComponent>(entity.Value))
+            {
+                return (entity.Value, gasTank);
+            }
         }
 
         foreach (var item in _inventory.GetHandOrInventoryEntities((user.Owner, user.Comp1, user.Comp2)))
         {
             if (TryComp(item, out gasTank) && _gasTank.CanConnectToInternals((item, gasTank)))
-                return (item, gasTank);
+            {
+                found ??= (item, gasTank);
+                if (!HasComp<JetpackComponent>(item))
+                {
+                    return (item, gasTank);
+                }
+            }
         }
 
-        return null;
+        return found;
     }
 }