static private IEnumerable <FeatureUIData> ExtractItemsFromSpellbooks2(BlueprintParametrizedFeature feature, UnitDescriptor unit)
        {
            foreach (Spellbook spellbook in unit.Spellbooks)
            {
                if (spellbook.Blueprint.GetComponent <SpellbookMechanics.GetKnownSpellsFromMemorizationSpellbook>() != null)
                {
                    continue;
                }
                foreach (var spell in spellbook.GetAllKnownSpells().Select(s => s.Blueprint).Distinct().ToArray())
                {
                    if (unit.GetFeature(feature.Prerequisite, spell.School) != null)
                    {
                        yield return(new FeatureUIData(feature, spell, spell.Name, spell.Description, spell.Icon, spell.name));
                    }
                }

                /*foreach (SpellLevelList spellLevel in spellbook.Blueprint.SpellList.SpellsByLevel)
                 * {
                 *  if (spellLevel.SpellLevel <= spellbook.MaxSpellLevel)
                 *  {
                 *      foreach (BlueprintAbility spell in spellLevel.SpellsFiltered)
                 *      {
                 *          if (unit.GetFeature(feature.Prerequisite, spell.School) != null)
                 *          {
                 *              yield return new FeatureUIData(feature, spell, spell.Name, spell.Description, spell.Icon, spell.name);
                 *          }
                 *      }
                 *  }
                 * }*/
            }
            yield break;
        }
        public static void GiveFeat(UnitDescriptor unit, string Guid, WeaponCategory category)
        {
            BlueprintFeature feature = Kingmaker.Cheats.Utilities.GetBlueprintByGuid <BlueprintFeature>(Guid);
            FeatureParam     param   = new FeatureParam(new WeaponCategory?(category));

            if (unit.GetFeature(feature, param) == null)
            {
                unit.AddFact(Kingmaker.Cheats.Utilities.GetBlueprintByGuid <BlueprintFeature>(Guid), null, param);
            }
        }
Example #3
0
 static void Postfix(BlueprintParametrizedFeature __instance, UnitDescriptor unit, ref IEnumerable <FeatureUIData> __result)
 {
     try
     {
         var self = __instance;
         List <FeatureUIData> result = null;
         // Add spells that have been granted by a progression (e.g. bloodline, oracle mystery/curse, etc).
         foreach (var feature in unit.Progression.Features)
         {
             var progression = feature.Blueprint as BlueprintProgression;
             if (progression == null)
             {
                 continue;
             }
             var data = unit.Progression.SureProgressionData(progression);
             foreach (var entry in data.LevelEntries.Where(e => e.Level <= data.Level))
             {
                 foreach (var addSpell in entry.Features.SelectMany(f => f.GetComponents <AddKnownSpell>()))
                 {
                     var spell = addSpell.Spell;
                     if (unit.GetFeature(self.Prerequisite, spell.School) == null)
                     {
                         continue;                                                           // skip spells of wrong school
                     }
                     if (result == null)
                     {
                         result = __result.ToList();
                     }
                     result.Add(new FeatureUIData(self, spell, spell.Name, spell.Description, spell.Icon, spell.name));
                 }
             }
         }
         if (result != null)
         {
             __result = result;
         }
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
 }