From bd03049673cc95ea6e073d411b83afca48803967 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sun, 19 Jan 2025 07:53:56 -0800 Subject: [PATCH] Rework EnablePrestigeTabPatch (#25) * Add new transpilers * Cleanup * Fix transpiler * Fix incorrect code instruction * Add EnablePrestigeTabPatch * Rework EnablePrestigeTabPatch --------- Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com> --- .../Patches/EnablePrestigeTabPatch.cs | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs b/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs index 1c15f29..0657000 100644 --- a/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs +++ b/project/SPT.Custom/Patches/EnablePrestigeTabPatch.cs @@ -2,15 +2,12 @@ using HarmonyLib; using SPT.Reflection.Patching; using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Reflection.Emit; namespace SPT.Custom.Patches { /// - /// This transpiler removes the call to to determine if it's
- /// and forces a true instead + /// This patch sets the Prestige Tab to be enabled in PvE mode ///
internal class EnablePrestigeTabPatch : ModulePatch { @@ -19,22 +16,13 @@ namespace SPT.Custom.Patches return AccessTools.Method(typeof(InventoryScreen.Class2754), nameof(InventoryScreen.Class2754.MoveNext)); } - [PatchTranspiler] - public static IEnumerable Transpile(IEnumerable instructions) + [PatchPostfix] + public static void Postfix(InventoryScreen.Class2754 __instance) { - CodeInstruction[] codeInstructions = instructions.ToArray(); - - // Remove all instructions that gets the gamemode from iSession - codeInstructions[259] = new(OpCodes.Nop); - codeInstructions[260] = new(OpCodes.Nop); - codeInstructions[261] = new(OpCodes.Nop); - codeInstructions[262] = new(OpCodes.Nop); - - // Force a true on the stack instead - codeInstructions[263] = new(OpCodes.Ldc_I4_1); - codeInstructions[264] = new(OpCodes.Nop); - - return codeInstructions; + var inventoryScreen = __instance.inventoryScreen_0; + var tabDictionary = Traverse.Create(inventoryScreen).Field>("_tabDictionary").Value; + var prestigeTab = tabDictionary[EInventoryTab.Prestige]; + prestigeTab.gameObject.SetActive(true); } } }