Time delay on change of Apc Ui charge % (#1241)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-07-01 09:39:09 -06:00
committed by GitHub
parent 8808d5e0f8
commit b807b9e7ee

View File

@@ -41,6 +41,8 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
private float _lastCharge = 0f; private float _lastCharge = 0f;
private TimeSpan _lastChargeChange;
private bool _uiDirty = true; private bool _uiDirty = true;
private const float HighPowerThreshold = 0.9f; private const float HighPowerThreshold = 0.9f;
@@ -91,9 +93,10 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
_appearance.SetData(ApcVisuals.ChargeState, newState); _appearance.SetData(ApcVisuals.ChargeState, newState);
} }
var newCharge = Battery.CurrentCharge; var newCharge = Battery.CurrentCharge;
if (newCharge != _lastCharge) if (newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
{ {
_lastCharge = newCharge; _lastCharge = newCharge;
_lastChargeChange = _gameTiming.CurTime;
_uiDirty = true; _uiDirty = true;
} }
var extPowerState = CalcExtPowerState(); var extPowerState = CalcExtPowerState();