예제 #1
0
        /// <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;
            }

            // Init Ploppable Tool panel.
            PloppableTool.Initialize();

            // Add buttons to access building details from zoned building info panels.
            SettingsPanel.AddInfoPanelButtons();

            // Deactivate the ploppable panel as it starts hidden.  Don't need to deactivate the settings panel as it's not instantiated until first shown.
            PloppableTool.Instance.gameObject.SetActive(false);

            // Report any loading errors.
            Debugging.ReportErrors();

            Debugging.Message("loading complete");

            // Load settings file and check if we need to display update notification.
            settingsFile = Configuration <SettingsFile> .Load();

            if (settingsFile.NotificationVersion != 2)
            {
                // No update notification "Don't show again" flag found; show the notification.
                UpdateNotification notification = new UpdateNotification();
                notification.Create();
                notification.Show();
            }
        }
        /// <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();
        }