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

@@ -1,10 +1,9 @@
using Content.Server.Body.Components;
using Content.Server.Bed;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Body.Components;
using Content.Shared.Chemistry.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Server.Body.Systems
@@ -18,6 +17,7 @@ namespace Content.Server.Body.Systems
public override void Initialize()
{
SubscribeLocalEvent<StomachComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<StomachComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
}
public override void Update(float frameTime)
@@ -76,6 +76,20 @@ namespace Content.Server.Body.Systems
}
}
private void OnApplyMetabolicMultiplier(EntityUid uid, StomachComponent component, ApplyMetabolicMultiplierEvent args)
{
if (args.Apply)
{
component.UpdateInterval *= args.Multiplier;
return;
}
// This way we don't have to worry about it breaking if the stasis bed component is destroyed
component.UpdateInterval /= args.Multiplier;
// Reset the accumulator properly
if (component.AccumulatedFrameTime >= component.UpdateInterval)
component.AccumulatedFrameTime = component.UpdateInterval;
}
private void OnComponentInit(EntityUid uid, StomachComponent component, ComponentInit args)
{
var solution = _solutionContainerSystem.EnsureSolution(uid, DefaultSolutionName);