Example #1
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> e, MethodBase original)
        {
            List <CodeInstruction> insts  = new List <CodeInstruction>(e);
            CodeFinder             finder = new CodeFinder(original, insts);

            int tradeMode = finder.
                            Start().
                            Forward(OpCodes.Ldsfld, TradeModeIcon).
                            Forward(OpCodes.Call, ButtonImageWithBG);

            insts.Insert(
                tradeMode + 2,
                new CodeInstruction(OpCodes.Call, ToggleGiftModeMethod),
                new CodeInstruction(OpCodes.Brtrue, insts[tradeMode + 1].operand)
                );

            int giftMode = finder.
                           Start().
                           Forward(OpCodes.Ldsfld, GiftModeIcon).
                           Forward(OpCodes.Call, ButtonImageWithBG);

            insts.Insert(
                giftMode + 2,
                new CodeInstruction(OpCodes.Call, ToggleGiftModeMethod),
                new CodeInstruction(OpCodes.Brtrue, insts[giftMode + 1].operand)
                );

            return(insts);
        }
Example #2
0
        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);
        }