コード例 #1
0
        /// <summary>
        /// Initializes the Ploppable Tool (including panel).
        /// </summary>
        internal static void Initialize()
        {
            // Don't do anything if we're already setup.
            if (_instance == null)
            {
                try
                {
                    // Creating our own gameObect helps finding the UI in ModTools.
                    _gameObject = new GameObject("PloppableTool");
                    _gameObject.transform.parent = UIView.GetAView().transform;

                    // Add tool and panel.
                    _instance = _gameObject.AddComponent <PloppableTool>();
                    _instance.DrawPloppablePanel();

                    // Deactivate to start with if we're speed boosting.
                    if (ModSettings.speedBoost)
                    {
                        _gameObject.SetActive(false);
                    }

                    // Initialise construction time dictionary.
                    _instance.constructionTimes = new Dictionary <BuildingInfo, int>();
                }
                catch (Exception e)
                {
                    Logging.LogException(e, "exception initializing ploppable tool");
                }
            }
        }
コード例 #2
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();
            }
        }
コード例 #3
0
        public static void Initialize()
        {
            if (_instance == null)
            {
                /*
                 * GameObject gameController = GameObject.FindWithTag("GameController");
                 * _instance = gameController.AddComponent<PloppableTool>();
                 * _instance.name = "PloppableTool";
                 * _instance.DrawPloppablePanel();
                 * _instance.PopulateAssets();
                 * _instance.enabled = false;
                 * //GameObject.FindObjectOfType<ToolController>().Tools[0].enabled = true;
                 */
                try
                {
                    // Destroy the UI if already exists
                    //_gameObject = GameObject.Find("PloppableTool");
                    //Destroy();

                    // Creating our own gameObect, helps finding the UI in ModTools
                    _gameObject = new GameObject("PloppableTool");
                    _gameObject.transform.parent = UIView.GetAView().transform;
                    _instance = _gameObject.AddComponent <PloppableTool>();
                    //_instance.name = "PloppableTool";
                    _instance.DrawPloppablePanel();
                    _instance.PopulateAssets();
                    //_instance.enabled = false;
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Harmony postfix to perform actions require after the level has loaded.
        /// </summary>
        public static void Postfix()
        {
            // Don't do anything if mod hasn't activated for whatever reason (mod conflict, harmony error, something else).
            if (!Loading.isModEnabled)
            {
                return;
            }

            // Report any 'soft' mod conflicts.
            if (Loading.softModConflct)
            {
                // Soft conflict detected - display warning notification for each one.
                foreach (string mod in ModUtils.conflictingModNames)
                {
                    if (mod.Equals("PTG") && ModSettings.dsaPTG == 0)
                    {
                        // Plop the Growables.
                        DontShowAgainMessageBox softConflictBox = MessageBoxBase.ShowModal <DontShowAgainMessageBox>();
                        softConflictBox.AddParas(Translations.Translate("PRR_CON_PTG0"), Translations.Translate("PRR_CON_PTG1"), Translations.Translate("PRR_CON_PTG2"));
                        softConflictBox.DSAButton.eventClicked += (component, clickEvent) => { ModSettings.dsaPTG = 1; SettingsUtils.SaveSettings(); };
                    }
                }
            }

            // Report any broken assets and remove from our prefab dictionary.
            foreach (BuildingInfo prefab in Loading.brokenPrefabs)
            {
                Logging.Error("broken prefab: ", prefab.name);
                Loading.xmlManager.prefabHash.Remove(prefab);
            }
            Loading.brokenPrefabs.Clear();

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

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

            // Display update notification.
            try
            {
                WhatsNew.ShowWhatsNew();
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception showing WhatsNew panel");
            }

            // Set up options panel event handler.
            try
            {
                OptionsPanel.OptionsEventHook();
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception hooking options panel");
            }

            Logging.KeyMessage("loading complete");
        }
コード例 #5
0
ファイル: Loading.cs プロジェクト: targettius/Ploppable-RICO
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            //if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame)
            //return;

            //Load xml only from main menu.
            if (xmlManager == null)
            {
                xmlManager = new RICOPrefabManager();
                xmlManager.Run();
            }

            //Assign xml settings to prefabs.
            convertPrefabs = new ConvertPrefabs();
            convertPrefabs.run();

            //Init GUI
            PloppableTool.Initialize();
            RICOSettingsPanel.Initialize();

            //Deploy Detour
            Detour.BuildingToolDetour.Deploy();
            Debug.Log("Detour Deployed");
        }
コード例 #6
0
 public static void Initialize()
 {
     if (_instance == null)
     {
         GameObject gameController = GameObject.FindWithTag("GameController");
         _instance      = gameController.AddComponent <PloppableTool>();
         _instance.name = "PloppableTool";
         _instance.DrawPloppablePanel();
         _instance.PopulateAssets();
         _instance.enabled = false;
         GameObject.FindObjectOfType <ToolController>().Tools[0].enabled = true;
     }
 }
コード例 #7
0
 /// <summary>
 /// Initializes the Ploppable Tool (including panel).
 /// </summary>
 internal static void Initialize()
 {
     // Don't do anything if we're already setup.
     if (_instance == null)
     {
         try
         {
             // Creating our own gameObect helps finding the UI in ModTools.
             _gameObject = new GameObject("PloppableTool");
             _gameObject.transform.parent = UIView.GetAView().transform;
             _instance = _gameObject.AddComponent <PloppableTool>();
             _instance.DrawPloppablePanel();
             _instance.PopulateButtons();
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
 }
コード例 #8
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame)
            {
                return;
            }

            //Load xml
            xmlManager = new XMLManager();
            xmlManager.Run();

            //Assign xml settings to prefabs.
            convertPrefabs = new ConvertPrefabs();
            convertPrefabs.run();

            //Init GUI
            PloppableTool.Initialize();
            RICOSettingsPanel.Initialize();

            //Deploy Detour
            Detour.BuildingToolDetour.Deploy();
        }
コード例 #9
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;
            }

            // 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();
        }