예제 #1
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> codes)
        {
            var from = typeof(NetAI).GetMethod("SimulationStep", BindingFlags.Public | BindingFlags.Instance, null,
                                               new Type[] { typeof(ushort), typeof(NetSegment).MakeByRefType() }, null);
            var to = typeof(NetManagerPatch).GetMethod("SimulationStep", BindingFlags.Static | BindingFlags.NonPublic);

            var list = codes.ToList();

            HarmonyUtil.ReplaceCalls(list, from, to);
            return(list);
        }
예제 #2
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> codes)
        {
            var fromSS = typeof(BuildingAI).GetMethod("SimulationStep", BindingFlags.Public | BindingFlags.Instance, null,
                                                      new Type[] { typeof(ushort), typeof(Building).MakeByRefType() }, null);
            var toSS = typeof(BuildingManagerPatch).GetMethod("SimulationStep", BindingFlags.Static | BindingFlags.NonPublic);

            var fromCU = typeof(BuildingAI).GetMethod("CheckUnlocking", BindingFlags.Public | BindingFlags.Instance);
            var toCU   = typeof(BuildingManagerPatch).GetMethod("CheckUnlocking", BindingFlags.Static | BindingFlags.NonPublic);

            var list = codes.ToList();

            HarmonyUtil.ReplaceCalls(list, fromSS, toSS);
            HarmonyUtil.ReplaceCalls(list, fromCU, toCU);

            return(list);
        }