private void LoadSettings(ModSettings settings, ModSettingsChange change)
        {
            const string
                style = "Style",
                waterPlantsSection = "WaterPlants",
                grassSection       = "Grass",
                advancedSection    = "Advanced";

            options.WaterPlants = settings.GetBool(waterPlantsSection, "Enabled");
            var properties = new PrototypesProperties()
            {
                GrassHeight = settings.GetTupleFloat(grassSection, "Height"),
                GrassWidth  = settings.GetTupleFloat(grassSection, "Width"),
                NoiseSpread = settings.GetFloat(grassSection, "NoiseSpread"),
                GrassColors = new GrassColors()
                {
                    SpringHealthy       = settings.GetColor(grassSection, "SpringHealthy"),
                    SpringDry           = settings.GetColor(grassSection, "SpringDry"),
                    SummerHealty        = settings.GetColor(grassSection, "SummerHealty"),
                    SummerDry           = settings.GetColor(grassSection, "SummerDry"),
                    FallHealty          = settings.GetColor(grassSection, "FallHealty"),
                    FallDry             = settings.GetColor(grassSection, "FallDry"),
                    SeasonInterpolation = settings.GetBool(grassSection, "SeasonInterpolation")
                },
                UseGrassShader  = !settings.GetBool(style, "Billboard"),
                TextureOverride = settings.GetBool(advancedSection, "TextureOverride")
            };

            var density = new Density()
            {
                GrassThick   = settings.GetTupleInt(grassSection, "ThickDensity"),
                GrassThin    = settings.GetTupleInt(grassSection, "ThinDensity"),
                WaterPlants  = settings.GetTupleInt(waterPlantsSection, "Density"),
                DesertPlants = settings.GetTupleInt(waterPlantsSection, "DesertDensity"),
            };

            switch (settings.GetInt(style, "Stones"))
            {
            case 0:
                options.TerrainStones = false;
                break;

            case 1:
                options.TerrainStones = true;
                density.Rocks         = 2;
                break;

            case 2:
                options.TerrainStones = true;
                density.Rocks         = 4;
                break;
            }

            if (change.HasChanged(style, "Style"))
            {
                switch (settings.GetValue <int>(style, "Style"))
                {
                case 0:
                default:
                    options.GrassStyle = GrassStyle.Classic;
                    break;

                case 1:
                    options.GrassStyle = GrassStyle.Mixed;
                    break;

                case 2:
                    options.GrassStyle = GrassStyle.Full;
                    break;
                }
            }

            if (change.HasChanged(advancedSection))
            {
                options.DetailObjectDistance = settings.GetValue <int>(advancedSection, "DetailDistance");
                string detailDistanceOverride = settings.GetValue <string>(advancedSection, "DetailDistanceOverride");
                if (!string.IsNullOrWhiteSpace(detailDistanceOverride) && int.TryParse(detailDistanceOverride, out int value))
                {
                    options.DetailObjectDistance = value;
                    Debug.Log($"{this}: override detail distance with {value}", this);
                }

                options.DetailObjectDensity = settings.GetValue <float>(advancedSection, "DetailDensity");
                options.FlyingInsects       = settings.GetValue <bool>(advancedSection, "FlyingInsects");
            }

            detailPrototypesManager = new DetailPrototypesManager(mod, transform, options, properties);
            densityManager          = new DensityManager(mod, options, density);

            if (isEnabled)
            {
                RefreshTerrainDetailsAsync();
            }
        }
Пример #2
0
        private void LoadSettings()
        {
            const string
                waterPlantsSection = "WaterPlants",
                grassSection       = "Grass",
                othersSection      = "Others",
                advancedSection    = "Advanced";

            // Load settings
            var settings = Mod.GetSettings();

            // Optional details
            int waterPlantsMode = settings.GetInt(waterPlantsSection, "Mode");

            WaterPlants  = waterPlantsMode != 0;
            WinterPlants = waterPlantsMode == 2;

            // Detail prototypes settings
            var properties = new PrototypesProperties()
            {
                GrassHeight = settings.GetTupleFloat(grassSection, "Height"),
                GrassWidth  = settings.GetTupleFloat(grassSection, "Width"),
                NoiseSpread = settings.GetFloat(grassSection, "NoiseSpread"),
                GrassColors = new GrassColors()
                {
                    SpringHealthy = settings.GetColor(grassSection, "SpringHealthy"),
                    SpringDry     = settings.GetColor(grassSection, "SpringDry"),
                    SummerHealty  = settings.GetColor(grassSection, "SummerHealty"),
                    SummerDry     = settings.GetColor(grassSection, "SummerDry"),
                    FallHealty    = settings.GetColor(grassSection, "FallHealty"),
                    FallDry       = settings.GetColor(grassSection, "FallDry"),
                },
                UseGrassShader    = settings.GetInt(grassSection, "Shader") == 1,
                NoiseSpreadPlants = settings.GetFloat(waterPlantsSection, "NoiseSpread"),
                TextureOverride   = settings.GetBool(advancedSection, "TextureOverride")
            };

            // Detail prototypes density
            var density = new Density()
            {
                GrassThick   = settings.GetTupleInt(grassSection, "ThickDensity"),
                GrassThin    = settings.GetTupleInt(grassSection, "ThinDensity"),
                WaterPlants  = settings.GetTupleInt(waterPlantsSection, "Density"),
                DesertPlants = settings.GetTupleInt(waterPlantsSection, "DesertDensity"),
            };

            switch (settings.GetInt(othersSection, "Flowers"))
            {
            case 0:
                Flowers = false;
                break;

            case 1:
                Flowers         = true;
                density.Flowers = 5;
                density.Bushes  = 2;
                break;

            case 2:
                Flowers         = true;
                density.Flowers = 25;
                density.Bushes  = 7;
                break;

            case 3:
                Flowers         = true;
                density.Flowers = 50;
                density.Bushes  = 15;
                break;
            }

            switch (settings.GetInt(othersSection, "Stones"))
            {
            case 0:
                TerrainStones = false;
                break;

            case 1:
                TerrainStones  = true;
                density.Stones = new Range <int>(2, 6);
                density.Rocks  = 2;
                break;

            case 2:
                TerrainStones  = true;
                density.Stones = new Range <int>(4, 12);
                density.Rocks  = 4;
                break;
            }

            RealisticGrass = settings.GetValue <bool>(grassSection, "Realistic");
            FlyingInsects  = settings.GetValue <bool>(othersSection, "FlyingInsects");

            DetailObjectDistance = settings.GetValue <int>(advancedSection, "DetailDistance");
            DetailObjectDensity  = settings.GetValue <float>(advancedSection, "DetailDensity");

            detailPrototypesManager = new DetailPrototypesManager(properties);
            densityManager          = new DensityManager(density);
        }