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

@@ -36,7 +36,7 @@ namespace Content.Client.Audio
private bool _overlayEnabled;
private float _maxAmbientRange;
private float _cooldown;
private float _accumulator;
private TimeSpan _targetTime = TimeSpan.Zero;
private float _ambienceVolume = 0.0f;
/// <summary>
@@ -131,17 +131,16 @@ namespace Content.Client.Audio
{
base.Update(frameTime);
if (!_gameTiming.IsFirstTimePredicted) return;
if (!_gameTiming.IsFirstTimePredicted)
return;
if (_cooldown <= 0f)
{
_accumulator = 0f;
return;
}
_accumulator += frameTime;
if (_accumulator < _cooldown) return;
_accumulator -= _cooldown;
if (_gameTiming.CurTime < _targetTime)
return;
_targetTime = _gameTiming.CurTime+TimeSpan.FromSeconds(_cooldown);
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (!EntityManager.TryGetComponent(player, out TransformComponent? playerManager))