void ReplacePathManager()
{
if (Singleton <PathManager> .instance as CustomPathManager != null)
{
return;
}
// Change PathManager to CustomPathManager
FieldInfo sInstance = typeof(ColossalFramework.Singleton <PathManager>).GetFieldByName("sInstance");
PathManager originalPathManager = ColossalFramework.Singleton <PathManager> .instance;
CustomPathManager customPathManager = originalPathManager.gameObject.AddComponent <CustomPathManager>();
customPathManager.SetOriginalValues(originalPathManager);
// change the new instance in the singleton
sInstance.SetValue(null, customPathManager);
// change the manager in the SimulationManager
FastList <ISimulationManager> managers = (FastList <ISimulationManager>) typeof(SimulationManager).GetFieldByName("m_managers").GetValue(null);
managers.Remove(originalPathManager);
managers.Add(customPathManager);
// Destroy in 10 seconds to give time to all references to update to the new manager without crashing
GameObject.Destroy(originalPathManager, 10f);
}