public void EnableHook() { if (hookEnabled) { return; } var allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public; //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Logging Methods"); //typeof(NetTool).GetMethods(allFlags).OrderBy(x => x.Name).ToList().ForEach(x => DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, x.Name)); //typeof(NetTool).GetMethods(allFlags).Where(x => x.Name == "CheckZoning").ToList().ForEach(x => //{ // DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "#####"); // DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Name: " + x.Name); // x.GetParameters().ToList().ForEach(y => dumpObject("param", y)); // DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "found: " + x.GetParameters().Length); // DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "#####"); //}); //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Logging Methods END"); var method = typeof(NetTool).GetMethods(allFlags).FirstOrDefault(c => c.Name == "CanCreateSegment" && c.GetParameters().Length == 12); //dumpObject("CanCreateSegment", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("CanCreateSegment", allFlags))); method = typeof(NetTool).GetMethod("CheckNodeHeights", allFlags); //dumpObject("CheckNodeHeights", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("CheckNodeHeights", allFlags))); method = typeof(NetTool).GetMethod("CheckCollidingSegments", allFlags); //dumpObject("CheckCollidingSegments", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("CheckCollidingSegments", allFlags))); method = typeof(BuildingTool).GetMethod("CheckCollidingBuildings", allFlags); //dumpObject("CheckCollidingBuildings", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("CheckCollidingBuildings", allFlags))); method = typeof(BuildingTool).GetMethod("CheckSpace", allFlags); //dumpObject("CheckSpace", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("CheckSpace", allFlags))); method = typeof(NetTool).GetMethod("GetElevation", allFlags); //dumpObject("GetElevation", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("GetElevation", allFlags))); method = typeof(RoadAI).GetMethod("GetElevationLimits", allFlags); //dumpObject("GetElevationLimits", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("GetElevationLimits", allFlags))); method = typeof(TrainTrackAI).GetMethod("GetElevationLimits", allFlags); //dumpObject("GetElevationLimits", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("GetElevationLimits", allFlags))); method = typeof(PedestrianPathAI).GetMethod("GetElevationLimits", allFlags); //dumpObject("GetElevationLimits", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("GetElevationLimits", allFlags))); method = typeof(NetAI).GetMethod("BuildUnderground", allFlags); //dumpObject("BuildUnderground", method); redirects.Add(method, RedirectionHelper.RedirectCalls(method, typeof(Anarchy).GetMethod("BuildUnderground", allFlags))); hookEnabled = true; Debug.Log("Hooked."); }