// Replace TradeDeal.get_AllTradeables with TradingWindow.AllTradeables static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> e, MethodBase original) { List <CodeInstruction> insts = new List <CodeInstruction>(e); CodeFinder finder = new CodeFinder(original, insts); for (int i = 0; i < 2; i++) { int getAllTradeables = finder.Forward(OpCodes.Callvirt, AccessTools.Method(typeof(TradeDeal), "get_AllTradeables")); insts.RemoveRange(getAllTradeables - 1, 2); insts.Insert(getAllTradeables - 1, new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(TradingWindow), nameof(TradingWindow.AllTradeables)))); } return(insts); }
static IEnumerable <CodeInstruction> Transpiler(ILGenerator gen, IEnumerable <CodeInstruction> e, MethodBase original) { List <CodeInstruction> insts = (List <CodeInstruction>)e; Label label = gen.DefineLabel(); var finder = new CodeFinder(original, insts); int pos = finder.Forward(OpCodes.Stloc_S, 5); insts.Insert( pos + 1, new CodeInstruction(OpCodes.Ldloc_S, 5), new CodeInstruction(OpCodes.Call, CanPlaceBlueprintAtPatch.ShouldIgnore1Method), new CodeInstruction(OpCodes.Brtrue, label) ); int ret = finder.Start().Forward(OpCodes.Ret); insts[ret + 1].labels.Add(label); return(insts); }