/// <summary>
        /// Init the configuration
        /// </summary>
        public static void InitConfig()
        {
            // Store modded values
            DefaultOptions.StoreAllModded();

            if (config.data != null)
            {
                config.DataToOptions();

                // Remove unneeded options
                List <VehicleOptions> optionsList = new List <VehicleOptions>();

                for (uint i = 0; i < config.options.Length; i++)
                {
                    if (config.options[i] != null && config.options[i].prefab != null)
                    {
                        optionsList.Add(config.options[i]);
                    }
                }

                config.options = optionsList.ToArray();
            }
            else if (File.Exists(m_fileName))
            {
                // Import config
                ImportConfig();
                return;
            }
            else
            {
                DebugUtils.Log("No configuration found. Default values will be used.");
            }

            // Checking for new vehicles
            CompileVehiclesList();

            // Checking for conflicts
            DefaultOptions.CheckForConflicts();

            // Update existing vehicles
            new EnumerableActionThread(VehicleOptions.UpdateCapacityUnits);
            new EnumerableActionThread(VehicleOptions.UpdateBackEngines);

            DebugUtils.Log("Configuration initialized");
            LogVehicleListSteamID();
        }
Esempio n. 2
0
/// <summary>
/// Init the Vehicle Data Configuration (not the Mod Configuration)A
/// </summary>
        public static void InitVehicleDataConfig()
        {
            // Store modded values
            DefaultOptions.StoreAllModded();

            if (config.data != null)
            {
                config.DataToOptions();

                // Remove unneeded options
                List <VehicleOptions> optionsList = new List <VehicleOptions>();

                for (uint i = 0; i < config.options.Length; i++)
                {
                    if (config.options[i] != null && config.options[i].prefab != null)
                    {
                        optionsList.Add(config.options[i]);
                    }
                }

                config.options = optionsList.ToArray();
            }
            else if (File.Exists(m_VehicleSettingsFile))
            {
                // Import config from Standard Filename
                ImportVehicleDataConfig();
                return;
            }
            else
            {
                // If Configuration has not been found, try to find the old config file
                if (File.Exists(m_OldConfigFileName))

                {
                    Logging.Message("Old vehicle configuration file found. Importing  old values and converting to Filename: " + Path.Combine(m_OldSettingsDir, m_OldConfigFileName));

                    m_VehicleSettingsFile = m_OldConfigFileName;

                    // Import config from Old Filename and export to the new filename
                    ImportVehicleDataConfig();

                    m_VehicleSettingsFile = Path.Combine(m_UserSettingsDir, m_VehicleConfigFileName);
                    config.Serialize(m_VehicleSettingsFile);

                    Logging.Message("Old vehicle configuration file converted to new file. New Filename: " + m_VehicleSettingsFile);

                    return;
                }

                else
                {
                    // No config file has been found at all...
                    Logging.Message("No vehicle configuration found. Default values will be used.");
                }
            }

            // Checking for new vehicles
            CompileVehiclesList();

            // Checking for conflicts
            DefaultOptions.CheckForConflicts();

            // Update existing vehicles
            SimulationManager.instance.AddAction(VehicleOptions.UpdateCapacityUnits);
            SimulationManager.instance.AddAction(VehicleOptions.UpdateBackEngines);

            Logging.Message("Vehicle Configuration initialized");
            LogVehicleListSteamID();
        }