changing accumulators to timespan targets (#12407)

* changing accumulators to timespan targets

* Update Content.Server/Abilities/Mime/MimePowersSystem.cs

Co-authored-by: 0x6273 <0x40@keemail.me>

* Update MimePowersSystem.cs

* serializing timespans and adding pausetime where applicable

* remove nullable

Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com>
Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
rolfero
2022-11-08 20:59:34 +01:00
committed by GitHub
parent 3ec0202634
commit 1151ca42e5
11 changed files with 82 additions and 64 deletions

View File

@@ -15,6 +15,7 @@ using Content.Shared.Damage;
using Content.Shared.Emag.Systems;
using Content.Server.Construction;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server.Bed
{
@@ -26,6 +27,7 @@ namespace Content.Server.Bed
[Dependency] private readonly SleepingSystem _sleepingSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
@@ -44,6 +46,7 @@ namespace Content.Server.Bed
if (args.Buckling)
{
AddComp<HealOnBuckleHealingComponent>(uid);
component.NextHealTime = _timing.CurTime + TimeSpan.FromSeconds(component.HealTime);
if (sleepAction != null)
_actionsSystem.AddAction(args.BuckledEntity, new InstantAction(sleepAction), null);
return;
@@ -54,7 +57,6 @@ namespace Content.Server.Bed
_sleepingSystem.TryWaking(args.BuckledEntity);
RemComp<HealOnBuckleHealingComponent>(uid);
component.Accumulator = 0;
}
public override void Update(float frameTime)
@@ -63,12 +65,10 @@ namespace Content.Server.Bed
foreach (var (_, bedComponent, strapComponent) in EntityQuery<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>())
{
bedComponent.Accumulator += frameTime;
if (bedComponent.Accumulator < bedComponent.HealTime)
if (_timing.CurTime < bedComponent.NextHealTime)
continue;
bedComponent.Accumulator -= bedComponent.HealTime;
bedComponent.NextHealTime += TimeSpan.FromSeconds(bedComponent.HealTime);
if (strapComponent.BuckledEntities.Count == 0) continue;