Exemple #1
0
        static IEnumerable <CodeInstruction> Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable <CodeInstruction> instructions)
        {
            OpCode[] opCodesToFind =
            {
                OpCodes.Call,
                OpCodes.Ldfld,
                OpCodes.Ldfld,
                OpCodes.Ldsfld,
                OpCodes.Bne_Un
            };
            string[] operandsToFind =
            {
                "Verse.Pawn get_SelPawn()",
                "RimWorld.Pawn_GuestTracker guest",
                "RimWorld.PrisonerInteractionModeDef interactionMode",
                "RimWorld.PrisonerInteractionModeDef Convert",
                "System.Reflection.Emit.Label"
            };

            OpCode[] opCodesToReplace =
            {
                OpCodes.Call,
                OpCodes.Ldfld,
                OpCodes.Ldfld,
                OpCodes.Ldsfld,
                OpCodes.Bne_Un
            };
            string[] operandsToReplace =
            {
                "Verse.Pawn get_SelPawn()",
                "RimWorld.Pawn_GuestTracker guest",
                "RimWorld.PrisonerInteractionModeDef interactionMode",
                "RimWorld.PrisonerInteractionModeDef Convert",
                "System.Reflection.Emit.Label"
            };

            var label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instructions);

            CodeInstruction[] replacment =
            {
                new CodeInstruction(OpCodes.Call,    typeof(Patch_VisitorTab_TabDraw).GetMethod(nameof(ShouldDisplayConvertIco))),
                new CodeInstruction(OpCodes.Brfalse, label)
            };

            return(HPatcher.ReplaceFragment(opCodesToReplace, operandsToReplace, instructions, replacment, nameof(ITab_Pawn_Visitor) + ": patch display ideo ico"));
        }
        private static IEnumerable <CodeInstruction> Transpiler(ILGenerator gen, IEnumerable <CodeInstruction> instr)
        {
            OpCode[] opCodesToFind =
            {
                OpCodes.Ldloc_0,
                OpCodes.Callvirt,
                OpCodes.Brtrue_S
            };
            string[] operandsToFind =
            {
                "",
                "RimWorld.Faction get_HostFaction()",
                "System.Reflection.Emit.Label"
            };
            Label label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instr);

            CodeInstruction[] replacemnt =
            {
                new CodeInstruction(OpCodes.Nop),
                new CodeInstruction(OpCodes.Nop),
                new CodeInstruction(OpCodes.Nop, label),
            };
            return(HPatcher.ReplaceFragment(opCodesToFind, operandsToFind, instr, replacemnt, "Patch_Bill_ProductionWithUft"));
        }