From b807b9e7ee64f49763be6eea836e08c0c1d6d1cb Mon Sep 17 00:00:00 2001 From: py01 <60152240+collinlunn@users.noreply.github.com> Date: Wed, 1 Jul 2020 09:39:09 -0600 Subject: [PATCH] Time delay on change of Apc Ui charge % (#1241) Co-authored-by: py01 --- .../Components/Power/ApcNetComponents/ApcComponent.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/ApcComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/ApcComponent.cs index 6c4ad336e4..9d7cebc0fb 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/ApcComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/ApcComponent.cs @@ -41,6 +41,8 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents private float _lastCharge = 0f; + private TimeSpan _lastChargeChange; + private bool _uiDirty = true; private const float HighPowerThreshold = 0.9f; @@ -91,9 +93,10 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents _appearance.SetData(ApcVisuals.ChargeState, newState); } var newCharge = Battery.CurrentCharge; - if (newCharge != _lastCharge) + if (newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime) { _lastCharge = newCharge; + _lastChargeChange = _gameTiming.CurTime; _uiDirty = true; } var extPowerState = CalcExtPowerState();