public override void OnCreated(ILoading loading) { //SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); ToolMode = TrafficManagerMode.None; Detours = new List <Detour>(); DetourInited = false; CustomPathManager = new CustomPathManager(); }
public override void OnCreated(ILoading loading) { // SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); Detours = new List <Detour>(); RegisteredManagers = new List <ICustomManager>(); DetourInited = false; CustomPathManager = new CustomPathManager(); RegisterCustomManagers(); }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); switch (mode) { case LoadMode.NewGame: OnNewGame(); break; case LoadMode.LoadGame: OnLoaded(); break; default: break; } if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { if (Instance == null) { if (Singleton <PathManager> .instance.GetType() != typeof(PathManager)) { LoadingExtension.PathfinderIncompatibility = true; } Instance = this; } if (!LoadingExtension.PathfinderIncompatibility) { FieldInfo pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); PathManager stockPathManager = PathManager.instance; customPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); customPathManager.UpdateWithPathManagerValues(stockPathManager); pathManagerInstance.SetValue(null, customPathManager); FastList <ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList <ISimulationManager>; managers.Remove(stockPathManager); managers.Add(customPathManager); GameObject.Destroy(stockPathManager, 10f); } UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>(); TrafficPriority.leftHandDrive = Singleton <SimulationManager> .instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True; } }
public override void OnCreated(ILoading loading) { Log._Debug("LoadingExtension.OnCreated() called"); // SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); Detours = new List <Detour>(); RegisteredManagers = new List <ICustomManager>(); DetourInited = false; CustomPathManager = new CustomPathManager(); RegisterCustomManagers(); Instance = this; InGameHotReload = InGame(); }
public override void OnCreated(ILoading loading) { Log._Debug("LoadingExtension.OnCreated() called"); // SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); if (IsGameLoaded) { // When another mod is detected, OnCreated is called again for god - or CS team - knows what reason! Log._Debug("Hot reload of another mod detected. Skipping LoadingExtension.OnCreated() ..."); return; } RegisteredManagers = new List <ICustomManager>(); CustomPathManager = new CustomPathManager(); RegisterCustomManagers(); Instance = this; }
public override void OnCreated(ILoading loading) { base.OnCreated(loading); if (Instance == null) { Instance = this; } FieldInfo pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); PathManager stockPathManager = PathManager.instance; customPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); customPathManager.UpdateWithPathManagerValues(stockPathManager); pathManagerInstance.SetValue(null, customPathManager); FastList <ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList <ISimulationManager>; managers.Remove(stockPathManager); managers.Add(customPathManager); GameObject.Destroy(stockPathManager, 10f); }
public override void OnCreated(ILoading loading) { SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); Log.Message("Setting ToolMode"); ToolMode = TrafficManagerMode.None; Log.Message("Init RevertMethods"); OriginalMethods = new MethodInfo[7]; CustomMethods = new MethodInfo[7]; CustomRedirects = new RedirectCallsState[7]; Log.Message("Setting Despawn to False"); DespawnEnabled = true; Log.Message("Init DetourInited"); DetourInited = false; Log.Message("Init Custom PathManager"); CustomPathManager = new CustomPathManager(); }
public override void OnLevelLoaded(LoadMode mode) { SimulationManager.UpdateMode updateMode = SimulationManager.instance.m_metaData.m_updateMode; Log.Info($"OnLevelLoaded({mode}) called. updateMode={updateMode}"); base.OnLevelLoaded(mode); Log._Debug("OnLevelLoaded Returned from base, calling custom code."); IsGameLoaded = false; switch (updateMode) { case SimulationManager.UpdateMode.NewGameFromMap: case SimulationManager.UpdateMode.NewGameFromScenario: case SimulationManager.UpdateMode.LoadGame: if (BuildConfig.applicationVersion != BuildConfig.VersionToString(TrafficManagerMod.GameVersion, false)) { string[] majorVersionElms = BuildConfig.applicationVersion.Split('-'); string[] versionElms = majorVersionElms[0].Split('.'); uint versionA = Convert.ToUInt32(versionElms[0]); uint versionB = Convert.ToUInt32(versionElms[1]); uint versionC = Convert.ToUInt32(versionElms[2]); Log.Info($"Detected game version v{BuildConfig.applicationVersion}"); bool isModTooOld = TrafficManagerMod.GameVersionA < versionA || (TrafficManagerMod.GameVersionA == versionA && TrafficManagerMod.GameVersionB < versionB) /* || * (TrafficManagerMod.GameVersionA == versionA && TrafficManagerMod.GameVersionB == versionB && TrafficManagerMod.GameVersionC < versionC)*/; bool isModNewer = TrafficManagerMod.GameVersionA < versionA || (TrafficManagerMod.GameVersionA == versionA && TrafficManagerMod.GameVersionB > versionB) /* || * (TrafficManagerMod.GameVersionA == versionA && TrafficManagerMod.GameVersionB == versionB && TrafficManagerMod.GameVersionC > versionC)*/; if (isModTooOld) { string msg = $"Traffic Manager: President Edition detected that you are running a newer game version ({BuildConfig.applicationVersion}) than TM:PE has been built for ({BuildConfig.VersionToString(TrafficManagerMod.GameVersion, false)}). Please be aware that TM:PE has not been updated for the newest game version yet and thus it is very likely it will not work as expected."; Log.Error(msg); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("TM:PE has not been updated yet", msg, false); }); } else if (isModNewer) { string msg = $"Traffic Manager: President Edition has been built for game version {BuildConfig.VersionToString(TrafficManagerMod.GameVersion, false)}. You are running game version {BuildConfig.applicationVersion}. Some features of TM:PE will not work with older game versions. Please let Steam update your game."; Log.Error(msg); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Your game should be updated", msg, false); }); } } IsGameLoaded = true; break; default: Log.Info($"OnLevelLoaded: Unsupported game mode {mode}"); return; } if (!IsPathManagerReplaced) { try { Log.Info("Pathfinder Compatible. Setting up CustomPathManager and SimManager."); var pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); var stockPathManager = PathManager.instance; Log._Debug($"Got stock PathManager instance {stockPathManager.GetName()}"); CustomPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); Log._Debug("Added CustomPathManager to gameObject List"); if (CustomPathManager == null) { Log.Error("CustomPathManager null. Error creating it."); return; } CustomPathManager.UpdateWithPathManagerValues(stockPathManager); Log._Debug("UpdateWithPathManagerValues success"); pathManagerInstance?.SetValue(null, CustomPathManager); Log._Debug("Getting Current SimulationManager"); var simManager = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic)? .GetValue(null) as FastList <ISimulationManager>; Log._Debug("Removing Stock PathManager"); simManager?.Remove(stockPathManager); Log._Debug("Adding Custom PathManager"); simManager?.Add(CustomPathManager); Object.Destroy(stockPathManager, 10f); Log._Debug("Should be custom: " + Singleton <PathManager> .instance.GetType().ToString()); IsPathManagerReplaced = true; } catch (Exception ex) { string error = "Traffic Manager: President Edition failed to load. You can continue playing but it's NOT recommended. Traffic Manager will not work as expected."; Log.Error(error); Log.Error($"Path manager replacement error: {ex.ToString()}"); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("TM:PE failed to load", error, true); }); } } Log.Info("Adding Controls to UI."); if (BaseUI == null) { Log._Debug("Adding UIBase instance."); BaseUI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>(); } // Init transport demand UI if (TransportDemandUI == null) { var uiView = UIView.GetAView(); TransportDemandUI = (UITransportDemand)uiView.AddUIComponent(typeof(UITransportDemand)); } // add "remove vehicle" button UIView.GetAView().gameObject.AddComponent <RemoveVehicleButtonExtender>(); // add "remove citizen instance" button UIView.GetAView().gameObject.AddComponent <RemoveCitizenInstanceButtonExtender>(); initDetours(); //Log.Info("Fixing non-created nodes with problems..."); //FixNonCreatedNodeProblems(); Log.Info("Notifying managers..."); foreach (ICustomManager manager in RegisteredManagers) { Log.Info($"OnLevelLoading: {manager.GetType().Name}"); manager.OnLevelLoading(); } //InitTool(); //Log._Debug($"Current tool: {ToolManager.instance.m_properties.CurrentTool}"); Log.Info("OnLevelLoaded complete."); }
public override void OnCreated(ILoading loading) { SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); ToolMode = TrafficManagerMode.None; Detours = new List<Detour>(); DetourInited = false; CustomPathManager = new CustomPathManager(); }
public bool StartPathFind2(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays) { if ((vehicleData.m_flags & (Vehicle.Flags.TransferToSource | Vehicle.Flags.GoingBack)) != Vehicle.Flags.None) { return(base.StartPathFind(vehicleID, ref vehicleData, startPos, endPos, startBothWays, endBothWays)); } PathUnit.Position startPosA; PathUnit.Position startPosB; float num; float num2; bool flag = PathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Car, 32f, out startPosA, out startPosB, out num, out num2); PathUnit.Position position; PathUnit.Position position2; float num3; float num4; if (PathManager.FindPathPosition(startPos, ItemClass.Service.PublicTransport, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship, 32f, out position, out position2, out num3, out num4)) { if (!flag || num3 < num) { startPosA = position; startPosB = position2; num = num3; num2 = num4; } flag = true; } PathUnit.Position endPosA; PathUnit.Position endPosB; float num5; float num6; bool flag2 = PathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Car, 32f, out endPosA, out endPosB, out num5, out num6); PathUnit.Position position3; PathUnit.Position position4; float num7; float num8; if (PathManager.FindPathPosition(endPos, ItemClass.Service.PublicTransport, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship, 32f, out position3, out position4, out num7, out num8)) { if (!flag2 || num7 < num5) { endPosA = position3; endPosB = position4; num5 = num7; num6 = num8; } flag2 = true; } if (flag && flag2) { CustomPathManager instance = Singleton <CustomPathManager> .instance; if (!startBothWays || num < 10f) { startPosB = default(PathUnit.Position); } if (!endBothWays || num5 < 10f) { endPosB = default(PathUnit.Position); } NetInfo.LaneType laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.Cargo; VehicleInfo.VehicleType vehicleTypes = VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship; uint path; if (instance.CreatePath(out path, ref Singleton <SimulationManager> .instance.m_randomizer, Singleton <SimulationManager> .instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, laneTypes, vehicleTypes, 20000f, this.IsHeavyVehicle(), this.IgnoreBlocked(vehicleID, ref vehicleData), false, false, ItemClass.Service.Industrial)) { if (vehicleData.m_path != 0u) { instance.ReleasePath(vehicleData.m_path); } vehicleData.m_path = path; vehicleData.m_flags |= Vehicle.Flags.WaitingPath; return(true); } } return(false); }
public override void OnCreated(ILoading loading) { SelfDestruct.DestructOldInstances(this); base.OnCreated(loading); Debug.Log("Setting ToolMode"); ToolMode = TrafficManagerMode.None; Debug.Log("Init RevertMethods"); RevertMethods = new RedirectCallsState[8]; Debug.Log("Setting Despawn to False"); DespawnEnabled = true; Debug.Log("Init DetourInited"); DetourInited = false; Debug.Log("Init Custom PathManager"); CustomPathManager = new CustomPathManager(); }
public override void OnLevelLoaded(LoadMode mode) { Log.Info("OnLevelLoaded"); base.OnLevelLoaded(mode); Log._Debug("OnLevelLoaded Returned from base, calling custom code."); Instance = this; gameLoaded = false; switch (mode) { case LoadMode.NewGame: case LoadMode.LoadGame: gameLoaded = true; break; default: return; } TrafficPriority.OnLevelLoading(); #if !TAM determinePathManagerCompatible(); //SpeedLimitManager.GetDefaultSpeedLimits(); if (IsPathManagerCompatible && !IsPathManagerReplaced) { try { Log.Info("Pathfinder Compatible. Setting up CustomPathManager and SimManager."); var pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); var stockPathManager = PathManager.instance; Log._Debug($"Got stock PathManager instance {stockPathManager.GetName()}"); CustomPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); Log._Debug("Added CustomPathManager to gameObject List"); if (CustomPathManager == null) { Log.Error("CustomPathManager null. Error creating it."); return; } CustomPathManager.UpdateWithPathManagerValues(stockPathManager); Log._Debug("UpdateWithPathManagerValues success"); pathManagerInstance?.SetValue(null, CustomPathManager); Log._Debug("Getting Current SimulationManager"); var simManager = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic)? .GetValue(null) as FastList <ISimulationManager>; Log._Debug("Removing Stock PathManager"); simManager?.Remove(stockPathManager); Log._Debug("Adding Custom PathManager"); simManager?.Add(CustomPathManager); Object.Destroy(stockPathManager, 10f); Log._Debug("Should be custom: " + Singleton <PathManager> .instance.GetType().ToString()); IsPathManagerReplaced = true; } catch (Exception ex) { Log.Error($"Path manager replacement error: {ex.ToString()}"); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", "Traffic Manager: President Edition detected an incompatibility with another mod! You can continue playing but it's NOT recommended. Traffic Manager will not work as expected.", true); IsPathManagerCompatible = false; } } Log.Info("Adding Controls to UI."); UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>(); initDetours(); Log.Info("OnLevelLoaded complete."); #endif }
public override void OnLevelLoaded(LoadMode mode) { SimulationManager.UpdateMode updateMode = SimulationManager.instance.m_metaData.m_updateMode; string scene = SceneManager.GetActiveScene().name; Log.Info($"OnLevelLoaded({mode}) called. updateMode={updateMode}, scene={scene}"); if (scene == "ThemeEditor") { return; } IsGameLoaded = false; if (BuildConfig.applicationVersion != BuildConfig.VersionToString( TrafficManagerMod.GAME_VERSION, false)) { string[] majorVersionElms = BuildConfig.applicationVersion.Split('-'); string[] versionElms = majorVersionElms[0].Split('.'); uint versionA = Convert.ToUInt32(versionElms[0]); uint versionB = Convert.ToUInt32(versionElms[1]); uint versionC = Convert.ToUInt32(versionElms[2]); Log.Info($"Detected game version v{BuildConfig.applicationVersion}"); bool isModTooOld = TrafficManagerMod.GAME_VERSION_A < versionA || (TrafficManagerMod.GAME_VERSION_A == versionA && TrafficManagerMod.GAME_VERSION_B < versionB); // || (TrafficManagerMod.GameVersionA == versionA // && TrafficManagerMod.GameVersionB == versionB // && TrafficManagerMod.GameVersionC < versionC); bool isModNewer = TrafficManagerMod.GAME_VERSION_A < versionA || (TrafficManagerMod.GAME_VERSION_A == versionA && TrafficManagerMod.GAME_VERSION_B > versionB); // || (TrafficManagerMod.GameVersionA == versionA // && TrafficManagerMod.GameVersionB == versionB // && TrafficManagerMod.GameVersionC > versionC); if (isModTooOld) { string msg = string.Format( "Traffic Manager: President Edition detected that you are running " + "a newer game version ({0}) than TM:PE has been built for ({1}). " + "Please be aware that TM:PE has not been updated for the newest game " + "version yet and thus it is very likely it will not work as expected.", BuildConfig.applicationVersion, BuildConfig.VersionToString(TrafficManagerMod.GAME_VERSION, false)); Log.Error(msg); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread( () => { UIView.library .ShowModal <ExceptionPanel>("ExceptionPanel") .SetMessage( "TM:PE has not been updated yet", msg, false); }); } else if (isModNewer) { string msg = string.Format( "Traffic Manager: President Edition has been built for game version {0}. " + "You are running game version {1}. Some features of TM:PE will not " + "work with older game versions. Please let Steam update your game.", BuildConfig.VersionToString(TrafficManagerMod.GAME_VERSION, false), BuildConfig.applicationVersion); Log.Error(msg); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread( () => { UIView.library .ShowModal <ExceptionPanel>("ExceptionPanel") .SetMessage( "Your game should be updated", msg, false); }); } } IsGameLoaded = true; //it will replace stock PathManager or already Replaced before HotReload if (!IsPathManagerReplaced || TrafficManagerMod.Instance.InGameHotReload) { try { Log.Info("Pathfinder Compatible. Setting up CustomPathManager and SimManager."); FieldInfo pathManagerInstance = typeof(Singleton <PathManager>).GetField( "sInstance", BindingFlags.Static | BindingFlags.NonPublic); if (pathManagerInstance == null) { throw new Exception("pathManagerInstance is null"); } PathManager stockPathManager = PathManager.instance; if (stockPathManager == null) { throw new Exception("stockPathManager is null"); } Log._Debug($"Got stock PathManager instance {stockPathManager?.GetName()}"); CustomPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); Log._Debug("Added CustomPathManager to gameObject List"); if (CustomPathManager == null) { Log.Error("CustomPathManager null. Error creating it."); return; } CustomPathManager.UpdateWithPathManagerValues(stockPathManager); Log._Debug("UpdateWithPathManagerValues success"); pathManagerInstance.SetValue(null, CustomPathManager); Log._Debug("Getting Current SimulationManager"); var simManager = this.simManager; if (simManager == null) { throw new Exception("simManager is null"); } Log._Debug("Removing Stock PathManager"); simManager.Remove(stockPathManager); Log._Debug("Adding Custom PathManager"); simManager.Add(CustomPathManager); Object.Destroy(stockPathManager, 10f); Log._Debug("Should be custom: " + Singleton <PathManager> .instance.GetType()); IsPathManagerReplaced = true; } catch (Exception ex) { string error = "Traffic Manager: President Edition failed to load. You can continue " + "playing but it's NOT recommended. Traffic Manager will not work as expected."; Log.Error(error); Log.Error($"Path manager replacement error: {ex}"); Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread( () => { UIView.library .ShowModal <ExceptionPanel>( "ExceptionPanel") .SetMessage( "TM:PE failed to load", error, true); }); } } ModUI.OnLevelLoaded(); if (PlayMode) { // Init transport demand UI if (TransportDemandUI == null) { UIView uiView = UIView.GetAView(); TransportDemandUI = (UITransportDemand)uiView.AddUIComponent(typeof(UITransportDemand)); } // add "remove vehicle" button UIView.GetAView().gameObject.AddComponent <RemoveVehicleButtonExtender>(); // add "remove citizen instance" button UIView.GetAView().gameObject.AddComponent <RemoveCitizenInstanceButtonExtender>(); UIView.GetAView().gameObject.AddComponent <RoadSelectionPanels>(); } Patcher.Create().Install(); // Log.Info("Fixing non-created nodes with problems..."); // FixNonCreatedNodeProblems(); Log.Info("Notifying managers..."); foreach (ICustomManager manager in RegisteredManagers) { Log.Info($"OnLevelLoading: {manager.GetType().Name}"); manager.OnLevelLoading(); } // InitTool(); // Log._Debug($"Current tool: {ToolManager.instance.m_properties.CurrentTool}"); Log.Info("OnLevelLoaded complete."); }
public override void OnLevelLoaded(LoadMode mode) { Log.Warning("OnLevelLoaded calling base method"); base.OnLevelLoaded(mode); Log.Message("OnLevelLoaded Returned from base, calling custom code."); switch (mode) { case LoadMode.NewGame: OnNewGame(); break; case LoadMode.LoadGame: OnLoaded(); break; } if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { determinePathManagerCompatible(); Instance = this; initDetours(); if (IsPathManagerCompatible && !PathManagerReplaced) { Log.Warning("#####################################"); Log.Message("Pathfinder Compatible. Setting up CustomPathManager and SimManager."); var pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); var stockPathManager = PathManager.instance; Log.Message($"Got stock PathManager instance {stockPathManager.GetName()}"); CustomPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>(); Log.Message("Added CustomPathManager to gameObject List"); if (CustomPathManager == null) { Log.Error("CustomPathManager null. Error creating it."); return; } CustomPathManager.UpdateWithPathManagerValues(stockPathManager); Log.Message("UpdateWithPathManagerValues success"); pathManagerInstance?.SetValue(null, CustomPathManager); Log.Message("Getting Current SimulationManager"); var simManager = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic)? .GetValue(null) as FastList <ISimulationManager>; Log.Message("Removing Stock PathManager"); simManager?.Remove(stockPathManager); Log.Message("Adding Custom PathManager"); simManager?.Add(CustomPathManager); Object.Destroy(stockPathManager, 10f); PathManagerReplaced = true; } Log.Message("Adding Controls to UI."); UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>(); TrafficPriority.LeftHandDrive = Singleton <SimulationManager> .instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True; } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); switch (mode) { case LoadMode.NewGame: OnNewGame(); break; case LoadMode.LoadGame: OnLoaded(); break; default: break; } if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame) { if (Instance == null) { if (Singleton<PathManager>.instance.GetType() != typeof(PathManager)) { LoadingExtension.PathfinderIncompatibility = true; } Instance = this; } if (!LoadingExtension.PathfinderIncompatibility) { FieldInfo pathManagerInstance = typeof(Singleton<PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic); PathManager stockPathManager = PathManager.instance; customPathManager = stockPathManager.gameObject.AddComponent<CustomPathManager>(); customPathManager.UpdateWithPathManagerValues(stockPathManager); pathManagerInstance.SetValue(null, customPathManager); FastList<ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList<ISimulationManager>; managers.Remove(stockPathManager); managers.Add(customPathManager); GameObject.Destroy(stockPathManager, 10f); } UI = ToolsModifierControl.toolController.gameObject.AddComponent<UIBase>(); TrafficPriority.leftHandDrive = Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True; } }