Exemple #1
0
        /// <summary>
        /// Loads the ModOptions from the configuration file located within the mods folder.
        /// </summary>
        /// <returns>Populated GameData.</returns>
        private ModOptions LoadSettings()
        {
            try
            {
                // Read the configuration file (path is relative to exe dir).
                using (StreamReader streamReader = new StreamReader(configDir))
                {
                    try
                    {
                        ModOptions gameData = JsonUtility.FromJson <ModOptions>(streamReader.ReadToEnd());
                        return(gameData);
                    }
                    catch (ArgumentNullException ex)
                    {
                        Debug.Log("Argument null exception");
                    }
                    catch (FormatException ex)
                    {
                        Debug.Log("Format Exception");
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Debug.Log("File Not Found Exception");
            }
            catch (IOException ex)
            {
                Debug.Log("General IO Exception");
            }
            catch (Exception ex)
            {
                Debug.Log("Meditation exception: " + ex.Message);
            }

            // If it's made it this far something is wrong, return null.
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Use Monobehaviour's `Initialize` function.
        /// </summary>
        public void Initialize()
        {
            modOptions = this.LoadSettings();

            this.Patch();
        }