コード例 #1
0
        internal static void TestLevelUp()
        {
            var            defaultClass   = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"); //Alchemist
            var            defaultBuild   = defaultClass.DefaultBuild;
            var            addClassLevels = defaultBuild.GetComponent <AddClassLevels>();
            var            targetPoints   = Main.settings.DefaultPointBuy25 ? 25 : 20;
            var            stats          = defaultBuild.GetComponents <StatsDistributionPreset>().FirstOrDefault(sd => sd.TargetPoints == targetPoints);
            UnitEntityData unitData       = Main.settings.DefaultPointBuy25 ?
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.DefaultPlayerCharacter) :
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.CustomCompanion);
            var  unit              = unitData.Descriptor;
            bool success           = false;
            var  levelUpController = TestLevelUpController.Start(unit: unit, instantCommit: true, unitJson: null, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen);

            success = levelUpController.SelectPortrait(ResourcesLibrary.GetBlueprints <BlueprintPortrait>().First());
            if (!success)
            {
                Main.Log("Error selecting portrait");
            }
            success = levelUpController.SelectGender(Gender.Male);
            if (!success)
            {
                Main.Log("Error selecting gender");
            }
            success = levelUpController.SelectRace(ResourcesLibrary.TryGetBlueprint <BlueprintRace>("0a5d473ead98b0646b94495af250fdc4"));
            if (!success)
            {
                Main.Log("Error selecting race");
            }
            success = levelUpController.SelectRaceStat(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting race stat");
            }
            success = levelUpController.SelectClass(ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"));
            if (!success)
            {
                Main.Log("Error selecting class");
            }
            levelUpController.ApplyClassMechanics();
            levelUpController.ApplySpellbook();
            success  = levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting stats");
            }
            success  = levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillUseMagicDevice);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeWorld);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillPerception);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillThievery);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillStealth);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillLoreNature);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeArcana);
            if (!success)
            {
                Main.Log("Error selecting skills");
            }
            var selection         = ResourcesLibrary.TryGetBlueprint <BlueprintFeatureSelection>("247a4068296e8be42890143f451b4b45"); //BasicFeatSelection
            var featurePointBlack = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("0da0c194d6e1d43419eb8d990b28e0ab");          //PointBlankFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 0, 0), featurePointBlack);
            if (!success)
            {
                Main.Log("Error selecting point blank");
            }
            var featurePreciseShot = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("8f3d1e6b4be006f4d896081f2f889665"); //PreciseShotFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 1, 0), featurePreciseShot);
            if (!success)
            {
                Main.Log("Error selecting precise shot");
            }
            var spells = new List <string>()
            {
                "4f8181e7a7f1d904fbaea64220e83379",
                "5590652e1c2225c4ca30c4a699ab3649",
                "4e0e9aba6447d514f88eff1464cc4763",
                "ef768022b0785eb43a18969903c537c4",
                "2c38da66e5a599347ac95b3294acbe00",
                "9d504f8dff6e93b4ab6afc938ed6a23d",
                "24afb2c948c731440a3aaf5411904c89",
                "c60969e7f264e6d4b84a1499fdcf9039",
            };
            var alchemistSpellBook = ResourcesLibrary.TryGetBlueprint <BlueprintSpellbook>("fcbf2a5447624528a3f333bced844d06");
            var alchemistSpellList = ResourcesLibrary.TryGetBlueprint <BlueprintSpellList>("f60d0cd93edc65c42ad31e34a905fb2f");

            success = true;
            for (var i = 0; i < spells.Count; i++)
            {
                var spell = ResourcesLibrary.TryGetBlueprint <BlueprintAbility>(spells[i]);
                success &= levelUpController.SelectSpell(alchemistSpellBook, alchemistSpellList, 1, spell, i);
            }
            if (!success)
            {
                Main.Log("Error selecting spells");
            }
            success = levelUpController.SelectVoice(ResourcesLibrary.TryGetBlueprint <BlueprintUnitAsksList>("e7b22776ba8e2b84eaaff98e439639a7"));
            if (!success)
            {
                Main.Log("Error selecting voice");
            }
            success = levelUpController.SelectName("ABC");
            if (!success)
            {
                Main.Log("Error selecting name");
            }
            var token = UnitSerialization.Serialize(unit);

            File.WriteAllText("TestUnit.json", token.ToString());
            LogUnit("TestUnit.txt", unit);
        }