Example #1
0
 public override void Update()
 {
     if (this.isServerForObject)
     {
         this.ownerAction = this.action;
     }
     if (this.duck != null && this.ownerAction)
     {
         this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-13f, -4f), 2f);
         this.angle       = Lerp.Float(this.angle, -1f, 0.1f);
         this.handFlip    = true;
         this.handOffset  = Lerp.Vec2(this.handOffset, new Vec2(-3f, -4f), 1f);
         this._canRaise   = false;
     }
     else
     {
         float num = 1f;
         if (this.duck != null)
         {
             this.angle = Lerp.Float(this.angle, 0.0f, 0.1f * num);
         }
         else
         {
             num = 20f;
         }
         this._holdOffset = Lerp.Vec2(this._holdOffset, new Vec2(-2f, 0.0f), num * 2f);
         this.handFlip    = false;
         this.handOffset  = Lerp.Vec2(this.handOffset, new Vec2(0.0f, 0.0f), 1f * num);
         this._canRaise   = true;
     }
     if (this.owner == null && this.level.simulatePhysics)
     {
         if (this._framesSinceThrown == 0)
         {
             this._throwSpin = this.angleDegrees;
         }
         ++this._framesSinceThrown;
         if (this._framesSinceThrown > 15)
         {
             this._framesSinceThrown = 15;
         }
         this.angleDegrees = this._throwSpin;
         bool flag1 = false;
         bool flag2 = false;
         if (((double)Math.Abs(this.hSpeed) + (double)Math.Abs(this.vSpeed) > 2.0 || !this.grounded) && ((double)this.gravMultiplier > 0.0 && !flag2) && !this._grounded)
         {
             if (this.offDir > (sbyte)0)
             {
                 this._throwSpin += (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0);
             }
             else
             {
                 this._throwSpin -= (float)(((double)Math.Abs(this.hSpeed * 2f) + (double)Math.Abs(this.vSpeed)) * 1.0 + 5.0);
             }
             flag1 = true;
         }
         if (!flag1 || flag2)
         {
             this._throwSpin %= 360f;
             if ((double)this._throwSpin < 0.0)
             {
                 this._throwSpin += 360f;
             }
             if (flag2)
             {
                 this._throwSpin = (double)Math.Abs(this._throwSpin - 90f) >= (double)Math.Abs(this._throwSpin + 90f) ? Lerp.Float(-90f, 0.0f, 16f) : Lerp.Float(this._throwSpin, 90f, 16f);
             }
             else if ((double)this._throwSpin > 90.0 && (double)this._throwSpin < 270.0)
             {
                 this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f);
             }
             else
             {
                 if ((double)this._throwSpin > 180.0)
                 {
                     this._throwSpin -= 360f;
                 }
                 else if ((double)this._throwSpin < -180.0)
                 {
                     this._throwSpin += 360f;
                 }
                 this._throwSpin = Lerp.Float(this._throwSpin, 0.0f, 14f);
             }
         }
     }
     else
     {
         this._throwSpin = 0.0f;
     }
     base.Update();
 }
        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);
        }