diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 28872ed23..38ef3d0fe 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -199,7 +199,8 @@ namespace Game.Entities void _UpdateSpells(uint diff) { - _spellHistory.Update(); + if (!_spellHistory.IsPaused()) + _spellHistory.Update(); if (GetCurrentSpell(CurrentSpellTypes.AutoRepeat) != null) _UpdateAutoRepeatSpell(); diff --git a/Source/Game/Spells/SpellHistory.cs b/Source/Game/Spells/SpellHistory.cs index e77a5be0f..957e7bd08 100644 --- a/Source/Game/Spells/SpellHistory.cs +++ b/Source/Game/Spells/SpellHistory.cs @@ -926,13 +926,44 @@ namespace Game.Spells if (!_globalCooldowns.TryGetValue(spellInfo.StartRecoveryCategory, out DateTime end)) return TimeSpan.Zero; - DateTime now = GameTime.GetDateAndTime(); + DateTime now = GameTime.GetSystemTime(); if (end < now) return TimeSpan.Zero; return end - now; } + public bool IsPaused() { return _pauseTime.HasValue; } + + public void PauseCooldowns() + { + _pauseTime = GameTime.GetSystemTime().TimeOfDay; + } + + public void ResumeCooldowns() + { + if (!_pauseTime.HasValue) + return; + + TimeSpan pausedDuration = GameTime.GetSystemTime().TimeOfDay - _pauseTime.Value; + + foreach (var itr in _spellCooldowns) + itr.Value.CooldownEnd += pausedDuration; + + foreach (var itr in _categoryCharges.Keys) + { + for (var i = 0; i < _categoryCharges[itr].Count; ++i) + { + var entry = _categoryCharges[itr][i]; + entry.RechargeEnd += pausedDuration; + } + } + + _pauseTime = null; + + Update(); + } + public Player GetPlayerOwner() { return _owner.GetCharmerOrOwnerPlayerOrPlayerItself(); @@ -1063,6 +1094,7 @@ namespace Game.Spells DateTime[] _schoolLockouts = new DateTime[(int)SpellSchools.Max]; MultiMap _categoryCharges = new(); Dictionary _globalCooldowns = new(); + TimeSpan? _pauseTime; public class CooldownEntry {