コード例 #1
0
        private RockWeatherState GetWeatherState(float time, bool lerp = true)
        {
            RockWeatherState rockWeatherState1 = (RockWeatherState)null;
            RockWeatherState rockWeatherState2 = (RockWeatherState)null;
            float            num1 = 0.0f;
            int index             = 0;

            switch (RockWeather._weather)
            {
            case Weather.Sunny:
                num1  = 1f / (float)this.timeOfDayColorMultMap.Count;
                index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMap.Count);
                if (index >= this.timeOfDayColorMultMap.Count)
                {
                    index = this.timeOfDayColorMultMap.Count - 1;
                }
                rockWeatherState1 = this.timeOfDayColorMultMap[index];
                rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMap.Count - 1 ? this.timeOfDayColorMultMap[index + 1] : this.timeOfDayColorMultMap[0];
                break;

            case Weather.Snowing:
                num1  = 1f / (float)this.timeOfDayColorMultMapWinter.Count;
                index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMapWinter.Count);
                if (index >= this.timeOfDayColorMultMapWinter.Count)
                {
                    index = this.timeOfDayColorMultMapWinter.Count - 1;
                }
                rockWeatherState1 = this.timeOfDayColorMultMapWinter[index];
                rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMapWinter.Count - 1 ? this.timeOfDayColorMultMapWinter[index + 1] : this.timeOfDayColorMultMapWinter[0];
                break;

            case Weather.Raining:
                num1  = 1f / (float)this.timeOfDayColorMultMapRaining.Count;
                index = (int)((double)RockWeather._timeOfDay * (double)this.timeOfDayColorMultMapRaining.Count);
                if (index >= this.timeOfDayColorMultMapRaining.Count)
                {
                    index = this.timeOfDayColorMultMapRaining.Count - 1;
                }
                rockWeatherState1 = this.timeOfDayColorMultMapRaining[index];
                rockWeatherState2 = index + 1 <= this.timeOfDayColorMultMapRaining.Count - 1 ? this.timeOfDayColorMultMapRaining[index + 1] : this.timeOfDayColorMultMapRaining[0];
                break;
            }
            float            num2 = Maths.NormalizeSection(RockWeather._timeOfDay, num1 * (float)index, num1 * (float)(index + 1));
            RockWeatherState rockWeatherState3 = new RockWeatherState();

            if (this._lastAppliedState == null)
            {
                this._lastAppliedState = rockWeatherState1.Copy();
            }
            if (lerp)
            {
                float amount = 1f / 1000f;
                rockWeatherState3.add           = Lerp.Vec3(this._lastAppliedState.add, rockWeatherState1.add + (rockWeatherState2.add - rockWeatherState1.add) * num2, amount);
                rockWeatherState3.multiply      = Lerp.Vec3(this._lastAppliedState.multiply, rockWeatherState1.multiply + (rockWeatherState2.multiply - rockWeatherState1.multiply) * num2, amount);
                rockWeatherState3.sky           = Lerp.Vec3(this._lastAppliedState.sky, rockWeatherState1.sky + (rockWeatherState2.sky - rockWeatherState1.sky) * num2, amount);
                rockWeatherState3.lightOpacity  = Lerp.Float(this._lastAppliedState.lightOpacity, rockWeatherState1.lightOpacity + (rockWeatherState2.lightOpacity - rockWeatherState1.lightOpacity) * num2, amount);
                rockWeatherState3.sunPos        = Lerp.Vec2(this._lastAppliedState.sunPos, rockWeatherState1.sunPos + (rockWeatherState2.sunPos - rockWeatherState1.sunPos) * num2, amount);
                rockWeatherState3.sunGlow       = Lerp.Float(this._lastAppliedState.sunGlow, rockWeatherState1.sunGlow + (rockWeatherState2.sunGlow - rockWeatherState1.sunGlow) * num2, amount);
                rockWeatherState3.sunOpacity    = Lerp.Float(this._lastAppliedState.sunOpacity, rockWeatherState1.sunOpacity + (rockWeatherState2.sunOpacity - rockWeatherState1.sunOpacity) * num2, amount);
                rockWeatherState3.rainbowLight  = Lerp.Float(this._lastAppliedState.rainbowLight, rockWeatherState1.rainbowLight + (rockWeatherState2.rainbowLight - rockWeatherState1.rainbowLight) * num2, amount);
                rockWeatherState3.rainbowLight2 = Lerp.Float(this._lastAppliedState.rainbowLight2, rockWeatherState1.rainbowLight2 + (rockWeatherState2.rainbowLight2 - rockWeatherState1.rainbowLight2) * num2, amount);
            }
            else
            {
                rockWeatherState3.add           = rockWeatherState1.add + (rockWeatherState2.add - rockWeatherState1.add) * num2;
                rockWeatherState3.multiply      = rockWeatherState1.multiply + (rockWeatherState2.multiply - rockWeatherState1.multiply) * num2;
                rockWeatherState3.sky           = rockWeatherState1.sky + (rockWeatherState2.sky - rockWeatherState1.sky) * num2;
                rockWeatherState3.lightOpacity  = rockWeatherState1.lightOpacity + (rockWeatherState2.lightOpacity - rockWeatherState1.lightOpacity) * num2;
                rockWeatherState3.sunPos        = rockWeatherState1.sunPos + (rockWeatherState2.sunPos - rockWeatherState1.sunPos) * num2;
                rockWeatherState3.sunGlow       = rockWeatherState1.sunGlow + (rockWeatherState2.sunGlow - rockWeatherState1.sunGlow) * num2;
                rockWeatherState3.sunOpacity    = rockWeatherState1.sunOpacity + (rockWeatherState2.sunOpacity - rockWeatherState1.sunOpacity) * num2;
                rockWeatherState3.rainbowLight  = rockWeatherState1.rainbowLight + (rockWeatherState2.rainbowLight - rockWeatherState1.rainbowLight) * num2;
                rockWeatherState3.rainbowLight2 = rockWeatherState1.rainbowLight2 + (rockWeatherState2.rainbowLight2 - rockWeatherState1.rainbowLight2) * num2;
            }
            this._lastAppliedState = rockWeatherState3;
            return(rockWeatherState3);
        }