示例#1
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Callvirt, "Segment", "GetCube", true, new Type[] { typeof(long), typeof(long), typeof(long) });
                FileLog.Log("Running patch, which found instruction " + InstructionHandlers.toString(codes, loc));
                codes[loc].opcode  = OpCodes.Call;
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.Cryopathy.CryopathyMod", "getCubeForCryoCheckAt", false, typeof(Segment), typeof(long), typeof(long), typeof(long), typeof(ushort));
                codes.Insert(loc, new CodeInstruction(OpCodes.Ldloc_1));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }