public void Apply() { PatchMethod[] ToPatchMethod(Patch[] patches) { return(patches.Select(p => new PatchMethod { after = p.after, before = p.before, method = p.PatchMethod, priority = p.priority, owner = p.owner, }).ToArray()); } var info = mb.ToPatchInfo(); var state = new PatchInfoWrapper { prefixes = ToPatchMethod(info.prefixes), postfixes = ToPatchMethod(info.postfixes), transpilers = ToPatchMethod(info.transpilers), finalizers = ToPatchMethod(info.finalizers), };
public void Apply() { PatchMethod[] ToPatchMethod(Patch[] patches) { return(patches.Select(p => new PatchMethod { after = p.after, before = p.before, method = p.patch, priority = p.priority, owner = p.owner, }).ToArray()); } var info = HarmonySharedState.GetPatchInfo(mb); var state = new PatchInfoWrapper { prefixes = ToPatchMethod(info.prefixes), postfixes = ToPatchMethod(info.postfixes), transpilers = ToPatchMethod(info.transpilers), finalizers = new PatchMethod[0] }; var add = new PatchInfoWrapper { finalizers = new PatchMethod[0] }; var remove = new PatchInfoWrapper { finalizers = new PatchMethod[0] }; Diff(previousState.prefixes, state.prefixes, out add.prefixes, out remove.prefixes); Diff(previousState.postfixes, state.postfixes, out add.postfixes, out remove.postfixes); Diff(previousState.transpilers, state.transpilers, out add.transpilers, out remove.transpilers); previousState = state; HarmonyInterop.ApplyPatch(mb, add, remove); }