private void PerformSpellSelections(LevelUpController controller, HashSet <int> spellHistory) { for (int i = 0; i < instance.SelectSpells.Length; i++) { BlueprintAbility spell = instance.SelectSpells[i]; if (!spellHistory.Contains(i)) { foreach (SpellSelectionData spellSelectionData in controller.State.SpellSelections) { if (spellSelectionData.HasEmpty()) { int level = spellSelectionData.SpellList.GetLevel(spell); if (level >= 0) { SpellSelectionData.SpellSelectionState spellSelectionState = spellSelectionData.LevelCount[level]; BlueprintAbility[] array = ((spellSelectionState != null) ? spellSelectionState.SpellSelections : null) ?? ((spellSelectionData.ExtraMaxLevel < level) ? null : spellSelectionData.ExtraSelected); if (array != null) { int slotIndex = 0; for (int j = 0; j < array.Length; j++) { if (array[j] == null) { slotIndex = j; break; } } if (controller.SelectSpell(spellSelectionData.Spellbook, spellSelectionData.SpellList, level, spell, slotIndex)) { spellHistory.Add(i); break; } } } } } } } }