Esempio n. 1
0
 public WeatherPattern(WeatherSystem ws, string name, float chance)
 {
     this.ws     = ws;
     api         = ws.api;
     this.Name   = name;
     this.Chance = chance;
 }
Esempio n. 2
0
        public WeatherSimulation(WeatherSystem ws)
        {
            this.ws        = ws;
            rand           = new Random(ws.api.World.Seed);
            BlendedAmbient = new AmbientModifier().EnsurePopulated();

            if (ws.api.Side == EnumAppSide.Client)
            {
                ws.capi.Ambient.CurrentModifiers.InsertBefore("serverambient", "weather", BlendedAmbient);
            }

            WeatherPattern ClearSky = new WeatherPatternClearSky(ws, "ClearSky", 1);

            ClearSky.Ambient.FogDensity = new WeightedFloat(2 / 2000f, 1);

            WeatherPattern CumulusClouds = new WeatherPattern(ws, "Cumulus Clouds", 1)
            {
                CloudDensityNoise       = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudDensityOffsetNoise = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudOffsetYNoise       = new SimplexNoise(new double[] { 2 }, new double[] { 1.5 }, rand.Next())
            };

            WeatherPattern StratusClouds = CumulusClouds.Clone();

            StratusClouds.Name = "Stratus Clouds";
            StratusClouds.Ambient.FlatFogYPos    = new WeightedFloat(25, 1);
            StratusClouds.Ambient.FlatFogDensity = new WeightedFloat(6 / 250f, 1);
            StratusClouds.Ambient.FogDensity     = new WeightedFloat(10 / 2000f, 1);
            StratusClouds.Chance = 0.35f;

            WeatherPattern CumulusCloudsWithFlatMist = CumulusClouds.Clone();

            CumulusCloudsWithFlatMist.Name = "Cumulus Clouds + Flat dense Mist";
            CumulusCloudsWithFlatMist.Ambient.FlatFogYPos    = new WeightedFloat(5, 1);
            CumulusCloudsWithFlatMist.Ambient.FlatFogDensity = new WeightedFloat(-100 / 250f, 1);
            CumulusCloudsWithFlatMist.BeginUse += () =>
            {
                CumulusCloudsWithFlatMist.Ambient.FlatFogDensity.Value = (-50 - 100 * (float)(rand.NextDouble() * rand.NextDouble())) / 300f;
                CumulusCloudsWithFlatMist.Ambient.FlatFogYPos.Value    = 1 + 7 * (float)rand.NextDouble();
            };

            CumulusCloudsWithFlatMist.ChanceOfWeatherChange = 0.008f;
            CumulusCloudsWithFlatMist.Chance = 0.1f;

            WeatherPattern CumulusCloudsWithTallMist = CumulusClouds.Clone();

            CumulusCloudsWithTallMist.Name = "Cumulus Clouds + Tall dense Mist";
            CumulusCloudsWithTallMist.Ambient.FlatFogYPos    = new WeightedFloat(40, 1);
            CumulusCloudsWithTallMist.Ambient.FlatFogDensity = new WeightedFloat(-30 / 250f, 1);
            CumulusCloudsWithTallMist.BeginUse += () => {
                CumulusCloudsWithTallMist.Ambient.FlatFogDensity.Value = (-50 - 50 * (float)(rand.NextDouble() * rand.NextDouble())) / 2000f;
                CumulusCloudsWithTallMist.Ambient.FlatFogYPos.Value    = 30 + 30 * (float)rand.NextDouble();
            };
            CumulusCloudsWithTallMist.ChanceOfWeatherChange = 0.008f;
            CumulusCloudsWithTallMist.Chance = 0.05f;

            WeatherPattern CumulusCloudsWithFog = CumulusClouds.Clone();

            CumulusCloudsWithFog.Name = "Cumulus Clouds + Fog";
            CumulusCloudsWithFog.Ambient.FogDensity = new WeightedFloat(40 / 2000f, 1);
            CumulusCloudsWithFog.BeginUse          += () => { CumulusCloudsWithFog.Ambient.FogDensity.Value = (10 + 30 * (float)rand.NextDouble()) / 2000f; };
            CumulusCloudsWithFog.Chance             = 0.35f;

            WeatherPattern NimboStratusClouds = new WeatherPattern(ws, "Nimbostratus Clouds", 1)
            {
                CloudDensityNoise       = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudDensityOffsetNoise = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudOffsetYNoise       = new SimplexNoise(new double[] { 2 }, new double[] { 1.5 }, rand.Next())
            };

            WeatherPattern AltoCumulusClouds = new WeatherPattern(ws, "Altocumulus Clouds", 1)
            {
                CloudDensityNoise       = new SimplexNoise(new double[] { 3 }, new double[] { 10 }, rand.Next()),
                CloudDensityOffsetNoise = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudOffsetYNoise       = new SimplexNoise(new double[] { 1 }, new double[] { 1.5 }, rand.Next())
            };


            WeatherPattern CirroCumulusClouds = new WeatherPattern(ws, "Cirrocumulus Clouds", 1)
            {
                CloudDensityNoise       = new SimplexNoise(new double[] { 3 }, new double[] { 10 }, rand.Next()),
                CloudDensityOffsetNoise = new SimplexNoise(new double[] { 4 }, new double[] { 1.5 }, rand.Next()),
                CloudOffsetYNoise       = new SimplexNoise(new double[] { 1 }, new double[] { 1.5 }, rand.Next())
            };

            CirroCumulusClouds.CloudYOffset = 100;

            Patterns = new WeatherPattern[]
            {
                ClearSky, CumulusClouds, CumulusCloudsWithFlatMist, CumulusCloudsWithTallMist, CumulusCloudsWithFog, StratusClouds, NimboStratusClouds, AltoCumulusClouds, CirroCumulusClouds
            };
        }
Esempio n. 3
0
 public WeatherPatternClearSky(WeatherSystem ws, string name, float chance) : base(ws, name, chance)
 {
 }