Make delay incurred from additional syringe contents modifiable + tiny syringe buff/fix (#29825)
* 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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user