コード例 #1
0
        static public void addClassToFeat(BlueprintCharacterClass class_to_add, BlueprintArchetype[] archetypes_to_add, DomainSpellsType spells_type, BlueprintFeatureBase feat)
        {
            foreach (var c in feat.ComponentsArray.ToArray())
            {
                if (c is IncreaseSpellDamageByClassLevel)
                {
                    var c_typed = c as IncreaseSpellDamageByClassLevel;
                    c_typed.AdditionalClasses = c_typed.AdditionalClasses.AddToArray(class_to_add);
                    c_typed.Archetypes        = c_typed.Archetypes.AddToArray(archetypes_to_add);
                }
                if (c is AddFeatureOnApply)
                {
                    var c_typed = c as AddFeatureOnApply;
                    addClassToFact(class_to_add, archetypes_to_add, spells_type, c_typed.Feature);
                }
                else if (c is AddFeatureOnClassLevel)
                {
                    var c_typed = c as AddFeatureOnClassLevel;
                    c_typed.AdditionalClasses = c_typed.AdditionalClasses.AddToArray(class_to_add);
                    c_typed.Archetypes        = c_typed.Archetypes.AddToArray(archetypes_to_add);
                    addClassToFact(class_to_add, archetypes_to_add, spells_type, c_typed.Feature as BlueprintUnitFact);
                }
                else if (c is AddFeatureIfHasFact)
                {
                    var c_typed = c as AddFeatureIfHasFact;
                    addClassToFact(class_to_add, archetypes_to_add, spells_type, c_typed.Feature as BlueprintUnitFact);
                }
                else if (c is AddSpecialSpellList && spells_type == DomainSpellsType.SpecialList)
                {
                    var c_typed = c as AddSpecialSpellList;
                    if (c_typed.CharacterClass != class_to_add)
                    {
                        var c2 = Helpers.Create <Kingmaker.UnitLogic.FactLogic.AddSpecialSpellList>();
                        c2.CharacterClass = class_to_add;
                        c2.SpellList      = c_typed.SpellList;
                        feat.AddComponent(c2);
                    }
                }
                else if (c is AddOppositionSchool && spells_type == DomainSpellsType.SpecialList)
                {
                    var c_typed = c as AddOppositionSchool;
                    if (c_typed.CharacterClass != class_to_add)
                    {
                        var c2 = Helpers.Create <AddOppositionSchool>();
                        c2.CharacterClass = class_to_add;
                        c2.School         = c_typed.School;
                        feat.AddComponent(c2);
                    }
                }
                else if (c is Kingmaker.UnitLogic.FactLogic.AddFacts)
                {
                    var c_typed = (Kingmaker.UnitLogic.FactLogic.AddFacts)c;
                    foreach (var f in c_typed.Facts)
                    {
                        addClassToFact(class_to_add, archetypes_to_add, spells_type, f);
                    }
                }
                else if (c is AddAbilityResources)
                {
                    var c_typed = (Kingmaker.Designers.Mechanics.Facts.AddAbilityResources)c;
                    addClassToResource(class_to_add, archetypes_to_add, c_typed.Resource);
                }
                else if (c is FactSinglify)
                {
                    var c_typed = c as FactSinglify;
                    foreach (var f in c_typed.NewFacts)
                    {
                        addClassToFact(class_to_add, archetypes_to_add, spells_type, f);
                    }
                }
                else if (c is ReplaceCasterLevelOfAbility)
                {
                    var c_typed = c as ReplaceCasterLevelOfAbility;

                    c_typed.AdditionalClasses = c_typed.AdditionalClasses.AddToArray(class_to_add);
                    c_typed.Archetypes        = c_typed.Archetypes.AddToArray(archetypes_to_add);
                }
                else if (c is BindAbilitiesToClass)
                {
                    var c_typed = c as BindAbilitiesToClass;

                    c_typed.AdditionalClasses = c_typed.AdditionalClasses.AddToArray(class_to_add);
                    c_typed.Archetypes        = c_typed.Archetypes.AddToArray(archetypes_to_add);
                }
                else if (c is ContextRankConfig)
                {
                    addClassToContextRankConfig(class_to_add, archetypes_to_add, c as ContextRankConfig, feat.name);
                }
                else if (c is IntenseSpells)
                {
                    feat.AddComponent(Helpers.Create <NewMechanics.IntenseSpellsForClasses>(i => i.classes = new BlueprintCharacterClass[] { class_to_add, (c as IntenseSpells).Wizard }));
                    feat.RemoveComponent(c);
                }
                else if (c is NewMechanics.IntenseSpellsForClasses)
                {
                    var c_typed = c as NewMechanics.IntenseSpellsForClasses;
                    if (!c_typed.classes.Contains(class_to_add))
                    {
                        c_typed.classes = c_typed.classes.AddToArray(class_to_add);
                    }
                }
                else if (c is AddClassLevelToSummonDuration)
                {
                    feat.AddComponent(Helpers.Create <NewMechanics.AddClassesLevelToSummonDuration>(i => i.CharacterClasses = new BlueprintCharacterClass[] { class_to_add, (c as AddClassLevelToSummonDuration).CharacterClass }));
                    feat.RemoveComponent(c);
                }
                else if (c is NewMechanics.AddClassesLevelToSummonDuration)
                {
                    var c_typed = c as NewMechanics.AddClassesLevelToSummonDuration;
                    if (!c_typed.CharacterClasses.Contains(class_to_add))
                    {
                        c_typed.CharacterClasses = c_typed.CharacterClasses.AddToArray(class_to_add);
                    }
                }
                else if (c is LearnSpellList && spells_type == DomainSpellsType.NormalList)
                {
                    var spell_list = (c as LearnSpellList)?.SpellList;
                    if (spell_list == null)
                    {
                        continue;
                    }
                    if (archetypes_to_add.Empty())
                    {
                        var learn_spells_fact = Helpers.Create <Kingmaker.UnitLogic.FactLogic.LearnSpellList>();
                        learn_spells_fact.SpellList      = spell_list;
                        learn_spells_fact.CharacterClass = class_to_add;
                        feat.AddComponent(learn_spells_fact);
                    }
                    else
                    {
                        foreach (var ar_type in archetypes_to_add)
                        {
                            var learn_spells_fact = Helpers.Create <Kingmaker.UnitLogic.FactLogic.LearnSpellList>();
                            learn_spells_fact.SpellList      = spell_list;
                            learn_spells_fact.CharacterClass = class_to_add;
                            learn_spells_fact.Archetype      = ar_type;
                            feat.AddComponent(learn_spells_fact);
                        }
                    }
                }
                else if (c is AddKnownSpell && spells_type == DomainSpellsType.NormalList)
                {
                    if (archetypes_to_add.Empty())
                    {
                        var learn_spells_fact = Helpers.Create <AddKnownSpell>();
                        learn_spells_fact.Spell          = (c as AddKnownSpell).Spell;
                        learn_spells_fact.SpellLevel     = (c as AddKnownSpell).SpellLevel;
                        learn_spells_fact.CharacterClass = class_to_add;
                        feat.AddComponent(learn_spells_fact);
                    }
                    else
                    {
                        foreach (var ar_type in archetypes_to_add)
                        {
                            var learn_spells_fact = Helpers.Create <AddKnownSpell>();
                            learn_spells_fact.Spell          = (c as AddKnownSpell).Spell;
                            learn_spells_fact.SpellLevel     = (c as AddKnownSpell).SpellLevel;
                            learn_spells_fact.CharacterClass = class_to_add;
                            learn_spells_fact.Archetype      = ar_type;
                            feat.AddComponent(learn_spells_fact);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static BlueprintScriptableObject[] Tooltip()
        {
            TooltipData contextTooltipData = Game.Instance.UI.TooltipsController.ContextTooltipData;

            if (contextTooltipData == null)
            {
                return((BlueprintScriptableObject[])null);
            }
            ItemEntity itemEntity = contextTooltipData.Item;

            if (itemEntity != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)itemEntity.Blueprint
                       }
            }
            ;
            BlueprintFeatureBase feature = contextTooltipData.Feature;

            if (feature != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)feature
                       }
            }
            ;
            Ability ability = contextTooltipData.Ability;

            if (ability != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)ability.Blueprint
                       }
            }
            ;
            BlueprintFeatureSelection featureSelection = contextTooltipData.FeatureSelection;

            if (featureSelection != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)featureSelection
                       }
            }
            ;
            AbilityData abilityData = contextTooltipData.AbilityData;

            if (abilityData != (AbilityData)null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)abilityData.Blueprint
                       }
            }
            ;
            ActivatableAbility activatableAbility = contextTooltipData.ActivatableAbility;

            if (activatableAbility != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)activatableAbility.Blueprint
                       }
            }
            ;
            Buff buff = contextTooltipData.Buff;

            if (buff != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)buff.Blueprint
                       }
            }
            ;
            BlueprintAbility blueprintAbility = contextTooltipData.BlueprintAbility;

            if (blueprintAbility != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)blueprintAbility
                       }
            }
            ;
            BlueprintCookingRecipe recipe = contextTooltipData.Recipe;

            if (recipe != (UnityEngine.Object)null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)recipe
                       }
            }
            ;
            KingdomBuff kingdomBuff = contextTooltipData.KingdomBuff;

            if (kingdomBuff != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)kingdomBuff.Blueprint
                       }
            }
            ;
            UnitEntityData unit = contextTooltipData.Unit;

            if (unit != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)unit.Blueprint
                       }
            }
            ;
            BlueprintCharacterClass blueprintCharacterClass = contextTooltipData.Class;

            if (blueprintCharacterClass != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)blueprintCharacterClass
                       }
            }
            ;
            BlueprintRace race = contextTooltipData.Race;

            if (race != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)race
                       }
            }
            ;
            BlueprintSettlementBuilding settlementBuildingBp = contextTooltipData.SettlementBuildingBp;

            if (settlementBuildingBp != null)
            {
                return new BlueprintScriptableObject[1]
                       {
                           (BlueprintScriptableObject)settlementBuildingBp
                       }
            }
            ;
            SettlementBuilding settlementBuilding = contextTooltipData.SettlementBuilding;

            if (settlementBuilding == null)
            {
                return((BlueprintScriptableObject[])contextTooltipData.TutorialPage ?? (BlueprintScriptableObject[])null);
            }
            return(new BlueprintScriptableObject[1]
            {
                (BlueprintScriptableObject)settlementBuilding.Blueprint
            });
        }
    }
}
コード例 #3
0
 internal static bool IsArcanaOrClassSkill(BlueprintFeatureBase f) => f.name.EndsWith("Arcana") || f.name.Contains("ClassSkill");
コード例 #4
0
        static bool canCombineArchetypes(BlueprintArchetype archetype1, BlueprintArchetype archetype2)
        {
            //Main.logger.Log($"Checking {archetype1.Name} and {archetype2.Name} stacking");

            if (archetype1 == CallOfTheWild.Archetypes.Seeker.archetype || archetype2 == CallOfTheWild.Archetypes.Seeker.archetype)
            {
                //Main.logger.Log("Seeker");
                return(false);
            }
            if ((archetype1.ReplaceSpellbook != null || archetype1.RemoveSpellbook) && (archetype2.ReplaceSpellbook != null || archetype2.RemoveSpellbook))
            {
                //Main.logger.Log("Spellbook Failure");
                return(false);
            }

            if (archetype1.ReplaceClassSkills && archetype2.ReplaceClassSkills)
            {
                var parent_class_skills = archetype1.GetParentClass().ClassSkills;
                var missing_skills1     = parent_class_skills.Except(archetype1.ClassSkills);
                var missing_skills2     = parent_class_skills.Except(archetype2.ClassSkills);

                if (missing_skills1.Intersect(missing_skills2).Any())
                {
                    //both skills are removed
                    //Main.logger.Log("Skills Failure");
                    return(false);
                }
            }


            if ((archetype1.BaseAttackBonus != null) && (archetype2.BaseAttackBonus != null) && archetype1.BaseAttackBonus != archetype2.BaseAttackBonus)
            {
                //Main.logger.Log("Base Attack Bonus Failure");
                return(false);
            }

            if ((archetype1.WillSave != null) && (archetype2.WillSave != null) && archetype1.BaseAttackBonus != archetype2.WillSave)
            {
                //Main.logger.Log("Will Save Failure");
                return(false);
            }

            if ((archetype1.ReflexSave != null) && (archetype2.ReflexSave != null) && archetype1.BaseAttackBonus != archetype2.ReflexSave)
            {
                //Main.logger.Log("Reflex Save Failure");
                return(false);
            }


            if ((archetype1.FortitudeSave != null) && (archetype2.FortitudeSave != null) && archetype1.BaseAttackBonus != archetype2.FortitudeSave)
            {
                //Main.logger.Log("Fort Save Failure");
                return(false);
            }

            if ((archetype1.IsDivineCaster && archetype1.IsArcaneCaster) || (archetype1.IsArcaneCaster && archetype1.IsDivineCaster))
            {
                //Main.logger.Log("Caster type Failure");
                return(false);
            }

            foreach (LevelEntry removeFeature in archetype1.RemoveFeatures)
            {
                var level_entry2 = archetype2.RemoveFeatures.FirstOrDefault((le => le.Level == removeFeature.Level)) ?? new LevelEntry();
                foreach (BlueprintFeatureBase feature1 in removeFeature.Features)
                {
                    BlueprintFeatureBase feature = feature1;
                    if (removeFeature.Features.Count((f => f == feature)) != 0 && level_entry2.Features.Count((f => f == feature)) != 0)
                    {
                        //Main.logger.Log($"{feature.name} Failure");
                        return(false);
                    }
                }
            }
            //Main.logger.Log("Passed");
            return(true);
        }