first commit
This commit is contained in:
43
NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs
Normal file
43
NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
using NitroxModel.Helper;
|
||||
|
||||
namespace NitroxPatcher.Patches.Dynamic;
|
||||
|
||||
public sealed partial class IngameMenu_OnSelect_Patch : NitroxPatch, IDynamicPatch
|
||||
{
|
||||
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((IngameMenu t) => t.OnSelect(default(bool)));
|
||||
private static readonly MethodInfo UPDATE_BUTTONS_METHOD = Reflect.Method((IngameMenu t) => t.UpdateButtons());
|
||||
|
||||
public static void Postfix()
|
||||
{
|
||||
IngameMenu.main.saveButton.gameObject.SetActive(false);
|
||||
|
||||
#if DEBUG
|
||||
IngameMenu.main.ActivateDeveloperMode(); // Activating it here to ensure IngameMenu is ready for it
|
||||
#endif
|
||||
}
|
||||
|
||||
public static IEnumerable<CodeInstruction> Transpiler(MethodBase original, IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
List<CodeInstruction> instructionList = instructions.ToList();
|
||||
|
||||
/* Early return cuts out
|
||||
* this.UpdateButtons();
|
||||
*/
|
||||
for (int i = 0; i < instructionList.Count; i++)
|
||||
{
|
||||
CodeInstruction instruction = instructionList[i];
|
||||
yield return instruction;
|
||||
|
||||
if (UPDATE_BUTTONS_METHOD.Equals(instructionList[i + 2].operand))
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user