예제 #1
0
        public static bool CanAddAbility(this UnitEntityData ch, BlueprintAbility ability)
        {
            if (ability.IsSpell)
            {
                if (PartyEditor.SelectedSpellbook.TryGetValue(ch.HashKey(), out var selectedSpellbook))
                {
                    return(!selectedSpellbook.IsKnown(ability) &&
                           (ability.IsInSpellList(selectedSpellbook.Blueprint.SpellList) || Main.settings.showFromAllSpellbooks));
                }

                foreach (var spellbook in ch.Spellbooks)
                {
                    if (spellbook.IsKnown(ability))
                    {
                        return(false);
                    }
                    var spellbookBP = spellbook.Blueprint;
                    var maxLevel    = spellbookBP.MaxSpellLevel;
                    for (var level = 0; level <= maxLevel; level++)
                    {
                        var learnable = spellbookBP.SpellList.GetSpells(level);
                        if (learnable.Contains(ability))
                        {
                            //                            Logger.Log($"found spell {ability.Name} in {learnable.Count()} level {level} spells");
                            return(true);;
                        }
                    }
                }
            }
            else
            {
                if (!ch.Descriptor.Abilities.HasFact(ability))
                {
                    return(true);
                }
            }
            return(false);
        }