Beds, Medical Beds, Stasis Beds (#6695)

This commit is contained in:
Rane
2022-04-15 18:53:52 -04:00
committed by GitHub
parent 3383350c03
commit 5376aed6ea
36 changed files with 534 additions and 31 deletions

View File

@@ -38,6 +38,7 @@ namespace Content.Server.Body.Systems
// We want to process lung reagents before we inhale new reagents.
UpdatesAfter.Add(typeof(MetabolizerSystem));
SubscribeLocalEvent<RespiratorComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
}
public override void Update(float frameTime)
@@ -93,7 +94,6 @@ namespace Content.Server.Body.Systems
respirator.SuffocationCycles = 0;
}
}
public void Inhale(EntityUid uid, SharedBodyComponent? body=null)
{
if (!Resolve(uid, ref body, false))
@@ -189,6 +189,26 @@ namespace Content.Server.Body.Systems
respirator.Saturation =
Math.Clamp(respirator.Saturation, respirator.MinSaturation, respirator.MaxSaturation);
}
private void OnApplyMetabolicMultiplier(EntityUid uid, RespiratorComponent component, ApplyMetabolicMultiplierEvent args)
{
if (args.Apply)
{
component.CycleDelay *= args.Multiplier;
component.Saturation *= args.Multiplier;
component.MaxSaturation *= args.Multiplier;
component.MinSaturation *= args.Multiplier;
return;
}
// This way we don't have to worry about it breaking if the stasis bed component is destroyed
component.CycleDelay /= args.Multiplier;
component.Saturation /= args.Multiplier;
component.MaxSaturation /= args.Multiplier;
component.MinSaturation /= args.Multiplier;
// Reset the accumulator properly
if (component.AccumulatedFrametime >= component.CycleDelay)
component.AccumulatedFrametime = component.CycleDelay;
}
}
}