Beds, Medical Beds, Stasis Beds (#6695)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user