]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make container draw disableble for mob-affecting Hyposprays (#30683)
authorVerm <32827189+Vermidia@users.noreply.github.com>
Wed, 7 May 2025 20:43:47 +0000 (15:43 -0500)
committerGitHub <noreply@github.com>
Wed, 7 May 2025 20:43:47 +0000 (16:43 -0400)
* Seperate container draw from affects mobs

* Spaces

* More spaces

* Fix toggle

* Use better ands

* Reorder checks for Performance:tm:

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Content.Client/Chemistry/UI/HyposprayStatusControl.cs
Content.Server/Chemistry/EntitySystems/HypospraySystem.cs
Content.Shared/Chemistry/Components/HyposprayComponent.cs
Content.Shared/Chemistry/EntitySystems/SharedHypospraySystem.cs

index 4a4d90dc4d5b0c822780d3500cdc1f8f767bb00b..37b6fb5ed88f31b45d7852177ccf63f746569449 100644 (file)
@@ -44,7 +44,7 @@ public sealed class HyposprayStatusControl : Control
         PrevMaxVolume = solution.MaxVolume;
         PrevOnlyAffectsMobs = _parent.Comp.OnlyAffectsMobs;
 
-        var modeStringLocalized = Loc.GetString(_parent.Comp.OnlyAffectsMobs switch
+        var modeStringLocalized = Loc.GetString((_parent.Comp.OnlyAffectsMobs && _parent.Comp.CanContainerDraw) switch
         {
             false => "hypospray-all-mode-text",
             true => "hypospray-mobs-only-mode-text",
index d537c2ffdd7e2928619c6296664508a69cdfad33..19ad64d0468c728fa3c67081f15dfc2266d4fa42 100644 (file)
@@ -33,8 +33,9 @@ public sealed class HypospraySystem : SharedHypospraySystem
 
     private bool TryUseHypospray(Entity<HyposprayComponent> entity, EntityUid target, EntityUid user)
     {
-        // if target is ineligible but is a container, try to draw from the container
-        if (!EligibleEntity(target, EntityManager, entity)
+        // if target is ineligible but is a container, try to draw from the container if allowed
+        if (entity.Comp.CanContainerDraw
+            && !EligibleEntity(target, EntityManager, entity)
             && _solutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _))
         {
             return TryDraw(entity, target, drawableSolution.Value, user);
index 17d52f0ad9333d19a052c4c3db921eb99f94705e..1e3a4751f46eba4d907cc31d11ef2b6d7d48cbec 100644 (file)
@@ -20,12 +20,18 @@ public sealed partial class HyposprayComponent : Component
 
     /// <summary>
     /// Decides whether you can inject everything or just mobs.
-    /// When you can only affect mobs, you're capable of drawing from beakers.
     /// </summary>
     [AutoNetworkedField]
     [DataField(required: true)]
     public bool OnlyAffectsMobs = false;
 
+    /// <summary>
+    /// If this can draw from containers in mob-only mode.
+    /// </summary>
+    [AutoNetworkedField]
+    [DataField]
+    public bool CanContainerDraw = true;
+
     /// <summary>
     /// Whether or not the hypospray is able to draw from containers or if it's a single use
     /// device that can only inject.
index b647d33c98c195918cb7c21496542fff94d5f1dd..6985ae693c047b77c2162f3e4f2051d66bfcee2c 100644 (file)
@@ -46,7 +46,7 @@ public abstract class SharedHypospraySystem : EntitySystem
     private void ToggleMode(Entity<HyposprayComponent> entity, EntityUid user)
     {
         SetMode(entity, !entity.Comp.OnlyAffectsMobs);
-        string msg = entity.Comp.OnlyAffectsMobs ? "hypospray-verb-mode-inject-mobs-only" : "hypospray-verb-mode-inject-all";
+        string msg = (entity.Comp.OnlyAffectsMobs && entity.Comp.CanContainerDraw) ? "hypospray-verb-mode-inject-mobs-only" : "hypospray-verb-mode-inject-all";
         _popup.PopupClient(Loc.GetString(msg), entity, user);
     }