]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cycle injector transfer amount on alt. use (#25566)
authorveprolet <68151557+veprolet@users.noreply.github.com>
Wed, 13 Mar 2024 10:00:45 +0000 (11:00 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2024 10:00:45 +0000 (21:00 +1100)
* Add toggle verb for injector transfer amount

* Fix injector verb priority scalability

---------

Co-authored-by: veprolet <>
Content.Shared/Chemistry/Components/InjectorComponent.cs
Content.Shared/Chemistry/EntitySystems/SharedInjectorSystem.cs
Resources/Locale/en-US/chemistry/components/solution-transfer-component.ftl

index 437c5e327d2e32df2e40e6e5605acb25a52715cd..605a15d73ab94ab5539c9490d05328ab43a381e9 100644 (file)
@@ -52,7 +52,7 @@ public sealed partial class InjectorComponent : Component
     ///     The maximum amount of solution that can be transferred at once from this solution.
     /// </summary>
     [DataField("maxTransferAmount")]
-    public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(50);
+    public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(15);
 
     /// <summary>
     /// Amount to inject or draw on each usage. If the injector is inject only, it will
index dad8eb40910838edc96dd9815d102b025d39e675..7e41cb39bd673dab9a5aead0efae232e83a0ae8d 100644 (file)
@@ -39,12 +39,34 @@ public abstract class SharedInjectorSystem : EntitySystem
 
         if (!HasComp<ActorComponent>(args.User))
             return;
+        var user = args.User;
 
         var (_, component) = entity;
 
-        // Add specific transfer verbs according to the container's size
+        var min = component.MinimumTransferAmount;
+        var max = component.MaximumTransferAmount;
+        var cur = component.TransferAmount;
+        var toggleAmount = cur == max ? min : max;
+
         var priority = 0;
-        var user = args.User;
+        AlternativeVerb toggleVerb = new()
+        {
+            Text = Loc.GetString("comp-solution-transfer-verb-toggle", ("amount", toggleAmount)),
+            Category = VerbCategory.SetTransferAmount,
+            Act = () =>
+            {
+                component.TransferAmount = toggleAmount;
+                Popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", toggleAmount)), user, user);
+                Dirty(entity);
+            },
+
+            Priority = priority
+        };
+        args.Verbs.Add(toggleVerb);
+
+        priority -= 1;
+
+        // Add specific transfer verbs according to the container's size
         foreach (var amount in TransferAmounts)
         {
             if (amount < component.MinimumTransferAmount || amount > component.MaximumTransferAmount)
index 14cec95129e454596bae1046b3880c7ce7b08b1b..74e38f00ab9805736cc65bb1e4580b9a328145b9 100644 (file)
@@ -11,6 +11,7 @@ comp-solution-transfer-is-full = {THE($target)} is full!
 ## Displayed in change transfer amount verb's name
 comp-solution-transfer-verb-custom-amount = Custom
 comp-solution-transfer-verb-amount = {$amount}u
+comp-solution-transfer-verb-toggle = Toggle to {$amount}u
 
 ## Displayed after you successfully change a solution's amount using the BUI
 comp-solution-transfer-set-amount = Transfer amount set to {$amount}u.