internal void HandleCooldown(SpellInfo spellInfo)
        {
            if (spellInfo.IsPassive)
            {
                return;
            }

            int cooldownLeft = spellInfo.CooldownTime;

            if (cooldownLeft <= 0)
            {
                return;
            }

            if (spellInfo.IsUsingCharges)
            {
                SpellChargeCooldown spellChargeCooldown = AddCharge(spellInfo.Id, cooldownLeft, cooldownLeft);

                if (caster is Player player && player.BoltEntity.Controller != null)
                {
                    EventHandler.ExecuteEvent(GameEvents.ServerSpellCharge, player, spellChargeCooldown);
                }
            }
            else
            {
                SpellCooldown spellCooldown = AddCooldown(spellInfo.Id, cooldownLeft, cooldownLeft);

                if (caster is Player player && player.BoltEntity.Controller != null)
                {
                    EventHandler.ExecuteEvent(GameEvents.ServerSpellCooldown, player, spellCooldown);
                }
            }
        }
        private SpellCooldown AddCooldown(int spellId, int cooldownTime, int cooldownTimeLeft)
        {
            if (spellCooldownsById.TryGetValue(spellId, out SpellCooldown spellCooldown))
            {
                spellCooldown.Cooldown     = cooldownTime;
                spellCooldown.CooldownLeft = cooldownTimeLeft;
                spellCooldown.OnHold       = false;
                return(spellCooldown);
            }

            var newCooldown = new SpellCooldown(cooldownTime, cooldownTimeLeft, spellId);

            spellCooldownsById[spellId] = newCooldown;
            spellCooldowns.Add(newCooldown);
            return(newCooldown);
        }
Пример #3
0
        internal void StartCooldown(SpellInfo spellInfo)
        {
            if (spellInfo.IsPassive)
            {
                return;
            }

            int cooldownLeft = spellInfo.CooldownTime;

            if (cooldownLeft <= 0)
            {
                return;
            }

            SpellCooldown spellCooldown = AddCooldown(spellInfo.Id, cooldownLeft, cooldownLeft);

            if (caster is Player player && player.BoltEntity.Controller != null)
            {
                EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerSpellCooldown, player, spellCooldown);
            }
        }
Пример #4
0
 public bool HasCooldown(int spellInfoId, out SpellCooldown cooldown) => spellCooldownsById.TryGetValue(spellInfoId, out cooldown) && cooldown.CooldownLeft > 0;