コード例 #1
0
            public static bool Prefix(LevelUpState state, UnitDescriptor unit)
            {
                if (!settings.toggleMulticlass)
                {
                    return(false);
                }
                if ((UnityEngine.Object)state.SelectedClass == (UnityEngine.Object)null)
                {
                    return(true);
                }
                SkipLevelsForSpellProgression component1 = state.SelectedClass.GetComponent <SkipLevelsForSpellProgression>();

                if ((UnityEngine.Object)component1 != (UnityEngine.Object)null && ((IEnumerable <int>)component1.Levels).Contains <int>(state.NextClassLevel))
                {
                    return(true);
                }
                ClassData classData = unit.Progression.GetClassData(state.SelectedClass);

                if (classData == null || !((UnityEngine.Object)classData.Spellbook != (UnityEngine.Object)null))
                {
                    return(true);
                }
                Spellbook spellbook1 = unit.DemandSpellbook(classData.Spellbook);

                if ((bool)(UnityEngine.Object)state.SelectedClass.Spellbook && (UnityEngine.Object)state.SelectedClass.Spellbook != (UnityEngine.Object)classData.Spellbook)
                {
                    Spellbook spellbook2 = unit.Spellbooks.FirstOrDefault <Spellbook>((Func <Spellbook, bool>)(s => (UnityEngine.Object)s.Blueprint == (UnityEngine.Object)state.SelectedClass.Spellbook));
                    if (spellbook2 != null)
                    {
                        foreach (AbilityData allKnownSpell in spellbook2.GetAllKnownSpells())
                        {
                            spellbook1.AddKnown(allKnownSpell.SpellLevel, allKnownSpell.Blueprint);
                        }
                        unit.DeleteSpellbook(state.SelectedClass.Spellbook);
                    }
                }
                int casterLevelBefore = spellbook1.CasterLevel;

                spellbook1.AddLevelFromClass(classData.CharacterClass);
                int casterLevelAfter = spellbook1.CasterLevel;

                if (casterLevelBefore == casterLevelAfter)
                {
                    return(true);                                       // Mod line
                }
                SpellSelectionData spellSelectionData = state.DemandSpellSelection(spellbook1.Blueprint, spellbook1.Blueprint.SpellList);

                if ((UnityEngine.Object)spellbook1.Blueprint.SpellsKnown != (UnityEngine.Object)null)
                {
                    for (int index = 0; index <= 10; ++index)
                    {
                        BlueprintSpellsTable spellsKnown = spellbook1.Blueprint.SpellsKnown;
                        int?count = spellsKnown.GetCount(casterLevelBefore, index);
                        int num1  = count ?? 0;
                        count = spellsKnown.GetCount(casterLevelAfter, index);
                        int num2 = count ?? 0;
                        spellSelectionData.SetLevelSpells(index, Math.Max(0, num2 - num1));
                    }
                }
                int maxSpellLevel = spellbook1.MaxSpellLevel;

                if (spellbook1.Blueprint.SpellsPerLevel > 0)
                {
                    if (casterLevelBefore == 0)
                    {
                        spellSelectionData.SetExtraSpells(0, maxSpellLevel);
                        spellSelectionData.ExtraByStat = true;
                        spellSelectionData.UpdateMaxLevelSpells(unit);
                    }
                    else
                    {
                        spellSelectionData.SetExtraSpells(spellbook1.Blueprint.SpellsPerLevel, maxSpellLevel);
                    }
                }
                foreach (AddCustomSpells component2 in spellbook1.Blueprint.GetComponents <AddCustomSpells>())
                {
                    ApplySpellbook.TryApplyCustomSpells(spellbook1, component2, state, unit);
                }
                return(true);
            }