Ejemplo n.º 1
0
        public override void OnLoad(ConfigNode node)
        {
            Instance = this;
            GeneratePresets();
            int index = 4;

            if (node.HasValue("newGame"))
            {
                newGame = bool.Parse(node.GetValue("newGame"));
            }

            if (node.HasValue("index"))
            {
                index = int.Parse(node.GetValue("index"));
            }

            dropdown = new GUIDropDown <FARDifficultyAndExactnessSettings>(presetNames.ToArray(),
                                                                           presets.ToArray(),
                                                                           index < 0 ? 2 : index);
            voxelSettings = new FARVoxelSettings();

            if (node.HasValue("numVoxelsControllableVessel"))
            {
                voxelSettings.numVoxelsControllableVessel = int.Parse(node.GetValue("numVoxelsControllableVessel"));
            }
            if (node.HasValue("numVoxelsDebrisVessel"))
            {
                voxelSettings.numVoxelsDebrisVessel = int.Parse(node.GetValue("numVoxelsDebrisVessel"));
            }
            if (node.HasValue("minPhysTicksPerUpdate"))
            {
                voxelSettings.minPhysTicksPerUpdate = int.Parse(node.GetValue("minPhysTicksPerUpdate"));
            }
            if (node.HasValue("useHigherResVoxelPoints"))
            {
                voxelSettings.useHigherResVoxelPoints = bool.Parse(node.GetValue("useHigherResVoxelPoints"));
            }
            if (node.HasValue("use32BitIndices"))
            {
                DebugVoxelMesh.Use32BitIndices = bool.Parse(node.GetValue("use32BitIndices"));
            }

            if (index == -1)
            {
                settings = new FARDifficultyAndExactnessSettings(index);

                if (node.HasValue("fractionTransonicDrag"))
                {
                    settings.fractionTransonicDrag = double.Parse(node.GetValue("fractionTransonicDrag"));
                }
                if (node.HasValue("gaussianVehicleLengthFractionForSmoothing"))
                {
                    settings.gaussianVehicleLengthFractionForSmoothing =
                        double.Parse(node.GetValue("gaussianVehicleLengthFractionForSmoothing"));
                }

                if (node.HasValue("numAreaSmoothingPasses"))
                {
                    settings.numAreaSmoothingPasses = int.Parse(node.GetValue("numAreaSmoothingPasses"));
                }
                if (node.HasValue("numDerivSmoothingPasses"))
                {
                    settings.numDerivSmoothingPasses = int.Parse(node.GetValue("numDerivSmoothingPasses"));
                }


                customSettings = settings;
            }
            else
            {
                settings       = presets[index];
                customSettings = new FARDifficultyAndExactnessSettings(-1);
            }

            currentIndex = index;


            FARLogger.Info("Loading FAR Data");
            flightGUISettings = new List <ConfigNode>();
            if (node.HasNode("FlightGUISettings"))
            {
                foreach (ConfigNode flightGUINode in node.GetNode("FlightGUISettings").nodes)
                {
                    flightGUISettings.Add(flightGUINode);
                }
            }

            FARDebugAndSettings.LoadConfigs(node);
        }
        public override void OnLoad(ConfigNode node)
        {
            GeneratePresets();
            int index = 4;
            if (node.HasValue("newGame"))
                newGame = bool.Parse(node.GetValue("newGame"));

            if (node.HasValue("index"))
                index = int.Parse(node.GetValue("index"));

            dropdown = new GUIDropDown<FARDifficultyAndExactnessSettings>(presetNames.ToArray(), presets.ToArray(), index < 0 ? 2 : index);
            voxelSettings = new FARVoxelSettings();

            if (node.HasValue("numVoxelsControllableVessel"))
                voxelSettings.numVoxelsControllableVessel = int.Parse(node.GetValue("numVoxelsControllableVessel"));
            if (node.HasValue("numVoxelsDebrisVessel"))
                voxelSettings.numVoxelsDebrisVessel = int.Parse(node.GetValue("numVoxelsDebrisVessel"));
            if (node.HasValue("minPhysTicksPerUpdate"))
                voxelSettings.minPhysTicksPerUpdate = int.Parse(node.GetValue("minPhysTicksPerUpdate"));

            if (index == -1)
            {
                settings = new FARDifficultyAndExactnessSettings(index);

                if (node.HasValue("fractionTransonicDrag"))
                    settings.fractionTransonicDrag = double.Parse(node.GetValue("fractionTransonicDrag"));
                if (node.HasValue("gaussianVehicleLengthFractionForSmoothing"))
                    settings.gaussianVehicleLengthFractionForSmoothing = double.Parse(node.GetValue("gaussianVehicleLengthFractionForSmoothing"));

                if (node.HasValue("numAreaSmoothingPasses"))
                    settings.numAreaSmoothingPasses = int.Parse(node.GetValue("numAreaSmoothingPasses"));
                if (node.HasValue("numDerivSmoothingPasses"))
                    settings.numDerivSmoothingPasses = int.Parse(node.GetValue("numDerivSmoothingPasses"));

                customSettings = settings;
            }
            else
            {
                settings = presets[index];
                customSettings = new FARDifficultyAndExactnessSettings(-1);
            }
            currentIndex = index;

            Debug.Log("Loading FAR Data");
            flightGUISettings = new List<ConfigNode>();
            if(node.HasNode("FlightGUISettings"))
            {
                foreach (ConfigNode flightGUINode in node.GetNode("FlightGUISettings").nodes)
                    flightGUISettings.Add(flightGUINode);
            }

            FARDebugAndSettings.LoadConfigs(node);
        }