static bool Prefix(CharacterBuildController __instance, BlueprintRace race) { try { if (race == null || Main.settings?.RelaxAncientLorekeeper == true) { return(true); } var self = __instance; var levelUp = self.LevelUpController; var @class = levelUp.State.SelectedClass; if (@class == null) { return(true); } if (@class.Archetypes.Any(a => a.GetComponents <Prerequisite>() != null)) { self.SetArchetype(null); } } catch (Exception e) { Log.Error(e); } return(true); }
/* * Uses the CharacterBuildController to edit level plans * Refer MainMenu.StartChargen which sets up the state and then calls CharacterBuildController.HandleLevelUpStart * */ public static void EditLevelPlan(LevelPlanHolder levelPlanHolder, int level) { var unit = levelPlanHolder.CreateUnit(level); if (Main.settings.ShowDollRoom) { ShowDollRoom(unit); } CharacterBuildController characterBuildController = Game.Instance.UI.CharacterBuildController; var mode = level == 1 ? LevelUpState.CharBuildMode.CharGen : LevelUpState.CharBuildMode.LevelUp; CurrentLevelUpController = LevelUpController.Start( unit: unit.Descriptor, instantCommit: false, unitJson: null, onSuccess: null, mode: mode); CurrentLevelUpController.SelectPortrait(Game.Instance.BlueprintRoot.CharGen.Portraits[0]); CurrentLevelUpController.SelectGender(Gender.Male); CurrentLevelUpController.SelectRace(Game.Instance.BlueprintRoot.Progression.CharacterRaces[0]); CurrentLevelUpController.SelectAlignment(Kingmaker.Enums.Alignment.TrueNeutral); CurrentLevelUpController.SelectVoice(Game.Instance.BlueprintRoot.CharGen.MaleVoices[0]); CurrentLevelUpController.SelectName("LevelPlan"); Traverse.Create(characterBuildController).Property <LevelUpController>("LevelUpController").Value = CurrentLevelUpController; Traverse.Create(characterBuildController).Field("Mode").SetValue(CurrentLevelUpController.State.Mode); Traverse.Create(characterBuildController).Field("Unit").SetValue(unit.Descriptor); characterBuildController.Show(true); }
public static bool Prefix(CharacterBuildController __instance, BlueprintAbility spell, int spellLevel, bool multilevel) { if (!settings.toggleMulticlass) { return(false); } BlueprintSpellbook spellbook = __instance.Spells.CurrentSpellSelectionData.Spellbook; BlueprintSpellList spellList = __instance.Spells.CurrentSpellSelectionData.SpellList; int spellsCollectionIndex = __instance.Spells.CurrentSpellsCollectionIndex; if (multilevel) { __instance.LevelUpController.UnselectSpell(spellbook, spellList, spellsCollectionIndex, spellLevel); } else { __instance.LevelUpController.UnselectSpell(spellbook, spellList, spellsCollectionIndex, -1); } if (!__instance.LevelUpController.SelectSpell(spellbook, spellList, spellLevel, spell, spellsCollectionIndex)) { return(true); } // Begin Mod Lines BlueprintCharacterClass selectedClass = __instance.LevelUpController.State.SelectedClass; __instance.LevelUpController.State.SelectedClass = spellbook.CharacterClass; // End Mod Lines __instance.DefineAvailibleData(); __instance.Spells.IsDirty = true; __instance.Total.IsDirty = true; __instance.Spells.SetSpellbooklevel(spellLevel); __instance.SetupUI(); __instance.LevelUpController.State.SelectedClass = selectedClass; // Mod Line return(true); }
/* * Refer MainMenu.StartChargen which also calls CharacterBuildController.HandleLevelUpStart * */ internal static void TestLevelup() { var unit = CreateUnit(); var descriptorJson = UnitSerialization.Serialize(unit.Descriptor);; if (Main.settings.ShowDollRoom) { ShowDollRoom(unit); } CharacterBuildController characterBuildController = Game.Instance.UI.CharacterBuildController; LevelPlanManager.CurrentLevelUpController = LevelUpController.Start( unit: unit.Descriptor, instantCommit: false, unitJson: descriptorJson, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen); /*CurrentLevelUpController.SelectPortrait(Game.Instance.BlueprintRoot.CharGen.Portraits[0]); * CurrentLevelUpController.SelectGender(Gender.Male); * CurrentLevelUpController.SelectRace(Game.Instance.BlueprintRoot.Progression.CharacterRaces[0]); * CurrentLevelUpController.SelectAlignment(Kingmaker.Enums.Alignment.TrueNeutral); * CurrentLevelUpController.SelectVoice(Game.Instance.BlueprintRoot.CharGen.MaleVoices[0]); * CurrentLevelUpController.SelectName("LevelPlan");*/ Traverse.Create(characterBuildController).Property <LevelUpController>("LevelUpController").Value = LevelPlanManager.CurrentLevelUpController; characterBuildController.Unit = unit.Descriptor; characterBuildController.Show(true); }
static bool Prefix(CharacterBuildController __instance) { try { if (!Main.enabled) { return(true); } if (Main.settings.DisableRemovePlanOnChange) { Traverse.Create(__instance.LevelUpController).Field("m_PlanChanged").SetValue(false); } if (__instance.LevelUpController != CurrentLevelUpController) { Main.Log("CharacterBuildController.Commit, not creating level up plan"); return(true); } /* * as __instance.Unit does not have a proper view attached to it, * we prevent the method from running as it will fail on * __instance.Unit.View.UpdateClassEquipment(); */ var planResult = CurrentLevelUpController.GetPlan(); CurrentLevelPlan.AddLevelPlan(planResult); CurrentLevelUpController = null; //LevelUpController.Commit __instance.LevelUpController.Preview.Unit.Dispose(); LevelUpPreviewThread.Stop(); //CharacterBuildController.Commit Traverse.Create(__instance).Property <LevelUpController>("LevelUpController").Value = null; foreach (CharBPhase charBPhase in __instance.CharacterBuildPhaseStates) { charBPhase.Dispose(); } if (Game.Instance.UI.ServiceWindow != null) { Game.Instance.UI.ServiceWindow.WindowTabs.Show(false); } Traverse.Create(__instance).Field("m_IsChargen").SetValue(false); __instance.Show(false); __instance.Unit = null; Main.Log("LevelUpController.Commit, creating level up plan"); } catch (Exception ex) { Main.Error(ex); return(false); } return(false); }
static void CreateLevelPlan() { var unit = Game.Instance.Player.MainCharacter.Value.Descriptor; var unitJson = UnitSerialization.Serialize(unit); CharacterBuildController characterBuildController = Game.Instance.UI.CharacterBuildController; CurrentLevelUpController = LevelUpController.Start( unit: unit, instantCommit: false, unitJson: unitJson, onSuccess: null, mode: LevelUpState.CharBuildMode.PreGen); Traverse.Create(characterBuildController).Property <LevelUpController>("LevelUpController").Value = CurrentLevelUpController; Traverse.Create(characterBuildController).Field("Mode").SetValue(CurrentLevelUpController.State.Mode); Traverse.Create(characterBuildController).Field("Unit").SetValue(unit); characterBuildController.Show(true); }
static bool Prefix(CharacterBuildController __instance) { return(true); }
static void Postfix(CharacterBuildController __instance) { CurrentLevelUpController = null; }