Example #1
0
 public override void Update()
 {
     if (!this.die)
     {
         SnowParticle snowParticle = this;
         snowParticle.position = snowParticle.position + this.velocity;
         this.z += this.zSpeed;
     }
     else
     {
         this.alpha -= 0.04f;
     }
 }
        public override void Update()
        {
            if (RockWeather.alwaysRainbow)
            {
                RockWeather.rainbowFade = 1f;
                RockWeather.rainbowTime = 1f;
            }
            RockWeather.rainbowFade  = Lerp.Float(RockWeather.rainbowFade, (double)RockWeather.rainbowTime > 0.0 ? 1f : 0.0f, 1f / 1000f);
            RockWeather.rainbowTime -= Maths.IncFrameTimer();
            if (RockWeather._weather != Weather.Sunny)
            {
                RockWeather.rainbowTime -= Maths.IncFrameTimer() * 8f;
            }
            if ((double)RockWeather.rainbowTime < 0.0)
            {
                RockWeather.rainbowTime = 0.0f;
            }
            if (RockWeather.neverRainbow)
            {
                RockWeather.rainbowFade = 0.0f;
            }
            RockWeatherState weatherState = this.GetWeatherState(RockWeather._timeOfDay);

            this.rainbowLight  = weatherState.rainbowLight * RockWeather.rainbowFade;
            this.rainbowLight2 = weatherState.rainbowLight2 * RockWeather.rainbowFade;
            this.ApplyWeatherState(weatherState);
            RockWeather._prevWeatherLerp = Lerp.Float(RockWeather._prevWeatherLerp, 0.0f, 0.05f);
            if (Network.isServer)
            {
                this.wait += 3f / 1000f;
                if ((double)this.wait > 1.0)
                {
                    this.wait = 0.0f;
                    if ((double)RockWeather._weatherTime > 0.100000001490116)
                    {
                        if ((double)RockWeather.snowChance > 0.0 && RockWeather._weather != Weather.Snowing && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.snowChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Snowing;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if ((double)RockWeather.rainChance > 0.0 && RockWeather._weather != Weather.Raining && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.rainChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Raining;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if (RockWeather._weather != Weather.Sunny && (double)Rando.Float(1f) > 0.980000019073486)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            if (RockWeather._weather == Weather.Raining)
                            {
                                if ((double)RockWeather._timeRaining > 900.0 && (double)Rando.Float(1f) > 0.850000023841858 || (double)Rando.Float(1f) > 0.949999988079071)
                                {
                                    RockWeather.rainbowTime = Rando.Float(30f, 240f);
                                }
                                if ((double)Rando.Float(1f) > 0.300000011920929)
                                {
                                    RockWeather.sunshowers = Rando.Float(0.1f, 60f);
                                }
                            }
                            RockWeather._timeRaining = 0.0f;
                            RockWeather._prevWeather = RockWeather._weather;
                            RockWeather._weather     = Weather.Sunny;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                    }
                }
            }
            RockWeather.sunshowers -= Maths.IncFrameTimer();
            if ((double)RockWeather.sunshowers <= 0.0)
            {
                RockWeather.sunshowers = 0.0f;
            }
            switch (RockWeather._weather)
            {
            case Weather.Snowing:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    SnowParticle snowParticle = new SnowParticle(new Vec2(Rando.Float(-100f, 400f), Rando.Float(-500f, -550f)));
                    snowParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)snowParticle);
                }
                this._particleWait -= 0.5f;
                break;

            case Weather.Raining:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    RainParticle rainParticle = new RainParticle(new Vec2(Rando.Float(-100f, 900f), Rando.Float(-500f, -550f)));
                    rainParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)rainParticle);
                }
                --this._particleWait;
                break;

            default:
                if ((double)RockWeather.sunshowers <= 0.0)
                {
                    break;
                }
                goto case Weather.Raining;
            }
            List <WeatherParticle> weatherParticleList = new List <WeatherParticle>();

            foreach (WeatherParticle particle in this._particles)
            {
                particle.Update();
                if ((double)particle.position.y > 0.0)
                {
                    particle.die = true;
                }
                switch (particle)
                {
                case RainParticle _ when(double) particle.z <70.0 && (double)particle.position.y> -62.0:
                    particle.die = true;

                    particle.position.y = -58f;
                    break;

                case RainParticle _ when(double) particle.z <40.0 && (double)particle.position.y> -98.0:
                    particle.die = true;

                    particle.position.y = -98f;
                    break;

                case RainParticle _ when(double) particle.z < 25.0 && ((double)particle.position.x > 175.0 && (double)particle.position.x < 430.0) && ((double)particle.position.y > -362.0 && (double)particle.position.y < -352.0):
                    particle.die = true;

                    particle.position.y = -362f;
                    break;
                }
                if ((double)particle.alpha < 0.00999999977648258)
                {
                    weatherParticleList.Add(particle);
                }
            }
            foreach (WeatherParticle weatherParticle in weatherParticleList)
            {
                this._particles.Remove(weatherParticle);
            }
        }