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

@@ -3,12 +3,14 @@ using Content.Server.Atmos.EntitySystems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Shared.Collections;
using Robust.Shared.Timing;
namespace Content.Server.Movement.Systems;
public sealed class JetpackSystem : SharedJetpackSystem
{
[Dependency] private readonly GasTankSystem _gasTank = default!;
[Dependency] private readonly IGameTiming _timing = default!;
private const float UpdateCooldown = 0.5f;
@@ -25,10 +27,9 @@ public sealed class JetpackSystem : SharedJetpackSystem
foreach (var (active, comp, gasTank) in EntityQuery<ActiveJetpackComponent, JetpackComponent, GasTankComponent>())
{
active.Accumulator += frameTime;
if (active.Accumulator < UpdateCooldown) continue;
if (_timing.CurTime < active.TargetTime) continue;
active.Accumulator -= UpdateCooldown;
active.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(active.EffectCooldown);
var air = _gasTank.RemoveAir(gasTank, comp.MoleUsage);
if (air == null || !MathHelper.CloseTo(air.TotalMoles, comp.MoleUsage, 0.001f))