]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make delay incurred from additional syringe contents modifiable + tiny syringe buff...
authorosjarw <62134478+osjarw@users.noreply.github.com>
Mon, 22 Jul 2024 10:20:36 +0000 (13:20 +0300)
committerGitHub <noreply@github.com>
Mon, 22 Jul 2024 10:20:36 +0000 (03:20 -0700)
* Make delay incurred by transfer amount modifiable

* No unintentional negative delay please

* Use more fixedpoint, hope I didn't break anything

* merge review suggestion

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
---------

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Content.Server/Chemistry/EntitySystems/InjectorSystem.cs
Content.Shared/Chemistry/Components/InjectorComponent.cs

index aac171371fb11a60be73afd0292ad0f63d720c08..54c3fd576fe5426aa7f32ddd4924b6e84b56e89c 100644 (file)
@@ -118,21 +118,25 @@ public sealed class InjectorSystem : SharedInjectorSystem
         if (!SolutionContainers.TryGetSolution(injector.Owner, injector.Comp.SolutionName, out _, out var solution))
             return;
 
-        var actualDelay = MathHelper.Max(injector.Comp.Delay, TimeSpan.FromSeconds(1));
-        float amountToInject;
+        var actualDelay = injector.Comp.Delay;
+        FixedPoint2 amountToInject;
         if (injector.Comp.ToggleState == InjectorToggleMode.Draw)
         {
             // additional delay is based on actual volume left to draw in syringe when smaller than transfer amount
-            amountToInject = Math.Min(injector.Comp.TransferAmount.Float(), (solution.MaxVolume - solution.Volume).Float());
+            amountToInject = FixedPoint2.Min(injector.Comp.TransferAmount, (solution.MaxVolume - solution.Volume));
         }
         else
         {
             // additional delay is based on actual volume left to inject in syringe when smaller than transfer amount
-            amountToInject = Math.Min(injector.Comp.TransferAmount.Float(), solution.Volume.Float());
+            amountToInject = FixedPoint2.Min(injector.Comp.TransferAmount, solution.Volume);
         }
 
         // Injections take 0.5 seconds longer per 5u of possible space/content
-        actualDelay += TimeSpan.FromSeconds(amountToInject / 10);
+        // First 5u(MinimumTransferAmount) doesn't incur delay
+        actualDelay += injector.Comp.DelayPerVolume * FixedPoint2.Max(0, amountToInject - injector.Comp.MinimumTransferAmount).Double();
+
+        // Ensure that minimum delay before incapacitation checks is 1 seconds
+        actualDelay = MathHelper.Max(actualDelay, TimeSpan.FromSeconds(1));
 
 
         var isTarget = user != target;
index ee7f9bd5798183bbaaf1ef1e029a4db36e52f4a7..aec6834063903188a91ddde0493e52efd6837cb7 100644 (file)
@@ -73,6 +73,12 @@ public sealed partial class InjectorComponent : Component
     [DataField]
     public TimeSpan Delay = TimeSpan.FromSeconds(5);
 
+    /// <summary>
+    /// Each additional 1u after first 5u increases the delay by X seconds.
+    /// </summary>
+    [DataField]
+    public TimeSpan DelayPerVolume = TimeSpan.FromSeconds(0.1);
+
     /// <summary>
     /// The state of the injector. Determines it's attack behavior. Containers must have the
     /// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should