public bool CanCastSpell(SpellLevelRecord spell, short targetedCell) { SpellHistoryEntry spellHistoryEntry = this.m_underlyingStack.LastOrDefault((SpellHistoryEntry entry) => entry.Spell.Id == spell.Id); bool result; if (spellHistoryEntry == null && (long)this.CurrentRound < (long)((ulong)spell.InitialCooldown)) { result = false; } else if (spellHistoryEntry == null) { result = true; } else if (spellHistoryEntry.IsGlobalCooldownActive(this.CurrentRound)) { result = false; } else { SpellHistoryEntry[] array = ( from entry in this.m_underlyingStack where entry.Spell.Id == spell.Id && entry.CastRound == this.CurrentRound select entry).ToArray <SpellHistoryEntry>(); if (array.Length == 0) { result = true; } else if (spell.MaxCastPerTurn > 0u && (long)array.Length >= (long)((ulong)spell.MaxCastPerTurn)) { result = false; } else { Fighter target = this.Owner.Fight.GetFighter(targetedCell); if (target == null) { result = true; } else { int num = array.Count((SpellHistoryEntry entry) => entry.Target != null && entry.Target.Id == target.Id); result = (spell.MaxCastPerTarget <= 0u || (long)num < (long)((ulong)spell.MaxCastPerTarget)); } } } return(result); }
public void RegisterCastedSpell(SpellHistoryEntry entry) { this.m_underlyingStack.Push(entry); }