Пример #1
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(this.prerequisite1.Check(selectionState, unit, state) && this.prerequisite2.Check(selectionState, unit, state));
 }
Пример #2
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(race == unit.Progression.Race);
 }
Пример #3
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(this.base_prerequsite.Check(selectionState, unit, state) || this.alternative_prerequsite.Check(selectionState, unit, state));
 }
Пример #4
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return((unit.Get <UnitPartFullProficiency>()?.hasFullProficiency(category)).GetValueOrDefault() != not);
 }
Пример #5
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(unit.GetSpellbook(character_class) != null);
 }
Пример #6
0
        // If we're gaining a level of prestige class that skips a caster level (e.g. level 5 of Dragon Disciple),
        // see if we already took enough Prestigious Spellcaster ranks to make up for it. If so, then we should
        // gain a caster level now.
        static bool ShouldGainCasterLevelOnLevelUp(LevelUpState state, UnitDescriptor unit)
        {
            var selectedClass = state.SelectedClass;

            if (prestigiousSpellcaster == null || !prestigiousSpellcasterClasses.Contains(selectedClass))
            {
                return(false);
            }

            // See if we have the matching prestigious spellcaster feat.

            var fact = GetSpellcasterFact(unit, selectedClass);

            if (fact == null)
            {
                return(false);
            }

            // If we already took the Prestigious Spellcaster feat for this skipped caster level, we can gain the level now.
            var spellSkipLevels = selectedClass.GetComponent <SkipLevelsForSpellProgression>().Levels;
            int skipIndex       = Array.IndexOf(spellSkipLevels, state.NextClassLevel);

            Log.Write($" checking for skipped spell level, found: {skipIndex}, from skips: " + String.Join(" ", spellSkipLevels));
            if (skipIndex >= 0)
            {
                var rank = fact.GetRank();
                Log.Write($" Prestigious Spellcaster {fact.Blueprint.name} rank {rank}");
                if (rank > skipIndex)
                {
                    // We already took prestigious spellcaster for this level, so we need to gain a caster level.
                    return(true);
                }
            }
            return(false);
        }
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(unit.Progression.GetClassLevel(this.CharacterClass) < 1);
 }
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(unit.Ensure <UnitPartSelfEvolution>().hasEvolution(evolution) != not);;
 }
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return(unit.Ensure <UnitPartSelfEvolution>().getNumEvolutionPoints() >= amount || unit.Progression.Features.HasFact((BlueprintFact)this.feature));
 }
Пример #10
0
 public void HandleSelectClass(UnitDescriptor unit, LevelUpState state)
 {
     if (Owner == unit)
     {
         // handle subsequent level ups after level 1
         Apply(state);
     }
 }
Пример #11
0
 static void Postfix(LevelUpState __instance, UnitDescriptor unit, LevelUpState.CharBuildMode mode)
 {
     if (IsAvailable() && Core.Mod.IsLevelLocked)
     {
         //__instance.SetFieldValue(nameof(LevelUpState.NextLevel), unit.Progression.CharacterLevel);
         __instance.AttributePoints = 0;
     }
 }
Пример #12
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);
                                }
                            }
                        }
                    });
                }
            }
Пример #13
0
 static bool Prefix(ApplyClassMechanics __instance, LevelUpState state, UnitDescriptor unit)
 {
     if (IsAvailable() && Core.Mod.IsLevelLocked)
     {
         __instance.Apply_NoStatsAndHitPoints(state, unit);
         return(false);
     }
     return(true);
 }
 static void Prefix(LevelUpState state, UnitDescriptor unit, BlueprintProgression progression)
 {
     if (IsAvailable())
     {
         ProgressionData progressionData = unit.Progression.SureProgressionData(progression);
         int             nextLevel       = progressionData.Blueprint.CalcLevel(unit);
         Core.Debug($" - {nameof(LevelUpHelper)}.{nameof(LevelUpHelper.UpdateProgression)}({state.SelectedClass}[{state.NextClassLevel}], {unit}, {progression}) - NextLevel: {nextLevel}");
     }
 }
Пример #15
0
        public static void SetSpellbook(this CharBPhaseSpells instance, BlueprintCharacterClass characterClass)
        {
            LevelUpState            state         = Game.Instance.LevelUpController.State;
            BlueprintCharacterClass selectedClass = state.SelectedClass;

            state.SelectedClass = characterClass;
            ReflectionCache.GetMethod <CharBPhaseSpells, Action <CharBPhaseSpells> >("SetupSpellBookView")(instance);
            state.SelectedClass = selectedClass;
        }
Пример #16
0
        static bool Prefix(LevelUpState state, ClassData classData, UnitDescriptor unit)
        {
            int hitDie = (int)classData.CharacterClass.HitDie;
            BlueprintCharacterClass characterClass = classData.CharacterClass;
            int nextLevel = state.NextLevel;
            int num2      = !BlueprintRoot.Instance.Progression.CharacterClasses.Contains(characterClass) || !unit.IsPlayerFaction ? hitDie / 2 + nextLevel % 2 + 1 : (nextLevel > 1 ? hitDie / 2 + nextLevel % 2 : hitDie);

            unit.Stats.HitPoints.BaseValue += num2;
            return(false);
        }
Пример #17
0
        protected override void Apply(LevelUpState state)
        {
            Log.Write($"{GetType().Name}: trying to unselect");
            var selection = state.Selections.FirstOrDefault(s => s.SelectedItem?.Feature == Fact.Blueprint);

            if (selection != null)
            {
                Log.Write($"Unselecting selection {selection.Index}");
                Game.Instance.UI.CharacterBuildController.LevelUpController.UnselectFeature(selection);
            }
        }
Пример #18
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     if (selectionState != (FeatureSelectionState)null && selectionState.IsSelectedInChildren((IFeatureSelectionItem)this.base_feature))
     {
         return(false);
     }
     return(unit.Progression.Features.Enumerable.Where(p => p.Blueprint == this.base_feature).Any(this.CheckFeature));
 }
Пример #19
0
        public static bool IsCharGen(this LevelUpState state)
        {
            var companionNames = Game.Instance?.Player?.AllCharacters.Where(c => !c.IsMainCharacter).Select(c => c.CharacterName).ToList();
            var isCompanion    = companionNames?.Contains(state.Unit.CharacterName) ?? false;

            if (isCompanion)
            {
                return(false);
            }
            return(state.Mode == LevelUpState.CharBuildMode.CharGen || state.Unit.CharacterName == "Player Character");
        }
Пример #20
0
        static bool Prefix(LevelUpState state, ClassData classData, UnitDescriptor unit)
        {
            unit.Stats.GetStat(StatType.BaseAttackBonus).BaseValue += calculateExtraBab(classData, unit);
            unit.Stats.GetStat(StatType.SaveFortitude).BaseValue   += calculateExtraSave(classData, unit, state.NextClassLevel,
                                                                                         c => c.FortitudeSave);
            unit.Stats.GetStat(StatType.SaveReflex).BaseValue += calculateExtraSave(classData, unit, state.NextClassLevel,
                                                                                    c => c.ReflexSave);
            unit.Stats.GetStat(StatType.SaveWill).BaseValue += calculateExtraSave(classData, unit, state.NextClassLevel,
                                                                                  c => c.WillSave);

            return(false);
        }
        public void HandleSelectClass(UnitDescriptor unit, LevelUpState state)
        {
            if (applied)
            {
                return;
            }

            if (Owner == unit)
            {
                Apply(state);
                applied = true;
            }
        }
Пример #22
0
 private static void Postfix(ApplyClassMechanics __instance, LevelUpState state, UnitDescriptor unit)
 {
     try {
         if (state.NextLevel == 1)
         {
             foreach (Action <LevelUpState, UnitDescriptor> action in onChargenApply)
             {
                 action(state, unit);
             }
         }
     } catch (Exception e) {
         Log.Error(e);
     }
 }
Пример #23
0
        protected override void Apply(LevelUpState state)
        {
            if (CharacterClass != state.SelectedClass)
            {
                return;
            }

            var spellbook         = Owner.Progression.GetClassData(CharacterClass).Spellbook;
            var spellSelection    = state.DemandSpellSelection(spellbook, spellbook.SpellList);
            int existingNewSpells = spellSelection.LevelCount[SpellLevel]?.SpellSelections.Length ?? 0;

            Log.Write($"Adding spell selection to level {SpellLevel}");
            spellSelection.SetLevelSpells(SpellLevel, 1 + existingNewSpells);
        }
Пример #24
0
            static void Postfix(ApplyClassMechanics __instance, LevelUpState state, UnitDescriptor unit)
            {
                if (IsAvailable())
                {
                    if (state.SelectedClass != null)
                    {
                        ForEachAppliedMulticlass(state, unit, () => {
                            Logger.ModLoggerDebug($" - {nameof(ApplyClassMechanics)}.{nameof(ApplyClassMechanics.Apply)}*({state.SelectedClass}[{state.NextClassLevel}], {unit})");

                            __instance.Apply_NoStatsAndHitPoints(state, unit);
                        });
                    }
                }
            }
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     foreach (var p in prerequisites)
     {
         if (!p.Check(selectionState, unit, state))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #26
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     foreach (ClassData classData in unit.Progression.Classes)
     {
         BlueprintSpellbook spellbook = classData.Spellbook;
         if (spellbook != null)
         {
             return(true);
         }
     }
     return(false);
 }
 static void Prefix(SelectFeature __instance, LevelUpState state, UnitDescriptor unit)
 {
     if (IsAvailable())
     {
         BlueprintCharacterClass sourceClass = (GetMethodDel <SelectFeature, Func <SelectFeature, LevelUpState, FeatureSelectionState> >
                                                    ("GetSelectionState")(__instance, state)?.Source as BlueprintProgression)?.GetSourceClass(unit);
         if (sourceClass == null)
         {
             Core.Debug($" - {nameof(SelectFeature)}.{nameof(SelectFeature.Apply)}({state.SelectedClass}[{state.NextClassLevel}], {unit}) - {__instance.Selection}, {__instance.Item}");
         }
         else
         {
             Core.Debug($" - {nameof(SelectFeature)}.{nameof(SelectFeature.Apply)}({sourceClass}[{unit.Progression.GetClassLevel(sourceClass)}], {unit}) - {__instance.Selection}, {__instance.Item}");
         }
     }
 }
Пример #28
0
 bool IFeatureSelection.CanSelect(UnitDescriptor unit, LevelUpState state, FeatureSelectionState selectionState, IFeatureSelectionItem item)
 {
     if (!item.Param.HasValue)
     {
         return(false);
     }
     if (HasNoSuchFeature)
     {
         var feat = item.Param.Value.Blueprint as BlueprintFeature;
         if (feat != null && unit.HasFact(feat))
         {
             return(false);
         }
     }
     return(CanSelect(unit, item.Param.Value));
 }
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     foreach (ClassData classData in unit.Progression.Classes)
     {
         BlueprintSpellbook spellbook = classData.Spellbook;
         if (spellbook != null &&
             (!this.OnlySpontaneous || spellbook.Spontaneous) &&
             spellbook.GetComponent <PsychicSpellbook>() != null &&
             unit.DemandSpellbook(classData.CharacterClass).MaxSpellLevel >= this.RequiredSpellLevel)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #30
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     foreach (var f in Features)
     {
         if (unit.Logic.HasFact(f))
         {
             return(false);
         }
         if (unit.Progression.Features.HasFact(f))
         {
             return(false);
         }
     }
     return(true);
 }