first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View 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 Player_OnKill_Patch : NitroxPatch, IDynamicPatch
{
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((Player t) => t.OnKill(default(DamageType)));
private static readonly MethodInfo SKIP_METHOD = Reflect.Method(() => GameModeUtils.IsPermadeath());
public static IEnumerable<CodeInstruction> Transpiler(MethodBase original, IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> instructionList = instructions.ToList();
/**
* Skips
* if (GameModeUtils.IsPermadeath())
* {
* SaveLoadManager.main.ClearSlotAsync(SaveLoadManager.main.GetCurrentSlot());
* this.EndGame();
* return;
* }
*/
for (int i = 0; i < instructionList.Count; i++)
{
CodeInstruction instr = instructionList[i];
if (instr.opcode == OpCodes.Call && instr.operand.Equals(SKIP_METHOD))
{
CodeInstruction newInstr = new(OpCodes.Ldc_I4_0);
newInstr.labels = instr.labels;
yield return newInstr;
}
else
{
yield return instr;
}
}
}
}