mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 05:30:43 -05:00
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>
This commit is contained in:
parent
a740deed47
commit
bd03049673
@ -2,15 +2,12 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using SPT.Reflection.Patching;
|
using SPT.Reflection.Patching;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
|
||||||
|
|
||||||
namespace SPT.Custom.Patches
|
namespace SPT.Custom.Patches
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This transpiler removes the call to <see cref="IBackEndSession.SessionMode"/> to determine if it's <see cref="ESessionMode.Regular"/> <br/>
|
/// This patch sets the Prestige Tab to be enabled in PvE mode
|
||||||
/// and forces a true instead
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class EnablePrestigeTabPatch : ModulePatch
|
internal class EnablePrestigeTabPatch : ModulePatch
|
||||||
{
|
{
|
||||||
@ -19,22 +16,13 @@ namespace SPT.Custom.Patches
|
|||||||
return AccessTools.Method(typeof(InventoryScreen.Class2754), nameof(InventoryScreen.Class2754.MoveNext));
|
return AccessTools.Method(typeof(InventoryScreen.Class2754), nameof(InventoryScreen.Class2754.MoveNext));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchPostfix]
|
||||||
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
|
public static void Postfix(InventoryScreen.Class2754 __instance)
|
||||||
{
|
{
|
||||||
CodeInstruction[] codeInstructions = instructions.ToArray();
|
var inventoryScreen = __instance.inventoryScreen_0;
|
||||||
|
var tabDictionary = Traverse.Create(inventoryScreen).Field<IReadOnlyDictionary<EInventoryTab, Tab>>("_tabDictionary").Value;
|
||||||
// Remove all instructions that gets the gamemode from iSession
|
var prestigeTab = tabDictionary[EInventoryTab.Prestige];
|
||||||
codeInstructions[259] = new(OpCodes.Nop);
|
prestigeTab.gameObject.SetActive(true);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user