private static bool DoDetour(Type rimworld, Type mod, string method) { MethodInfo RimWorld_A = rimworld.GetMethod(method, UniversalBindingFlags); MethodInfo ModTest_A = mod.GetMethod(method, UniversalBindingFlags); if (!Detours.TryDetourFromTo(RimWorld_A, ModTest_A)) { return(false); } return(true); }
private static bool DoInject() { MethodInfo RimWorld_PathFinder_FindPath = typeof(Verse.AI.PathFinder).GetMethod("FindPath", new [] { typeof(IntVec3), typeof(LocalTargetInfo), typeof(TraverseParms), typeof(PathEndMode) }); MethodInfo ModTest_PathFinder_FindPath = typeof(PathFinderDetour).GetMethod("FindPath", UniversalBindingFlags); if (!Detours.TryDetourFromTo(RimWorld_PathFinder_FindPath, ModTest_PathFinder_FindPath)) { return(false); } #if DEBUG var assembly = typeof(GameInitData).Assembly; var debugCellType = assembly.GetType("Verse.DebugCell"); if (!DoDetour(debugCellType, typeof(DebugCell), "OnGUI")) { return(false); } #endif return(true); }