/// <summary> /// Called by the game when the mod is enabled. /// </summary> public void OnEnabled() { // Apply Harmony patches via Cities Harmony. // Called here instead of OnCreated to allow the auto-downloader to do its work prior to launch. HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll()); // Load settings file. SettingsUtils.LoadSettings(); // Check to see if UIView is ready. if (UIView.GetAView() != null) { // It's ready - attach the hook now. OptionsPanel.OptionsEventHook(); } else { // Otherwise, queue the hook for when the intro's finished loading. LoadingManager.instance.m_introLoaded += OptionsPanel.OptionsEventHook; } }
/// <summary> /// Called by the game when level loading is complete. /// </summary> /// <param name="mode">Loading mode (e.g. game, editor, scenario, etc.)</param> public override void OnLevelLoaded(LoadMode mode) { // Alert the user to any mod conflicts. ModUtils.NotifyConflict(); // Don't do anything further if mod hasn't activated (conflicting mod detected, or loading into editor instead of game). if (!isModEnabled) { return; } base.OnLevelLoaded(mode); // Don't do anything if in asset editor. if (mode == LoadMode.NewAsset || mode == LoadMode.LoadAsset) { return; } // Wait for loading to fully complete. while (!LoadingManager.instance.m_loadingComplete) { } // Check watchdog flag. if (!patchOperating) { // Patch wasn't operating; display warning notification and exit. HarmonyNotification notification = new HarmonyNotification(); notification.Create(); notification.Show(); return; } // Report any broken assets and remove from our prefab dictionary. foreach (BuildingInfo prefab in brokenPrefabs) { Debugging.Message("broken prefab: " + prefab.name); xmlManager.prefabHash.Remove(prefab); } brokenPrefabs.Clear(); // Init Ploppable Tool panel. PloppableTool.Initialize(); // Add buttons to access building details from zoned building info panels. SettingsPanel.AddInfoPanelButtons(); // Report any loading errors. Debugging.ReportErrors(); Debugging.Message("loading complete"); // Load settings file and check if we need to display update notification. if (UpdateNotification.notificationVersion != 3) { // No update notification "Don't show again" flag found; show the notification. UpdateNotification notification = new UpdateNotification(); notification.Create(); notification.Show(); } // Set up options panel event handler. OptionsPanel.OptionsEventHook(); }