示例#1
0
        /// <summary>
        /// Clears all pending spell cooldowns.
        /// </summary>
        public override void ClearCooldowns()
        {
            // send cooldown updates to client
            foreach (var cd in m_idCooldowns)
            {
                SpellHandler.SendClearCoolDown(OwnerChar, (SpellId)cd.SpellId);
            }

            foreach (var spell in m_byId.Values)
            {
                foreach (var cd in m_categoryCooldowns)
                {
                    if (spell.Category == cd.CategoryId)
                    {
                        SpellHandler.SendClearCoolDown(OwnerChar, spell.SpellId);
                        break;
                    }
                }
            }

            // remove and delete all cooldowns
            var cds    = m_idCooldowns.ToArray();
            var catCds = m_categoryCooldowns.ToArray();

            m_idCooldowns.Clear();
            m_categoryCooldowns.Clear();

            RealmServer.IOQueue.AddMessage(new Message(() =>
            {
                foreach (var cooldown in cds)
                {
                    if (cooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)cooldown).Delete();
                    }
                }
                foreach (var cooldown in catCds)
                {
                    if (cooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)cooldown).Delete();
                    }
                }
            }));

            // clear rune cooldowns
            if (m_runes != null)
            {
                // TODO: Clear rune cooldown
            }
        }
示例#2
0
        /// <summary>
        /// Clears the cooldown for this spell
        /// </summary>
        public override void ClearCooldown(Spell cooldownSpell, bool alsoCategory = true)
        {
            var ownerChar = OwnerChar;

            // send cooldown update to client
            SpellHandler.SendClearCoolDown(ownerChar, cooldownSpell.SpellId);
            if (alsoCategory && cooldownSpell.Category != 0)
            {
                foreach (var spell in m_byId.Values)
                {
                    if (spell.Category == cooldownSpell.Category)
                    {
                        SpellHandler.SendClearCoolDown(ownerChar, spell.SpellId);
                    }
                }
            }

            // remove and delete
            ISpellIdCooldown       idCooldown  = m_idCooldowns.RemoveFirst(cd => cd.SpellId == cooldownSpell.Id);
            ISpellCategoryCooldown catCooldown = m_categoryCooldowns.RemoveFirst(cd => cd.CategoryId == cooldownSpell.Category);

            // enqueue task
            if (idCooldown is ActiveRecordBase || catCooldown is ActiveRecordBase)
            {
                RealmServer.IOQueue.AddMessage(new Message(() =>
                {
                    if (idCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)idCooldown).Delete();
                    }
                    if (catCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)catCooldown).Delete();
                    }
                }
                                                           ));
            }
        }