using HarmonyLib; using SPT.Reflection.Patching; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; namespace SPT.SinglePlayer.Patches.Performance { /// /// Transpiler used to stop the allocation of a new during
/// To update transpiler, look for:
/// - New allocation of
/// - and
///
public class RemoveStopwatchAllocationsEveryCoverPointFramePatch : ModulePatch { protected override MethodBase GetTargetMethod() { return AccessTools.Method(typeof(CoverPointMaster), nameof(CoverPointMaster.method_0)); } [PatchTranspiler] public static IEnumerable Transpile(IEnumerable instructions) { List codeList = instructions.ToList(); // This is the line that stops the Stopwatch codeList[69].opcode = OpCodes.Nop; // These lines stop the allocation and Start() of the Stopwatch codeList[12].opcode = OpCodes.Nop; codeList[11].opcode = OpCodes.Nop; codeList[10].opcode = OpCodes.Nop; return codeList; } } }