]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Syringe doafter based on Syringe contents (#25890)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Wed, 13 Mar 2024 09:35:48 +0000 (02:35 -0700)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2024 09:35:48 +0000 (20:35 +1100)
Syringe delay based on amount in syringe

Co-authored-by: Plykiya <plykiya@protonmail.com>
Content.Server/Chemistry/EntitySystems/InjectorSystem.cs

index 40e637615e004d6ba880b47d221d884097067cc4..e718e14683b55a6173bde3ab15a99163ccf9805a 100644 (file)
@@ -128,9 +128,21 @@ public sealed class InjectorSystem : SharedInjectorSystem
             return;
 
         var actualDelay = MathHelper.Max(injector.Comp.Delay, TimeSpan.FromSeconds(1));
+        float 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());
+        }
+        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());
+        }
+
+        // Injections take 0.5 seconds longer per 5u of possible space/content
+        actualDelay += TimeSpan.FromSeconds(amountToInject / 10);
 
-        // Injections take 0.5 seconds longer per additional 5u
-        actualDelay += TimeSpan.FromSeconds(injector.Comp.TransferAmount.Float() / injector.Comp.Delay.TotalSeconds - 0.5f);
 
         var isTarget = user != target;