private void PerformSelections(LevelUpController controller, Dictionary <SelectionEntry, HashSet <int> > selectionsHistory, LevelUpActionPriority?maxPriority = null) { SelectionEntry[] selections = instance.Selections; int i = 0; while (i < selections.Length) { SelectionEntry selectionEntry = selections[i]; if (maxPriority == null) { goto IL_66; } if (selectionEntry.IsParametrizedFeature) { if (SelectFeature.CalculatePriority(selectionEntry.ParametrizedFeature) <= maxPriority.Value) { goto IL_66; } } else if (SelectFeature.CalculatePriority(selectionEntry.Selection) <= maxPriority.Value) { goto IL_66; } IL_253: i++; continue; IL_66: HashSet <int> hashSet; if (!selectionsHistory.TryGetValue(selectionEntry, out hashSet)) { hashSet = new HashSet <int>(); selectionsHistory[selectionEntry] = hashSet; } if (selectionEntry.IsParametrizedFeature) { FeatureSelectionState featureSelectionState = controller.State.FindSelection(selectionEntry.ParametrizedFeature, false); if (featureSelectionState != null) { FeatureUIData item; switch (selectionEntry.ParametrizedFeature.ParameterType) { case FeatureParameterType.Custom: case FeatureParameterType.SpellSpecialization: item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamObject, string.Empty, string.Empty, null, selectionEntry.ParamObject.ToString()); break; case FeatureParameterType.WeaponCategory: item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamWeaponCategory, string.Empty, string.Empty, null, selectionEntry.ParamWeaponCategory.ToString()); break; case FeatureParameterType.SpellSchool: item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamSpellSchool, string.Empty, string.Empty, null, selectionEntry.ParamSpellSchool.ToString()); break; case FeatureParameterType.LearnSpell: goto IL_1BD; case FeatureParameterType.Skill: item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.Stat, string.Empty, string.Empty, null, selectionEntry.Stat.ToString()); break; default: goto IL_1BD; } controller.SelectFeature(featureSelectionState, item); goto IL_1CE; IL_1BD: throw new ArgumentOutOfRangeException(); } IL_1CE: goto IL_253; } for (int j = 0; j < selectionEntry.Features.Length; j++) { if (!hashSet.Contains(j)) { BlueprintFeature blueprintFeature = selectionEntry.Features[j]; FeatureSelectionState featureSelectionState2 = controller.State.FindSelection(selectionEntry.Selection, false); if (featureSelectionState2 != null && blueprintFeature != null && controller.SelectFeature(featureSelectionState2, blueprintFeature)) { hashSet.Add(j); } } } goto IL_253; } }