using System.Linq; namespace Harmony.XUiC_QuestTurnInRewardsWindowPatches { [HarmonyPatch(typeof(XUiC_QuestTurnInRewardsWindow))] [HarmonyPatch("SetupOptions")] public class SetupOptionsPatch { public static bool Prefix(XUiC_QuestTurnInRewardsWindow __instance) { float num = EffectManager.GetValue(PassiveEffects.QuestRewardOptionCount, _originalValue: (float)__instance.currentQuest.QuestClass.RewardChoicesCount, _entity: (EntityAlive)__instance.xui.playerUI.entityPlayer); __instance.optionCount = 0; int index1 = 0; if (__instance.selectedEntry != null) __instance.SelectedEntry = (XUiC_QuestTurnInEntry)null; __instance.selectedEntryList.Clear(); __instance.rewardList.Clear(); for (int index2 = 0; index2 < __instance.entryList.Length; ++index2) { __instance.entryList[index2].OnPress -= new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed); __instance.entryList[index2].SetBaseReward((BaseReward)null); } EntityPlayer player = __instance.xui.playerUI.entityPlayer; ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkDaringAdventurer"); float perkDaringAdventurer = RebirthUtilities.GetCalculatedLevel(player, progressionValue); //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions perkDaringAdventurer: " + perkDaringAdventurer); for (int index3 = 0; index3 < __instance.currentQuest.Rewards.Count; ++index3) { bool bAddReward = true; BaseReward reward = __instance.currentQuest.Rewards[index3]; if (reward != null) { string rewardID = __instance.currentQuest.Rewards[index3].ID; //Log.Out($"XUiC_QuestTurnInRewardsWindowPatches-SetupOptions rewardID[{index3}]: " + rewardID); if (__instance.currentQuest.Rewards[index3].ID != null) { if (RebirthUtilities.ScenarioSkip()) { if (rewardID.Contains("FuriousRamsayGeneticBlueprintTier") && perkDaringAdventurer < 1) { //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions A SKIP GENETIC BLUEPRINTS"); bAddReward = false; } else if (rewardID == "groupFRPerks" && perkDaringAdventurer < 2) { //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions A SKIP PERK BOOK"); bAddReward = false; } } else { if (rewardID.Contains("FuriousRamsayGeneticBlueprintTier") && perkDaringAdventurer < 1) { //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP GENETIC BLUEPRINTS"); bAddReward = false; } else if (rewardID.Contains("groupExpertiseXPQuestBundle") && perkDaringAdventurer < 2) { //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP EXPERTISE BUNDLES"); bAddReward = false; } else if (rewardID == "groupFRPerks" && perkDaringAdventurer < 3) { //Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP PERK BOOK"); bAddReward = false; } } } } if (bAddReward) { __instance.rewardList.Add(__instance.currentQuest.Rewards[index3]); } } __instance.rewardList = __instance.rewardList.OrderBy((Func)(o => o.RewardIndex)).ToList(); for (int index4 = 0; index4 < __instance.rewardList.Count; ++index4) { BaseReward reward = __instance.rewardList[index4]; __instance.entryList[index1].OnPress -= new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed); if (reward.isChosenReward) { __instance.entryList[index1].SetBaseReward(reward); __instance.entryList[index1].Chosen = false; __instance.entryList[index1++].OnPress += new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed); ++__instance.optionCount; if ((double)num == (double)index1 || index1 >= __instance.entryList.Length) break; } } __instance.entryList[0].SelectCursorElement(true); if (__instance.optionCount != 1) return false; __instance.SelectedEntry = __instance.entryList[0]; __instance.RefreshBindings(); return false; } } }