예제 #1
0
            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);
                                }
                            }
                        }
                    });
                }
            }
예제 #2
0
 static void Postfix(LevelUpController __instance)
 {
     if (IsAvailable())
     {
         if (__instance.State.IsCharGen() && __instance.Unit.IsCustomCompanion() && CharGenSet.Count > 0)
         {
             CompanionSets.Add(__instance.Unit.CharacterName, new HashSet <string>(CharGenSet));
             CharGenSet.Clear();
         }
     }
 }