static void Postfix(LevelUpState state, UnitDescriptor unit) { if (IsAvailable()) { Core.Mod.AppliedMulticlassSet.Clear(); Core.Mod.UpdatedProgressions.Clear(); // get multiclass setting HashSet <string> selectedMulticlassSet = Core.Mod.LevelUpController.Unit.IsMainCharacter ? MainCharSet : (state.IsCharGen() && unit.IsCustomCompanion()) ? CharGenSet : CompanionSets.ContainsKey(unit.CharacterName) ? CompanionSets[unit.CharacterName] : null; if (selectedMulticlassSet == null || selectedMulticlassSet.Count == 0) { return; } // applying classes StateReplacer stateReplacer = new StateReplacer(state); foreach (BlueprintCharacterClass characterClass in Core.Mod.CharacterClasses) { if (characterClass != stateReplacer.SelectedClass && selectedMulticlassSet.Contains(characterClass.AssetGuid)) { stateReplacer.Replace(null, 0); if (new SelectClass(characterClass).Check(state, unit)) { Core.Debug($" - {nameof(SelectClass)}.{nameof(SelectClass.Apply)}*({characterClass}, {unit})"); unit.Progression.AddClassLevel_NotCharacterLevel(characterClass); //state.NextClassLevel = unit.Progression.GetClassLevel(characterClass); //state.SelectedClass = characterClass; characterClass.RestrictPrerequisites(unit, state); //EventBus.RaiseEvent<ILevelUpSelectClassHandler>(h => h.HandleSelectClass(unit, state)); Core.Mod.AppliedMulticlassSet.Add(characterClass); } } } stateReplacer.Restore(); // applying archetypes ForEachAppliedMulticlass(state, unit, () => { foreach (BlueprintArchetype archetype in state.SelectedClass.Archetypes) { if (selectedMulticlassSet.Contains(archetype.AssetGuid)) { AddArchetype addArchetype = new AddArchetype(state.SelectedClass, archetype); if (addArchetype.Check(state, unit)) { addArchetype.Apply(state, unit); } } } }); } }
public void CtorNew(UnitDescriptor unit, bool isPregen) { this.object_ctor(); this.mod_Selections = new List <FeatureSelectionState>(); this.mod_SpellSelections = new List <SpellSelectionData>(); this.AlignmentRestriction = new AlignmentRestriction(); this.StatsDistribution = new StatsDistribution(); this.mod_m_Unit = unit; this.mod_NextLevel = unit.Progression.CharacterLevel + 1; if (this.mod_NextLevel == 1) { this.mod_IsCharGen = true; if (!isPregen) { int pointCount; if (unit.IsCustomCompanion()) { pointCount = KingmakerPatchSettings.PointBuy.Enabled ? KingmakerPatchSettings.PointBuy.CompanionAttributePoints : 20; } else { pointCount = KingmakerPatchSettings.PointBuy.Enabled ? KingmakerPatchSettings.PointBuy.PlayerAttributePoints : 25; } this.StatsDistribution.Start(pointCount); } this.CanSelectPortrait = !isPregen; this.CanSelectRace = true; this.CanSelectGender = !isPregen; this.CanSelectAlignment = true; this.CanSelectName = true; this.CanSelectVoice = true; } else { this.mod_IsCharGen = false; } if (this.mod_NextLevel % 4 == 0) { this.AttributePoints = 1; } }