public static IEnumerable <CodeInstruction> Transpiler(ILGenerator il, IEnumerable <CodeInstruction> instructions)
        {
            CodeInstruction ldarg_startNodeID       = CSURUtil.GetLDArg(targetMethod_, "startNodeID"); // push startNodeID into stack,
            CodeInstruction call_GetMinCornerOffset = new CodeInstruction(OpCodes.Call, mGetMinCornerOffset);

            int n = 0;

            foreach (var innstruction in instructions)
            {
                bool is_ldfld_minCornerOffset =
                    innstruction.opcode == OpCodes.Ldfld && innstruction.operand == f_minCornerOffset;
                yield return(innstruction);

                if (is_ldfld_minCornerOffset)
                {
                    n++;
                    yield return(ldarg_startNodeID);

                    yield return(call_GetMinCornerOffset);
                }
            }

            DebugLog.LogToFileOnly($"TRANSPILER CalculateCornerPatch: Successfully patched NetSegment.CalculateCorner(). " +
                                   $"found {n} instances of Ldfld NetInfo.m_minCornerOffset");
            yield break;
        }
示例#2
0
        public static IEnumerable <CodeInstruction> Transpiler(ILGenerator il, IEnumerable <CodeInstruction> instructions)
        {
            CodeInstruction ldarg_segment        = CSURUtil.GetLDArg(targetMethod_, "segment"); // push segment into stack,
            CodeInstruction call_ChangeHalfWidth = new CodeInstruction(OpCodes.Call, mChangeHalfWidth);

            int n = 0;

            foreach (var innstruction in instructions)
            {
                yield return(innstruction);

                bool is_ldfld_f_halfWidth =
                    innstruction.opcode == OpCodes.Ldfld && innstruction.operand == f_halfWidth;
                if (is_ldfld_f_halfWidth)
                {
                    n++;
                    yield return(ldarg_segment);

                    yield return(call_ChangeHalfWidth);
                }
            }

            DebugLog.LogToFileOnly($"TRANSPILER CreateZoneBlocksPatch: Successfully patched RoadAI.CreateZoneBlocks(). " +
                                   $"found {n} instances of Ldfld NetInfo.m_halfWidth");
            yield break;
        }