Example #1
0
        public void Feed(FluidData dat)
        {
            if (this._lava == null && dat.sprite != "" && dat.sprite != null)
            {
                if (this.data.sprite == null)
                {
                    this.data.sprite = dat.sprite;
                }
                this._lava = new SpriteMap(dat.sprite, 16, 16);
                this._lava.AddAnimation("idle", 0.1f, true, 0, 1, 2, 3);
                this._lava.SetAnimation("idle");
                this._lava.center   = new Vec2(8f, 10f);
                this._lavaAlternate = new SpriteMap(dat.sprite, 16, 16);
                this._lavaAlternate.AddAnimation("idle", 0.1f, true, 2, 3, 0, 1);
                this._lavaAlternate.SetAnimation("idle");
                this._lavaAlternate.center = new Vec2(8f, 10f);
            }
            if (this._lightRect == null && Layer.lighting)
            {
                this._lightRect = new WhiteRectangle(this.x, this.y, this.width, this.height, (double)dat.heat <= 0.0);
                Level.Add((Thing)this._lightRect);
            }
            if ((double)dat.amount > 0.0)
            {
                this._framesSinceFeed = 0;
            }
            this.data.Mix(dat);
            this.data.amount = Maths.Clamp(this.data.amount, 0.0f, this.MaxFluidFill());
            this._wide       = this.FeedAmountToDistance(this.data.amount);
            float num1 = this._wide + 4f;

            this._collisionOffset.x = (float)-((double)num1 / 2.0);
            this._collisionSize.x   = num1;
            this.FeedEdges();
            if (this._leftCorner != null && this._rightCorner != null && (double)this._wide > (double)this._rightCorner.corner.x - (double)this._leftCorner.corner.x)
            {
                this._wide = this._rightCorner.corner.x - this._leftCorner.corner.x;
                this.x     = this._leftCorner.corner.x + (float)(((double)this._rightCorner.corner.x - (double)this._leftCorner.corner.x) / 2.0);
            }
            float num2 = this._wide + 4f;

            this._collisionOffset.x = (float)-((double)num2 / 2.0);
            this._collisionSize.x   = num2;
            if (!(this.data.sprite == "water") || this._leftCorner == null)
            {
                return;
            }
            Block block = this._leftCorner.block;

            while (true)
            {
                switch (block)
                {
                case null:
                    goto label_19;

                case SnowTileset _:
                    if ((double)block.left + 2.0 > (double)this.left && (double)block.right - 2.0 < (double)this.right)
                    {
                        (block as SnowTileset).Freeze();
                        break;
                    }
                    break;

                case SnowIceTileset _:
                    if ((double)block.left + 2.0 > (double)this.left && (double)block.right - 2.0 < (double)this.right)
                    {
                        (block as SnowIceTileset).Freeze();
                        break;
                    }
                    break;
                }
                block = block.rightBlock;
            }
            label_19 :;
        }
Example #2
0
 public override void PostDrawLayer(Layer layer)
 {
     if (NetworkDebugger._instances.Count == 0)
     {
         return;
     }
     if (layer == Layer.Console)
     {
         if (NetworkDebugger._interfaces[0].pin || (double)Mouse.xConsole < (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             DevConsoleCore core = DevConsole.core;
             DevConsole.core = NetworkDebugger._instances[0].consoleCore;
             NetworkDebugger._interfaces[0].Draw(NetworkDebugger._instances[0].network);
             DevConsole.core = core;
         }
         else
         {
             NetworkDebugger._interfaces[0].visible = false;
         }
         if (NetworkDebugger._interfaces[1].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 1)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[1].consoleCore;
                 NetworkDebugger._interfaces[1].Draw(NetworkDebugger._instances[1].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[1].visible = false;
         }
         if (NetworkDebugger._interfaces[2].pin || (double)Mouse.xConsole <(double)Layer.Console.width / 2.0 && (double)Mouse.yConsole> (double) Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 2)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[2].consoleCore;
                 NetworkDebugger._interfaces[2].Draw(NetworkDebugger._instances[2].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[2].visible = false;
         }
         if (NetworkDebugger._interfaces[3].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole > (double)Layer.Console.height / 2.0)
         {
             if (NetworkDebugger._instances.Count > 3)
             {
                 DevConsoleCore core = DevConsole.core;
                 DevConsole.core = NetworkDebugger._instances[3].consoleCore;
                 NetworkDebugger._interfaces[3].Draw(NetworkDebugger._instances[3].network);
                 DevConsole.core = core;
             }
         }
         else
         {
             NetworkDebugger._interfaces[3].visible = false;
         }
         if (this._connectionArrow == null)
         {
             this._connectionArrow = new SpriteMap("connectionArrow", 56, 13);
             this._connectionArrow.CenterOrigin();
             this._connectionX = new Sprite("connectionX");
             this._connectionX.CenterOrigin();
         }
         for (int i = 0; i < 4; ++i)
         {
             if (NetworkDebugger._instances.Count > i && NetworkDebugger._instances[i].active)
             {
                 for (int j = 0; j < 4; ++j)
                 {
                     if (i != j && NetworkDebugger._instances.Count > j && NetworkDebugger._instances[j].active)
                     {
                         NetworkConnection networkConnection1 = NetworkDebugger._instances[i].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(j)));
                         NetworkConnection networkConnection2 = NetworkDebugger._instances[j].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(i)));
                         Vec2  vec2_1 = NetworkDebugger._interfaces[i].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  vec2_2 = NetworkDebugger._interfaces[j].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10));
                         Vec2  p2     = vec2_2 - vec2_1;
                         Vec2  vec2_3 = p2.normalized.Rotate(Maths.DegToRad(90f), Vec2.Zero);
                         float num1   = -Maths.PointDirection(Vec2.Zero, p2);
                         float num2   = 0.0f;
                         if (networkConnection1 != null)
                         {
                             float num3 = 0.0f;
                             float num4 = 0.0f;
                             if (networkConnection2 != null)
                             {
                                 num3 = NetworkDebugger.GetReceived(networkConnection1.identifier, networkConnection2.identifier);
                                 num4 = NetworkDebugger.GetSent(networkConnection1.identifier, networkConnection2.identifier);
                                 num2 = 6f;
                             }
                             this._connectionArrow.frame        = networkConnection1.status != ConnectionStatus.Connected ? 0 : 3;
                             this._connectionArrow.angleDegrees = num1;
                             this._connectionArrow.alpha        = 1f;
                             this._connectionArrow.depth        = new Depth(0.92f);
                             Vec2 vec2_4 = (vec2_1 + vec2_2) / 2f + vec2_3 * num2;
                             DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                             if (networkConnection1.status != ConnectionStatus.Disconnecting)
                             {
                                 this._connectionX.depth = new Depth(0.98f);
                                 Vec2 vec2_5 = vec2_4 - p2.normalized * 22f;
                                 if ((double)(Mouse.positionConsole - vec2_5).length < 8.0)
                                 {
                                     this._connectionX.alpha = 1f;
                                     if (this.lefpres)
                                     {
                                         networkConnection1.Disconnect();
                                         SFX.Play("quack");
                                     }
                                 }
                                 else
                                 {
                                     this._connectionX.alpha = 0.4f;
                                 }
                                 DuckGame.Graphics.Draw(this._connectionX, vec2_5.x, vec2_5.y);
                             }
                             if ((double)num4 > 0.0)
                             {
                                 ++this._connectionArrow.frame;
                                 this._connectionArrow.alpha = num4;
                                 this._connectionArrow.depth = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 --this._connectionArrow.frame;
                             }
                             if ((double)num3 > 0.0)
                             {
                                 this._connectionArrow.frame += 2;
                                 this._connectionArrow.alpha  = num3;
                                 this._connectionArrow.depth  = new Depth(0.95f);
                                 DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y);
                                 this._connectionArrow.frame -= 2;
                             }
                         }
                     }
                 }
             }
         }
     }
     base.PostDrawLayer(layer);
 }
Example #3
0
        public override void Activate(DeathCrate c, bool server = true)
        {
            float x    = c.x;
            float ypos = c.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            if (server)
            {
                for (int index = 0; index < 10; ++index)
                {
                    Banana banana = new Banana(c.x, c.y);
                    float  num2   = (float)index / 9f;
                    banana.hSpeed = (float)((double)num2 * 40.0 - 20.0) * Rando.Float(0.5f, 1f);
                    banana.vSpeed = Rando.Float(-3f, -11f);
                    banana.PressAction();
                    Level.Add((Thing)banana);
                }
                Level.Remove((Thing)c);
            }
            Graphics.FlashScreen();
            SFX.Play("explode");
        }
        public override void Update()
        {
            if (this.isServerForObject)
            {
                this.xscale = this.yscale = Maths.CountUp(this.yscale, 0.05f);
                this._fade -= 0.05f;
                if ((double)this._fade < 0.0)
                {
                    Level.Remove((Thing)this);
                }
                this.alpha = Maths.NormalizeSection(this._fade, 0.2f, 0.3f);
                Vec2 p2 = Vec2.Zero;
                if (this._owner.controlledDuck == null && !this._isNotControlRay)
                {
                    p2 = new Vec2((float)Math.Cos((double)this.angle), (float)-Math.Sin((double)this.angle));
                    foreach (IAmADuck amAduck in Level.CheckCircleAll <IAmADuck>(this.position, 3f))
                    {
                        switch (amAduck)
                        {
                        case Duck _:
                            if (!(amAduck as Duck).HasEquipment(typeof(TinfoilHat)) && !((amAduck as Duck).holdObject is MindControlRay))
                            {
                                this._owner.ControlDuck(amAduck as Duck);
                                continue;
                            }
                            continue;

                        case RagdollPart _ when(amAduck as RagdollPart).doll.captureDuck != null:
                            this._owner.ControlDuck((amAduck as RagdollPart).doll.captureDuck);

                            continue;

                        case TrappedDuck _ when(amAduck as TrappedDuck).captureDuck != null:
                            this._owner.ControlDuck((amAduck as TrappedDuck).captureDuck);

                            continue;

                        default:
                            continue;
                        }
                    }
                }
                else
                {
                    if (this._owner.controlledDuck != null)
                    {
                        p2 = this._owner.controlledDuck.cameraPosition - this.position;
                        p2.Normalize();
                        this.angleDegrees = -Maths.PointDirection(Vec2.Zero, p2);
                    }
                    this._isNotControlRay = true;
                }
                ControlWave controlWave = this;
                controlWave.position = controlWave.position + p2 * 2.6f;
            }
            else
            {
                this.xscale = this.yscale = 1f;
                Vec2        vec2        = new Vec2((float)Math.Cos((double)this.angle), (float)-Math.Sin((double)this.angle));
                ControlWave controlWave = this;
                controlWave.position = controlWave.position + vec2 * 2.6f;
            }
        }
Example #5
0
 public override void Update()
 {
     if (this.owner is Duck owner)
     {
         if (this.isServerForObject)
         {
             this.handPitch = owner.inputProfile.leftTrigger;
             this.notePitch = !owner.inputProfile.Down("SHOOT") ? 0.0f : this.handPitch + 0.01f;
         }
         if ((double)this.notePitch != (double)this.prevNotePitch)
         {
             if ((double)this.notePitch != 0.0)
             {
                 int num = (int)Math.Round((double)this.notePitch * 12.0);
                 if (num < 0)
                 {
                     num = 0;
                 }
                 if (num > 12)
                 {
                     num = 12;
                 }
                 if (this.noteSound == null)
                 {
                     this.hitPitch  = this.notePitch;
                     this.noteSound = SFX.Play("sax" + Change.ToString((object)num));
                     Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector));
                 }
                 else
                 {
                     this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.100000001490116), -1f, 1f);
                 }
             }
             else if (this.noteSound != null)
             {
                 this.noteSound.Stop();
                 this.noteSound = (Sound)null;
             }
         }
         if (this._raised)
         {
             this.handAngle       = 0.0f;
             this.handOffset      = new Vec2(0.0f, 0.0f);
             this._holdOffset     = new Vec2(0.0f, 2f);
             this.collisionOffset = new Vec2(-4f, -7f);
             this.collisionSize   = new Vec2(8f, 16f);
             this.OnReleaseAction();
         }
         else
         {
             this.handOffset      = new Vec2((float)(5.0 + (1.0 - (double)this.handPitch) * 2.0), (float)((1.0 - (double)this.handPitch) * 4.0 - 2.0));
             this.handAngle       = (float)((1.0 - (double)this.handPitch) * 0.400000005960464) * (float)this.offDir;
             this._holdOffset     = new Vec2((float)(4.0 + (double)this.handPitch * 2.0), this.handPitch * 2f);
             this.collisionOffset = new Vec2(-1f, -7f);
             this.collisionSize   = new Vec2(2f, 16f);
         }
     }
     else
     {
         this.collisionOffset = new Vec2(-4f, -7f);
         this.collisionSize   = new Vec2(8f, 16f);
     }
     this.prevNotePitch = this.notePitch;
     base.Update();
 }
        public override void Activate(DeathCrate c, bool server = true)
        {
            float x    = c.x;
            float ypos = c.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            if (server)
            {
                for (int index = 0; index < 16; ++index)
                {
                    Level.Add((Thing)SmallFire.New(c.x - 6f + Rando.Float(12f), c.y - 8f + Rando.Float(4f), Rando.Float(12f) - 6f, 2f - Rando.Float(8.5f), firedFrom: ((Thing)c)));
                }
                Level.Remove((Thing)c);
            }
            Graphics.FlashScreen();
            SFX.Play("explode");
        }
Example #7
0
 public override void Update()
 {
     if ((double)this.hitWait > 0.0)
     {
         this.hitWait -= 0.1f;
     }
     else
     {
         this.hitWait = 0.0f;
     }
     this._alternate                = !this._alternate;
     this._scanner.alpha            = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858);
     this._projector.alpha          = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858) * this._projectorAlpha;
     this._currentProjection.alpha  = (float)(0.400000005960464 + (double)this._projectionFlashWave.normalized * 0.600000023841858);
     this._currentProjection.alpha -= this._glitch * 3f;
     this._currentProjection.alpha *= this._projectorAlpha;
     this._double = Maths.CountDown(this._double, 0.15f);
     this._glitch = Maths.CountDown(this._glitch, 0.1f);
     if ((double)Rando.Float(1f) < 0.00999999977648258)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
     }
     if ((double)Rando.Float(1f) < 0.00499999988824129)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
         this._useWave = !this._useWave;
     }
     if ((double)Rando.Float(1f) < 0.00800000037997961)
     {
         this._glitch = 0.3f;
         this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
         this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
         this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
         this._useWave = !this._useWave;
         this._double  = 0.6f + Rando.Float(0.6f);
     }
     this._close.Clear();
     if (this._hoverItem != null && this._hoverItem.owner != null)
     {
         this.BreakHoverBond();
     }
     if (this._hoverItem == null)
     {
         Holdable holdable = Level.Nearest <Holdable>(this.x, this.y);
         if (holdable != null && holdable.owner == null && (holdable != null && holdable.canPickUp) && ((double)holdable.bottom <= (double)this.top && (double)Math.Abs(holdable.hSpeed) + (double)Math.Abs(holdable.vSpeed) < 2.0))
         {
             float num = 999f;
             if (holdable != null)
             {
                 num = (this.position - holdable.position).length;
             }
             if ((double)num < 24.0)
             {
                 this._hoverItem = holdable;
             }
         }
     }
     else if ((double)Math.Abs(this._hoverItem.hSpeed) + (double)Math.Abs(this._hoverItem.vSpeed) > 2.0 || (double)(this._hoverItem.position - this.position).length > 25.0)
     {
         this.BreakHoverBond();
     }
     else
     {
         this._hoverItem.position       = Lerp.Vec2Smooth(this._hoverItem.position, this.position + new Vec2(0.0f, (float)(-12.0 - (double)this._hoverItem.collisionSize.y / 2.0 + (double)(float)this._projectionWave * 2.0)), 0.2f);
         this._hoverItem.vSpeed         = 0.0f;
         this._hoverItem.gravMultiplier = 0.0f;
     }
     foreach (Duck duck in this._level.things[typeof(Duck)])
     {
         if (!duck.dead && (double)(duck.position - this.position).length < 64.0)
         {
             this._close.Add(duck.profile);
             this._closeGlitch = false;
         }
     }
     this._closeWait = Maths.CountDown(this._closeWait, 0.05f);
     for (int index = 0; index < this._close.Count; ++index)
     {
         if (this._close.Count == 1)
         {
             this._closeIndex = 0;
         }
         else if (this._close.Count > 1 && index == this._closeIndex && (double)this._closeWait <= 0.0)
         {
             this._closeIndex             = (this._closeIndex + 1) % this._close.Count;
             this._closeWait              = 1f;
             this._glitch                 = 0.3f;
             this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
             this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
             this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
             this._useWave                = !this._useWave;
             this._double                 = 0.6f + Rando.Float(0.6f);
             break;
         }
     }
     if (this._closeIndex >= this._close.Count)
     {
         this._closeIndex = 0;
     }
     if (this._close.Count == 0)
     {
         if (!this._closeGlitch)
         {
             this._closeWait = 1f;
             this._glitch    = 0.3f;
             this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f);
             this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f);
             this._projectorGlitch.flipH  = (double)Rando.Float(1f) > 0.5;
             this._useWave     = !this._useWave;
             this._double      = 0.6f + Rando.Float(0.6f);
             this._closeGlitch = true;
         }
         this._projectorAlpha    = Maths.CountDown(this._projectorAlpha, 0.1f);
         this._currentProjection = this._none;
     }
     else
     {
         StoredItem storedItem = PurpleBlock.GetStoredItem(this._close[this._closeIndex]);
         this._currentProjection = storedItem.sprite != null ? (!this._served.Contains(this._close[this._closeIndex]) ? storedItem.sprite : (this._alternate ? storedItem.sprite : this._none)) : this._none;
         this._projectorAlpha    = Maths.CountUp(this._projectorAlpha, 0.1f);
     }
     this._projectorGlitch.alpha = this._glitch * this._projectorAlpha;
     base.Update();
 }
Example #8
0
        public void Draw()
        {
            if ((double)this._wait > 1.0)
            {
                bool flag = true;
                for (int index1 = 0; index1 < this._cool.Count; ++index1)
                {
                    if (this._sampleCool[index1] < this._cool[index1])
                    {
                        List <int> cool;
                        int        index2;
                        (cool = this._cool)[index2 = index1] = cool[index2] - 1;
                        flag = false;
                    }
                    else if (this._sampleCool[index1] > this._cool[index1])
                    {
                        List <int> cool;
                        int        index2;
                        (cool = this._cool)[index2 = index1] = cool[index2] + 1;
                        flag = false;
                    }
                    if ((double)this._upScale[index1] > 0.0)
                    {
                        List <float> upScale;
                        int          index2;
                        (upScale = this._upScale)[index2 = index1] = upScale[index2] - 0.05f;
                    }
                }
                if (flag)
                {
                    this._wait += 0.015f;
                    if ((double)this._wait > 2.0)
                    {
                        this._readyToTalk = true;
                    }
                }
            }
            else
            {
                this._wait += 0.01f;
            }
            this._redBar.depth = new Depth(0.2f);
            Graphics.Draw(this._redBar, 30f, 25f);
            this._font.depth = new Depth(0.25f);
            if (DG.isHalloween)
            {
                this._font.Draw("SPOOKY  REPORT", 44f, 28f, Color.White, new Depth(0.25f));
            }
            else
            {
                this._font.Draw("HOTNESS REPORT", 44f, 28f, Color.White, new Depth(0.25f));
            }
            this._blueBar.depth = new Depth(0.1f);
            Graphics.Draw(this._blueBar, 30f, 18f);
            Graphics.DrawRect(new Vec2(20f, 135f), new Vec2(260f, 160f), new Color(12, 90, 182), new Depth(0.1f));
            Vec2           vec2_1 = new Vec2(60f, 50f);
            Vec2           vec2_2 = new Vec2(200f, 150f);
            Vec2           vec2_3 = new Vec2(vec2_2.x - vec2_1.x, vec2_2.y - vec2_1.y);
            List <Profile> active = Profiles.active;
            int            index3 = 0;

            foreach (Profile profile in active)
            {
                float num1   = active.Count != 1 ? (active.Count != 2 ? (float)index3 * (vec2_3.x / (float)(active.Count - 1)) : (float)((double)vec2_3.x / 2.0 - (double)vec2_3.x / 4.0 + (double)index3 * ((double)vec2_3.x / 2.0))) : vec2_3.x / 2f;
                float num2   = (float)(this._cool[index3] + 50) / 250f;
                float num3   = 1f / (float)(this._tempMap.Count - 2);
                int   index1 = (int)((double)num2 * (double)(this._tempMap.Count - 2));
                if (index1 < 0)
                {
                    index1 = 0;
                }
                int   temp = this._tempMap[index1];
                float num4 = Maths.NormalizeSection(num2, num3 * (float)index1, num3 * (float)(index1 + 1));
                int   num5 = (int)((double)this._tempMap[index1] + (double)(this._tempMap[index1 + 1] - this._tempMap[index1]) * (double)num4);
                float num6 = 50f;
                float num7 = num2 + 0.28f;
                float x    = vec2_1.x + num1;
                float y    = (float)((double)vec2_2.y - 32.0 - (double)num7 * (double)num6);
                profile.persona.sprite.depth = new Depth(0.3f);
                profile.persona.sprite.color = Color.White;
                Graphics.Draw(profile.persona.sprite, 0, x, y);
                Vec2 hatPoint = DuckRig.GetHatPoint(profile.persona.sprite.imageIndex);
                profile.team.hat.depth  = new Depth(0.31f);
                profile.team.hat.center = new Vec2(16f, 16f) + profile.team.hatOffset;
                Graphics.Draw(profile.team.hat, profile.team.hat.frame, x + hatPoint.x, y + hatPoint.y);
                Graphics.DrawRect(new Vec2(x - 17f, y + 16f), new Vec2(x + 16f, 160f), profile.persona.colorUsable, new Depth(0.05f));
                string text = num5.ToString() + "=";
                this._font.depth = new Depth(0.25f);
                this._font.Draw(text, new Vec2((float)((double)x - (double)this._font.GetWidth(text) / 2.0 + 3.0), 140f), Color.White, new Depth(0.25f));
                this._icon.depth = new Depth(0.3f);
                this._icon.frame = (int)Math.Floor((double)num2 * 8.98999977111816);
                if (this._icon.frame != this._lastFrame[index3])
                {
                    this._lastFrame[index3] = this._icon.frame;
                    this._upScale[index3]   = 0.5f;
                }
                this._icon.scale = new Vec2(1f + this._upScale[index3]);
                Graphics.Draw((Sprite)this._icon, x, y + 28f);
                ++index3;
            }
        }
Example #9
0
 public static int GetCompressedVec2(Vec2 val, int range = 2147483647)
 {
     if (range != int.MaxValue)
     {
         float num = (float)((int)short.MaxValue / range);
         val.x = Maths.Clamp(val.x, (float)-range, (float)range) * num;
         val.y = Maths.Clamp(val.y, (float)-range, (float)range) * num;
     }
     return((int)((long)(ushort)Maths.Clamp((int)Math.Round((double)val.x), (int)short.MinValue, (int)short.MaxValue) << 16 | (long)(ushort)Maths.Clamp((int)Math.Round((double)val.y), (int)short.MinValue, (int)short.MaxValue)));
 }
 public override void UpdateParts()
 {
     if (!this.doubleUpdating && Input.Down("JUMP"))
     {
         this.doubleUpdating = true;
         this.UpdateParts();
         this.doubleUpdating = false;
     }
     if (!this.down && (double)this.yOffset > -1.0)
     {
         if ((double)this._initialWait < 1.0)
         {
             this._initialWait += 0.06f;
         }
         else if ((double)this._insertCoin < 1.0)
         {
             if (!this._chinged)
             {
                 SFX.Play("ching", pitch: Rando.Float(0.4f, 0.6f));
                 this._chinged = true;
             }
             this._insertCoinInc += 0.008f;
             this._insertCoin    += this._insertCoinInc;
         }
         else
         {
             this._insertCoin = 1f;
             if ((double)this._afterInsertWait < 1.0)
             {
                 this._afterInsertWait += 0.2f;
             }
             else
             {
                 if ((double)this._gachaWait >= 0.200000002980232 && !this.played)
                 {
                     this.played = true;
                     SFX.Play("gachaSound", pitch: Rando.Float(-0.1f, 0.1f));
                 }
                 if (!this._coined && (double)this._gachaWait > 0.200000002980232)
                 {
                     SFX.Play("gachaCoin", pitch: Rando.Float(0.4f, 0.6f));
                     this._coined = true;
                 }
                 this._gachaWait += 0.04f;
                 if ((double)this._gachaWait >= 1.0)
                 {
                     this._gachaWait  = 1f;
                     this.gachaSpeed += 0.25f;
                     if ((double)this.gachaSpeed > 6.0)
                     {
                         this.gachaSpeed = 6f;
                     }
                     this.gachaY += this.gachaSpeed;
                     if ((double)this.gachaY > 50.0 && (double)this.gachaSpeed > 0.0)
                     {
                         if ((double)this.gachaSpeed > 0.800000011920929)
                         {
                             SFX.Play("gachaBounce", pitch: 0.2f);
                         }
                         this.gachaY     = 50f;
                         this.gachaSpeed = (float)(-(double)this.gachaSpeed * 0.400000005960464);
                     }
                     float num = 8f;
                     this._toyVelocity.y += 0.2f;
                     Vec2 toyPosition1 = this._toyPosition;
                     if ((double)toyPosition1.length > (double)num)
                     {
                         Vec2 toyPosition2 = this._toyPosition;
                         this._toyPosition = toyPosition1.normalized * num;
                         Vec2 vec2 = this._toyPosition - toyPosition2;
                         this._toyVelocity += vec2;
                         if ((double)vec2.length > 1.0)
                         {
                             SFX.Play("gachaBounce", pitch: (0.7f + Rando.Float(0.2f)));
                         }
                         this._toyAngleLerp = Maths.PointDirection(Vec2.Zero, this._toyPosition);
                     }
                     Vec2 leftStick = InputProfile.active.leftStick;
                     if (InputProfile.active.lastActiveDevice is Keyboard)
                     {
                         if (InputProfile.active.Down("LEFT"))
                         {
                             leftStick.x = -1f;
                         }
                         if (InputProfile.active.Down("RIGHT"))
                         {
                             leftStick.x = 1f;
                         }
                         if (InputProfile.active.Down("UP"))
                         {
                             leftStick.y = 1f;
                         }
                         if (InputProfile.active.Down("DOWN"))
                         {
                             leftStick.y = -1f;
                         }
                     }
                     this._toyVelocity  += (this._lastStick - leftStick) * new Vec2(2f, -2f);
                     this._lastStick     = leftStick;
                     this._toyVelocity.x = Math.Max(Math.Min(this._toyVelocity.x, 3f), -3f);
                     this._toyVelocity.y = Math.Max(Math.Min(this._toyVelocity.y, 3f), -3f);
                     this._toyPosition  += this._toyVelocity;
                     if (!this.opened)
                     {
                         this._toyAngle  = Lerp.FloatSmooth(this._toyAngle, this._toyAngleLerp, 0.1f);
                         this._eggOffset = Lerp.Vec2Smooth(this._eggOffset, leftStick * 8f, 0.3f);
                     }
                     else
                     {
                         this._toyAngle    = Lerp.FloatSmooth(this._toyAngle, -90f, 0.1f);
                         this._eggOffset   = Lerp.Vec2Smooth(this._eggOffset, Vec2.Zero, 0.3f);
                         this._toyPosition = Lerp.Vec2Smooth(this._toyPosition, Vec2.Zero, 0.3f);
                     }
                     this._openWait += 0.029f;
                     if ((double)this._openWait >= 1.0)
                     {
                         if (!this.didOpenToyCorner)
                         {
                             HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@OPEN TOY");
                             this.didOpenToyCorner = true;
                         }
                         if (Input.Pressed("SELECT") && !this.opened)
                         {
                             this.opened = true;
                             SFX.Play("gachaOpen", pitch: Rando.Float(0.1f, 0.3f));
                             this._gachaEgg.frame += 2;
                         }
                         if (this.opened)
                         {
                             this._swapWait += 0.06f;
                             if ((double)this._swapWait >= 1.0)
                             {
                                 if (!this._swapped)
                                 {
                                     SFX.Play("harp");
                                     HUD.CloseAllCorners();
                                     HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@CONTINUE");
                                     Profiles.experienceProfile.SetNumFurnitures((int)this._contains.index, Profiles.experienceProfile.GetNumFurnitures((int)this._contains.index) + 1);
                                 }
                                 this._starGrow += 0.05f;
                                 this._swapped   = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     this.yOffset = Lerp.FloatSmooth(this.yOffset, this.down ? -250f : 0.0f, 0.4f);
     if (this.down)
     {
         if (this._swapped)
         {
             this.finished = true;
             this.Close();
         }
         else
         {
             this._downWait -= 0.06f;
             if ((double)this._downWait <= 0.0)
             {
                 this._downWait = 1f;
                 this.down      = false;
                 SFX.Play("gachaGet", pitch: -0.4f);
             }
         }
     }
     if (!this.down && this._swapped && Input.Pressed("SELECT"))
     {
         this.played           = false;
         this._gachaWait       = 0.0f;
         this._openWait        = 0.0f;
         this.finished         = false;
         this.opened           = false;
         this._swapWait        = 0.0f;
         this._swapped         = false;
         this._starGrow        = 0.0f;
         this._insertCoin      = 0.0f;
         this._insertCoinInc   = 0.0f;
         this._afterInsertWait = 0.0f;
         this._chinged         = false;
         this.gachaY           = 0.0f;
         this.gachaSpeed       = 0.0f;
         this.doubleUpdating   = false;
         ++this._prizesGiven;
         this._eggOffset       = Vec2.Zero;
         this._toyPosition     = Vec2.Zero;
         this._toyVelocity     = Vec2.Zero;
         this._lastStick       = Vec2.Zero;
         this._toyAngle        = 0.0f;
         this._toyAngleLerp    = 0.0f;
         this._coined          = false;
         this._initialWait     = 0.0f;
         this.didOpenToyCorner = false;
         HUD.CloseAllCorners();
         SFX.Play("resume", 0.6f);
         if (this.prizes.Count > 4)
         {
             this.prizes.RemoveAt(0);
             this.LoadNextPrize();
         }
         else
         {
             this.down     = true;
             this._swapped = true;
         }
     }
     base.UpdateParts();
 }
Example #11
0
        public override void Update()
        {
            this._selectBeam.color = new Color(0.3f, (float)(0.300000011920929 + (double)this._wave2.normalized * 0.200000002980232), (float)(0.5 + (double)this._wave.normalized * 0.300000011920929)) * (1f + this._flash);
            this._flash            = Maths.CountDown(this._flash, 0.1f);
            this._spawnWait       -= 0.025f;
            if ((double)this._spawnWait < 0.0)
            {
                Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave.normalized, false, Color.Cyan * 0.8f));
                Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave2.normalized, true, Color.LightBlue * 0.8f));
                this._spawnWait = 1f;
            }
            using (IEnumerator <Duck> enumerator = Level.CheckRectAll <Duck>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Duck d = enumerator.Current;
                    if (!this._ducks.Any <BeamDuck>((Func <BeamDuck, bool>)(t => t.duck == d)))
                    {
                        float num = (double)d.y >= 100.0 ? 130f : 40f;
                        SFX.Play("stepInBeam");
                        d.immobilized = true;
                        d.crouch      = false;
                        d.sliding     = false;
                        if (d.holdObject != null)
                        {
                            this._guns.Add((Thing)d.holdObject);
                        }
                        d.ThrowItem();
                        d.solid    = false;
                        d.grounded = false;
                        this._ducks.Add(new BeamDuck()
                        {
                            duck        = d,
                            entryHeight = num,
                            leaving     = false,
                            entryDir    = (double)d.x < (double)this.x ? -1 : 1,
                            sin         = new SinWave(0.1f),
                            sin2        = new SinWave(0.05f)
                        });
                        this.entered = true;
                    }
                }
            }
            foreach (Holdable holdable in Level.CheckRectAll <Holdable>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y)))
            {
                if (holdable.owner == null && !this._guns.Contains((Thing)holdable))
                {
                    this._guns.Add((Thing)holdable);
                }
            }
            int   count = this._ducks.Count;
            int   num1  = 0;
            float num2  = (float)((double)this._beamHeight / (double)count / 2.0 + 20.0 * (count > 1 ? 1.0 : 0.0));
            float num3  = (float)(((double)this._beamHeight - (double)num2 * 2.0) / (count > 1 ? (double)(count - 1) : 1.0));

            for (int index = 0; index < this._ducks.Count; ++index)
            {
                BeamDuck duck = this._ducks[index];
                if (duck.leaving)
                {
                    duck.duck.solid  = true;
                    duck.duck.hSpeed = this._leaveLeft ? -4f : 4f;
                    duck.duck.vSpeed = 0.0f;
                    if ((double)Math.Abs(duck.duck.position.x - this.x) > 24.0)
                    {
                        duck.duck.immobilized = false;
                        this._ducks.RemoveAt(index);
                        --index;
                        continue;
                    }
                }
                else
                {
                    duck.duck.position.x = Lerp.FloatSmooth(duck.duck.position.x, this.position.x + (float)duck.sin2 * 1f, 0.2f);
                    duck.duck.position.y = Lerp.FloatSmooth(duck.duck.position.y, (float)((double)num2 + (double)num3 * (double)index + (double)(float)duck.sin * 2.0), 0.08f);
                    duck.duck.vSpeed     = 0.0f;
                    duck.duck.hSpeed     = 0.0f;
                }
                if (!TitleScreen.hasMenusOpen && duck.duck.inputProfile.Pressed("LEFT"))
                {
                    duck.leaving     = true;
                    this._leaveLeft  = true;
                    duck.duck.offDir = (sbyte)-1;
                    this.entered     = false;
                }
                else if (!TitleScreen.hasMenusOpen && duck.duck.inputProfile.Pressed("RIGHT"))
                {
                    duck.leaving     = true;
                    this._leaveLeft  = false;
                    duck.duck.offDir = (sbyte)1;
                    this.entered     = false;
                }
                ++num1;
            }
            for (int index = 0; index < this._guns.Count; ++index)
            {
                Thing gun = this._guns[index];
                gun.vSpeed = 0.0f;
                gun.hSpeed = 0.0f;
                if ((double)Math.Abs(this.position.x - gun.position.x) < 6.0)
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y - 3f), 0.1f);
                    gun.alpha    = Maths.LerpTowards(gun.alpha, 0.0f, 0.1f);
                    if ((double)gun.alpha <= 0.0)
                    {
                        gun.y = -200f;
                        this._guns.RemoveAt(index);
                        --index;
                    }
                }
                else
                {
                    gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y), 0.2f);
                }
            }
            base.Update();
        }
        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);
            }
        }
        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);
        }
Example #14
0
        public override void Update()
        {
            ++this._framesSinceFeed;
            this.fluidWave += 0.1f;
            if ((double)this.data.amount < 9.99999974737875E-05)
            {
                Level.Remove((Thing)this);
            }
            if ((double)this.collisionSize.y > 10.0)
            {
                ++this.bubbleWait;
                if (this.bubbleWait > Rando.Int(15, 25))
                {
                    for (int index = 0; index < (int)Math.Floor((double)this.collisionSize.x / 16.0); ++index)
                    {
                        if ((double)Rando.Float(1f) > 0.850000023841858)
                        {
                            Level.Add((Thing) new TinyBubble(this.left + (float)(index * 16) + Rando.Float(-4f, 4f), this.bottom + Rando.Float(-4f), 0.0f, this.top + 10f));
                        }
                    }
                    this.bubbleWait = 0;
                }
                foreach (PhysicsObject physicsObject in Level.CheckRectAll <PhysicsObject>(this.topLeft, this.bottomRight))
                {
                    physicsObject.sleeping = false;
                }
            }
            FluidPuddle fluidPuddle = Level.CheckLine <FluidPuddle>(new Vec2(this.left, this.y), new Vec2(this.right, this.y), (Thing)this);

            if (fluidPuddle != null && (double)fluidPuddle.data.amount < (double)this.data.amount)
            {
                fluidPuddle.active = false;
                float num1 = Math.Min(fluidPuddle.left, this.left);
                float num2 = Math.Max(fluidPuddle.right, this.right);
                this.x = num1 + (float)(((double)num2 - (double)num1) / 2.0);
                this.Feed(fluidPuddle.data);
                Level.Remove((Thing)fluidPuddle);
            }
            if (this._leftStream != null)
            {
                this._leftStream.Update();
                this._leftStream.onFire = this.onFire;
            }
            if (this._rightStream != null)
            {
                this._rightStream.Update();
                this._rightStream.onFire = this.onFire;
            }
            float distance = this.FeedAmountToDistance(this.data.amount);

            if ((double)this._wide == 0.0)
            {
                this._wide = 1f / 1000f;
            }
            float num = Maths.Clamp(distance / this._wide, 1f, 99999f);

            if (this.onFire)
            {
                this._fireRise = Lerp.FloatSmooth(this._fireRise, 1f, 0.1f, 1.2f);
                if (this._framesSinceFeed > 10)
                {
                    FluidData data = this.data;
                    data.amount = -1f / 1000f;
                    this.Feed(data);
                    if ((double)this.data.amount <= 0.0)
                    {
                        this.data.amount = 0.0f;
                        this.alpha       = Lerp.Float(this.alpha, 0.0f, 0.04f);
                    }
                    else
                    {
                        this.alpha = Lerp.Float(this.alpha, 1f, 0.04f);
                    }
                    if ((double)this.alpha <= 0.0)
                    {
                        Level.Remove((Thing)this);
                    }
                }
            }
            else
            {
                this.alpha = Lerp.Float(this.alpha, 1f, 0.04f);
                if ((double)num < 3.0)
                {
                    FluidData data = this.data;
                    data.amount = -0.0001f;
                    this.Feed(data);
                }
            }
            float depth = this.CalculateDepth();

            if ((double)depth > 4.0 && !this._initializedUpperCorners)
            {
                this._initializedUpperCorners = true;
                foreach (BlockCorner groupCorner in this._block.GetGroupCorners())
                {
                    if (this._leftCorner != null && (double)groupCorner.corner.x == (double)this._leftCorner.corner.x && (double)groupCorner.corner.y < (double)this._leftCorner.corner.y)
                    {
                        if (this._topLeftCorner == null)
                        {
                            this._topLeftCorner = groupCorner;
                        }
                        else if ((double)groupCorner.corner.y > (double)this._topLeftCorner.corner.y)
                        {
                            this._topLeftCorner = groupCorner;
                        }
                    }
                    else if (this._rightCorner != null && (double)groupCorner.corner.x == (double)this._rightCorner.corner.x && (double)groupCorner.corner.y < (double)this._rightCorner.corner.y)
                    {
                        if (this._topRightCorner == null)
                        {
                            this._topRightCorner = groupCorner;
                        }
                        else if ((double)groupCorner.corner.y > (double)this._topRightCorner.corner.y)
                        {
                            this._topRightCorner = groupCorner;
                        }
                    }
                }
            }
            if (this._leftStream != null)
            {
                this._leftStream.position.y = this.y - this._collisionOffset.y;
            }
            if (this._rightStream != null)
            {
                this._rightStream.position.y = this.y - this._collisionOffset.y;
            }
            this._collisionOffset.y = -depth;
            this._collisionSize.y   = depth;
        }
 public override void DrawHoverInfo() => Graphics.DrawLine(this.position, this.position + Maths.AngleToVec(Maths.DegToRad(this.direction)) * (this.firePower * 5f), Color.Red, 2f, new Depth(1f));
Example #16
0
        public override void Update()
        {
            this._waveMult = Lerp.Float(this._waveMult, 0.0f, 0.1f);
            if (this.isServerForObject)
            {
                this._magnetActive = this.action;
            }
            else if (this._magnetActive)
            {
                this._waveMult = 1f;
            }
            if ((double)this._beamSound.Volume > 0.00999999977648258 && this._beamSound.State != SoundState.Playing)
            {
                this._beamSound.Play();
            }
            else if ((double)this._beamSound.Volume < 0.00999999977648258 && this._beamSound.State == SoundState.Playing)
            {
                this._beamSound.Stop();
            }
            this._beamSound.Volume = Maths.LerpTowards(this._beamSound.Volume, this._magnetActive ? 0.1f : 0.0f, 0.1f);
            Vec2 p1_1 = this.Offset(this.barrelOffset);

            if (this._magnetActive && this.duck != null && this.duck.holdObject == this)
            {
                foreach (MagnaLine line in this._lines)
                {
                    line.Update();
                    line.show = true;
                    float num = this._ammoType.range;
                    if (this._hasRay)
                    {
                        num = (this.barrelPosition - this._rayHit).length;
                    }
                    line.dist = num;
                }
                if (this._grabbed == null && this._stuck == null)
                {
                    Holdable holdable1   = (Holdable)null;
                    float    val1        = 0.0f;
                    Vec2     normalized1 = this.barrelVector.Rotate(Maths.DegToRad(90f), Vec2.Zero).normalized;
                    for (int index = 0; index < 3; ++index)
                    {
                        Vec2 p1_2 = p1_1;
                        if (index == 0)
                        {
                            p1_2 += normalized1 * 8f;
                        }
                        else if (index == 2)
                        {
                            p1_2 -= normalized1 * 8f;
                        }
                        foreach (Holdable holdable2 in Level.CheckLineAll <Holdable>(p1_2, p1_2 + this.barrelVector * this._ammoType.range))
                        {
                            if (holdable2 != this && holdable2 != this.owner && (holdable2.owner != this.owner && holdable2.physicsMaterial == PhysicsMaterial.Metal) && (holdable2.duck == null || !(holdable2.duck.holdObject is MagnetGun)))
                            {
                                float length = (holdable2.position - p1_1).length;
                                if (holdable1 == null || (double)length < (double)val1)
                                {
                                    val1      = length;
                                    holdable1 = holdable2;
                                }
                            }
                        }
                    }
                    this._hasRay = false;
                    if (holdable1 != null && Level.CheckLine <Block>(p1_1, holdable1.position) == null)
                    {
                        float num = (float)((1.0 - (double)Math.Min(val1, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929);
                        if (holdable1.owner is Duck duck && !(duck.holdObject is MagnetGun) && (double)num > 0.300000011920929)
                        {
                            if (!(holdable1 is Equipment) || holdable1.equippedDuck == null)
                            {
                                duck.ThrowItem(false);
                                duck = (Duck)null;
                            }
                            else if (holdable1 is TinfoilHat)
                            {
                                duck.Unequip(holdable1 as Equipment);
                                duck = (Duck)null;
                            }
                        }
                        Vec2 normalized2 = (p1_1 - holdable1.position).normalized;
                        // TODO if (duck != null && holdable1 is Equipment)
                        if (false)
                        {
                            if (duck.ragdoll != null)
                            {
                                duck.ragdoll.makeActive = true;
                                return;
                            }
                            if (!(holdable1.owner.realObject is Duck) && Network.isActive)
                            {
                                return;
                            }
                            holdable1.owner.realObject.hSpeed += normalized2.x * num;
                            holdable1.owner.realObject.vSpeed += (float)((double)normalized2.y * (double)num * 4.0);
                            if ((holdable1.owner.realObject as PhysicsObject).grounded && (double)holdable1.owner.realObject.vSpeed > 0.0)
                            {
                                holdable1.owner.realObject.vSpeed = 0.0f;
                            }
                        }
                        else
                        {
                            this.Fondle((Thing)holdable1);
                            holdable1.hSpeed += normalized2.x * num;
                            holdable1.vSpeed += (float)((double)normalized2.y * (double)num * 4.0);
                            if (holdable1.grounded && (double)holdable1.vSpeed > 0.0)
                            {
                                holdable1.vSpeed = 0.0f;
                            }
                        }
                        this._hasRay = true;
                        this._rayHit = holdable1.position;
                        if (this.isServerForObject && (double)val1 < 20.0)
                        {
                            if (holdable1 is Equipment && holdable1.duck != null)
                            {
                                this._grabbed = holdable1.owner.realObject;
                                holdable1.duck.immobilized = true;
                                holdable1.duck.gripped     = true;
                                holdable1.duck.ThrowItem();
                                if (!(holdable1.owner.realObject is Duck))
                                {
                                    holdable1.owner.realObject.owner = this.owner;
                                    Thing.SuperFondle(holdable1.owner.realObject, DuckNetwork.localConnection);
                                }
                            }
                            else
                            {
                                this._grabbed   = (Thing)holdable1;
                                holdable1.owner = this.owner;
                                if (holdable1 is Grenade)
                                {
                                    (holdable1 as Grenade).OnPressAction();
                                }
                            }
                            this.attachIndex += 1;
                        }
                    }
                    else if (this.isServerForObject && this._stuck == null && ((double)Math.Abs(this.angle) < 0.0500000007450581 || (double)Math.Abs(this.angle) > 1.5))
                    {
                        Vec2 position = this.owner.position;
                        if (this.duck.sliding)
                        {
                            position.y += 4f;
                        }
                        Vec2  hitPos;
                        Block block = Level.CheckRay <Block>(position, position + this.barrelVector * this._ammoType.range, out hitPos);
                        this._hasRay = true;
                        this._rayHit = hitPos;
                        if (block != null && block.physicsMaterial == PhysicsMaterial.Metal)
                        {
                            float num    = (float)((1.0 - (double)Math.Min((block.position - position).length, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929);
                            Vec2  vec2   = hitPos - this.duck.position;
                            float length = vec2.length;
                            vec2.Normalize();
                            this.owner.hSpeed += vec2.x * num;
                            this.owner.vSpeed += vec2.y * num;
                            if ((double)length < 20.0)
                            {
                                this._stuck       = block;
                                this._stickPos    = hitPos;
                                this._stickNormal = -this.barrelVector;
                                this.attachIndex += 1;
                            }
                        }
                    }
                }
            }
            else
            {
                if (this.isServerForObject)
                {
                    if (this._grabbed != null)
                    {
                        this._grabbed.angle = 0.0f;
                        if (this._grabbed is Holdable grabbed)
                        {
                            grabbed.owner = (Thing)null;
                            grabbed.ReturnToWorld();
                            this.ReturnItemToWorld((Thing)grabbed);
                        }
                        if (this._grabbed is Duck grabbed2)
                        {
                            grabbed2.immobilized  = false;
                            grabbed2.gripped      = false;
                            grabbed2.crippleTimer = 1f;
                        }
                        this._grabbed.visible       = true;
                        this._grabbed.enablePhysics = true;
                        this._grabbed.hSpeed        = this.barrelVector.x * 5f;
                        this._grabbed.vSpeed        = this.barrelVector.y * 5f;
                        this._grabbed       = (Thing)null;
                        this._collisionSize = new Vec2(14f, this._collisionSize.y);
                    }
                    if (this._stuck != null)
                    {
                        this._stuck = (Block)null;
                        if (this.owner != null && !this._raised)
                        {
                            this.duck._groundValid = 6;
                        }
                    }
                }
                foreach (MagnaLine line in this._lines)
                {
                    line.show = false;
                }
            }
            if (Network.isActive)
            {
                if (this._grabbed != null)
                {
                    if (this._grabbed is TrappedDuck && this._grabbed.connection != this.connection)
                    {
                        this._grabbed = (Thing)(this._grabbed as TrappedDuck)._duckOwner;
                        if (this._grabbed != null)
                        {
                            Duck grabbed2 = this._grabbed as Duck;
                            grabbed2.immobilized = true;
                            grabbed2.gripped     = true;
                            grabbed2.ThrowItem();
                            grabbed2._trapped = (TrappedDuck)null;
                        }
                    }
                    if (this._grabbed is Duck grabbed)
                    {
                        grabbed.isGrabbedByMagnet = true;
                        if (this.isServerForObject)
                        {
                            this.Fondle((Thing)grabbed);
                            this.Fondle((Thing)grabbed.holdObject);
                            foreach (Thing t in grabbed._equipment)
                            {
                                this.Fondle(t);
                            }
                            this.Fondle((Thing)grabbed._ragdollInstance);
                            this.Fondle((Thing)grabbed._trappedInstance);
                            this.Fondle((Thing)grabbed._cookedInstance);
                        }
                    }
                }
                if (this._grabbed == null && this._prevGrabDuck != null && this._prevGrabDuck is Duck)
                {
                    (this._prevGrabDuck as Duck).isGrabbedByMagnet = false;
                }
                this._prevGrabDuck = this._grabbed;
            }
            if (this._grabbed != null && this.owner != null)
            {
                if (this.isServerForObject)
                {
                    this.Fondle(this._grabbed);
                }
                this._grabbed.hSpeed        = this.owner.hSpeed;
                this._grabbed.vSpeed        = this.owner.vSpeed;
                this._grabbed.angle         = this.angle;
                this._grabbed.visible       = false;
                this._grabbed.offDir        = this.offDir;
                this._grabbed.enablePhysics = false;
                this._collisionSize         = new Vec2(16f + this._grabbed.width, this._collisionSize.y);
                if (this._grabbed is Duck grabbed)
                {
                    grabbed.grounded = true;
                    grabbed.sliding  = false;
                    grabbed.crouch   = false;
                }
                else
                {
                    this._grabbed.owner = (Thing)this;
                }
            }
            if (this.localAttachIndex < this.attachIndex)
            {
                for (int index = 0; index < 2; ++index)
                {
                    Level.Add((Thing)SmallSmoke.New(p1_1.x + Rando.Float(-1f, 1f), p1_1.y + Rando.Float(-1f, 1f)));
                }
                SFX.Play("grappleHook");
                for (int index = 0; index < 6; ++index)
                {
                    Level.Add((Thing)Spark.New(p1_1.x - this.barrelVector.x * 2f + Rando.Float(-1f, 1f), p1_1.y - this.barrelVector.y * 2f + Rando.Float(-1f, 1f), this.barrelVector + new Vec2(Rando.Float(-1f, 1f), Rando.Float(-1f, 1f))));
                }
                this.localAttachIndex = this.attachIndex;
            }
            if (this.isServerForObject)
            {
                if (this._magnetActive && this._raised && (this.duck != null && !this.duck.grounded) && this._grabbed == null)
                {
                    this._keepRaised = true;
                }
                else
                {
                    this._keepRaised = false;
                }
                if (this._stuck != null && this.duck != null)
                {
                    if ((double)this._stickPos.y < (double)this.owner.position.y - 8.0)
                    {
                        this.owner.position = this._stickPos + this._stickNormal * 12f;
                        this._raised        = true;
                        this._keepRaised    = true;
                    }
                    else
                    {
                        this.owner.position = this._stickPos + this._stickNormal * 16f;
                        this._raised        = false;
                        this._keepRaised    = false;
                    }
                    this.owner.hSpeed  = this.owner.vSpeed = 0.0f;
                    this.duck.moveLock = true;
                }
                else if (this._stuck == null && this.duck != null)
                {
                    this.duck.moveLock = false;
                }
                if (this.owner == null && this.prevOwner != null)
                {
                    if (this.prevOwner is Duck prevOwner)
                    {
                        prevOwner.moveLock = false;
                    }
                    this._prevOwner = (Thing)null;
                }
            }
            base.Update();
        }
 public override void Update()
 {
     this._sprite.frame = (int)((double)this._heat * 7.0);
     if (this._equippedDuck != null)
     {
         float num1 = 0.0f;
         this._offset = new Vec2(-3f, 3f);
         this.angle   = 0.0f;
         if (this._equippedDuck.sliding && this._equippedDuck._trapped == null)
         {
             if (this._equippedDuck.offDir > (sbyte)0)
             {
                 this.angle = -1.570796f;
             }
             else
             {
                 this.angle = 1.570796f;
             }
             this._offset.y += 12f;
             num1           -= 6f;
         }
         if (this._equippedDuck.crouch && !this._equippedDuck.sliding)
         {
             this._offset.y += 4f;
         }
         this.collisionOffset = new Vec2(0.0f, -9999f);
         this.collisionSize   = new Vec2(0.0f, 0.0f);
         this.solid           = false;
         PhysicsObject physicsObject1 = (PhysicsObject)this._equippedDuck;
         if (this._equippedDuck._trapped != null)
         {
             physicsObject1 = (PhysicsObject)this._equippedDuck._trapped;
         }
         else if (this._equippedDuck.ragdoll != null && this._equippedDuck.ragdoll.part1 != null)
         {
             physicsObject1 = (PhysicsObject)this._equippedDuck.ragdoll.part1;
         }
         this._sprite.flipH = this._equippedDuck._sprite.flipH;
         if (this._on && (double)this._heat < 1.0)
         {
             if (this._equippedDuck._trapped == null && this._equippedDuck.crouch)
             {
                 this._equippedDuck.sliding = true;
             }
             if (this.isServerForObject)
             {
                 Global.data.jetFuelUsed.valueFloat += Maths.IncFrameTimer();
             }
             this._heat += 11f / 1000f;
             if (physicsObject1 is RagdollPart)
             {
                 float angle = this.angle;
                 this.angle = physicsObject1.angle;
                 Vec2 vec2_1 = this.Offset(new Vec2(0.0f, 8f));
                 Level.Add((Thing) new JetpackSmoke(vec2_1.x, vec2_1.y));
                 this.angle = angle;
                 if ((double)physicsObject1.velocity.length < 7.0)
                 {
                     RagdollPart ragdollPart = physicsObject1 as RagdollPart;
                     ragdollPart.addWeight = 0.2f;
                     this._equippedDuck.ragdoll.jetting = true;
                     float num2   = (float)-((double)physicsObject1.angle - 1.57079637050629);
                     Vec2  vec2_2 = Vec2.Zero;
                     if ((double)this._equippedDuck.inputProfile.leftStick.length > 0.100000001490116)
                     {
                         vec2_2 = new Vec2(this._equippedDuck.inputProfile.leftStick.x, -this._equippedDuck.inputProfile.leftStick.y);
                     }
                     else
                     {
                         vec2_2 = new Vec2(0.0f, 0.0f);
                         if (this._equippedDuck.inputProfile.Down("LEFT"))
                         {
                             --vec2_2.x;
                         }
                         if (this._equippedDuck.inputProfile.Down("RIGHT"))
                         {
                             ++vec2_2.x;
                         }
                         if (this._equippedDuck.inputProfile.Down("UP"))
                         {
                             --vec2_2.y;
                         }
                         if (this._equippedDuck.inputProfile.Down("DOWN"))
                         {
                             ++vec2_2.y;
                         }
                     }
                     if ((double)vec2_2.length < 0.100000001490116)
                     {
                         vec2_2 = new Vec2((float)Math.Cos((double)num2), (float)-Math.Sin((double)num2));
                     }
                     PhysicsObject physicsObject2 = physicsObject1;
                     physicsObject2.velocity = physicsObject2.velocity + vec2_2 * 1.5f;
                     if (ragdollPart.doll != null && ragdollPart.doll.part1 != null && (ragdollPart.doll.part2 != null && ragdollPart.doll.part3 != null))
                     {
                         ragdollPart.doll.part1.extraGravMultiplier = 0.4f;
                         ragdollPart.doll.part2.extraGravMultiplier = 0.4f;
                         ragdollPart.doll.part3.extraGravMultiplier = 0.7f;
                     }
                 }
             }
             else
             {
                 Level.Add((Thing) new JetpackSmoke(this.x, this.y + 8f + num1));
                 if ((double)this.angle > 0.0)
                 {
                     if ((double)physicsObject1.hSpeed < 6.0)
                     {
                         physicsObject1.hSpeed += 0.9f;
                     }
                 }
                 else if ((double)this.angle < 0.0)
                 {
                     if ((double)physicsObject1.hSpeed > -6.0)
                     {
                         physicsObject1.hSpeed -= 0.9f;
                     }
                 }
                 else if ((double)physicsObject1.vSpeed > -4.5)
                 {
                     physicsObject1.vSpeed -= 0.38f;
                 }
             }
         }
         if ((double)this._heat >= 1.0)
         {
             this._on = false;
         }
         if (physicsObject1.grounded)
         {
             if ((double)this._heat > 0.0)
             {
                 this._heat -= 0.25f;
             }
             else
             {
                 this._heat = 0.0f;
             }
         }
     }
     else
     {
         this._sprite.flipH   = false;
         this.collisionOffset = new Vec2(-5f, -5f);
         this.collisionSize   = new Vec2(11f, 12f);
         this.solid           = true;
     }
     base.Update();
 }
        public float CalculateProfileScore(bool log = false)
        {
            List <StatContribution> statContributionList = new List <StatContribution>();
            float num1 = 0.0f;
            float num2 = 0.0f;
            float num3 = 0.0f;
            float num4 = 0.0f;

            if (this.timesSpawned > 0)
            {
                num4 = (float)((double)this.matchesWon / (double)this.timesSpawned * 0.400000005960464);
            }
            float num5 = num1 + num4;

            if ((double)num4 > 0.0)
            {
                num3 += num4;
            }
            else if ((double)num4 < 0.0)
            {
                num2 += num4;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "MAT",
                amount = num4
            });
            if (this.gamesPlayed > 0)
            {
                num4 = (float)((double)this.trophiesWon / (double)this.gamesPlayed * 0.400000005960464);
            }
            float num6 = num5 + num4;

            if ((double)num4 > 0.0)
            {
                num3 += num4;
            }
            else if ((double)num4 < 0.0)
            {
                num2 += num4;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "WON",
                amount = num4
            });
            int num7 = this.timesKilled;

            if (num7 < 1)
            {
                num7 = 1;
            }
            float num8 = (float)Math.Log(1.0 + (double)this.kills / (double)num7) * 0.4f;
            float num9 = num6 + num8;

            if ((double)num8 > 0.0)
            {
                num3 += num8;
            }
            else if ((double)num8 < 0.0)
            {
                num2 += num8;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "KDR",
                amount = num8
            });
            float num10 = (float)((double)Maths.Clamp((DateTime.Now - this.lastPlayed).Days, 0, 60) / 60.0 * 0.5);
            float num11 = num9 + num10;

            if ((double)num10 > 0.0)
            {
                num3 += num10;
            }
            else if ((double)num10 < 0.0)
            {
                num2 += num10;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "LVE",
                amount = num10
            });
            float num12 = (float)Math.Log(1.0 + (double)this.quacks * 9.99999974737875E-05) * 0.4f;
            float num13 = num11 + num12;

            if ((double)num12 > 0.0)
            {
                num3 += num12;
            }
            else if ((double)num12 < 0.0)
            {
                num2 += num12;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "CHR",
                amount = num12
            });
            float num14 = (float)Math.Log(0.75 + (double)this.coolness * 0.025000000372529);
            float num15 = num13 + num14;

            if ((double)num14 > 0.0)
            {
                num3 += num14;
            }
            else if ((double)num14 < 0.0)
            {
                num2 += num14;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "COO",
                amount = num14
            });
            float num16 = (float)Math.Log(1.0 + (double)this.bulletsFired * 9.99999974737875E-05);
            float num17 = num15 + num16;

            if ((double)num16 > 0.0)
            {
                num3 += num16;
            }
            else if ((double)num16 < 0.0)
            {
                num2 += num16;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "SHT",
                amount = num16
            });
            if (this.bulletsFired > 0)
            {
                num16 = (float)((double)this.bulletsThatHit / (double)this.bulletsFired * 0.200000002980232 - 0.100000001490116);
            }
            float num18 = num17 + num16;

            if ((double)num16 > 0.0)
            {
                num3 += num16;
            }
            else if ((double)num16 < 0.0)
            {
                num2 += num16;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "ACC",
                amount = num16
            });
            float num19 = (float)Math.Log(1.0 + (double)this.disarms * 0.000500000023748726) * 0.5f;
            float num20 = num18 + num19;

            if ((double)num19 > 0.0)
            {
                num3 += num19;
            }
            else if ((double)num19 < 0.0)
            {
                num2 += num19;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "DSM",
                amount = num19
            });
            float num21 = -(float)(Math.Log(1.0 + (double)(this.timesLitOnFire + this.timesMindControlled + this.timesNetted + this.timesDisarmed + this.minesSteppedOn + this.fallDeaths) * 0.000500000023748726) * 0.5);
            float num22 = num20 + num21;

            if ((double)num21 > 0.0)
            {
                num3 += num21;
            }
            else if ((double)num21 < 0.0)
            {
                num2 += num21;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "BAD",
                amount = num21
            });
            float num23 = (float)(-((double)Maths.Clamp((DateTime.Now - this.lastWon).Days, 0, 60) / 60.0) * 0.300000011920929);
            float num24 = num22 + num23;

            if ((double)num23 > 0.0)
            {
                num3 += num23;
            }
            else if ((double)num23 < 0.0)
            {
                num2 += num23;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "LOS",
                amount = num23
            });
            float num25 = (float)Math.Log(1.0 + (double)this.timesJumped * 9.99999974737875E-05) * 0.2f;
            float num26 = num24 + num25;

            if ((double)num25 > 0.0)
            {
                num3 += num25;
            }
            else if ((double)num25 < 0.0)
            {
                num2 += num25;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "JMP",
                amount = num25
            });
            float num27 = (float)Math.Log(1.0 + (double)this.timeWithMouthOpen * (1.0 / 1000.0)) * 0.5f;
            float num28 = num26 + num27;

            if ((double)num27 > 0.0)
            {
                num3 += num27;
            }
            else if ((double)num27 < 0.0)
            {
                num2 += num27;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "MTH",
                amount = num27
            });
            float num29 = (float)Math.Log(1.0 + (double)this.timesSwore) * 0.5f;
            float num30 = num28 + num29;

            if ((double)num29 > 0.0)
            {
                num3 += num29;
            }
            else if ((double)num29 < 0.0)
            {
                num2 += num29;
            }
            statContributionList.Add(new StatContribution()
            {
                name   = "SWR",
                amount = num29
            });
            if (log && (double)num30 != 0.0)
            {
                foreach (StatContribution statContribution in statContributionList)
                {
                    float num31 = 0.0f;
                    if ((double)statContribution.amount != 0.0)
                    {
                        num31 = (double)statContribution.amount <= 0.0 ? (float)((double)Math.Abs(statContribution.amount) / (double)Math.Abs(num2) * ((double)Math.Abs(num2) / ((double)num3 + (double)Math.Abs(num2)))) : (float)((double)Math.Abs(statContribution.amount) / (double)Math.Abs(num3) * ((double)num3 / ((double)num3 + (double)Math.Abs(num2))));
                    }
                    if ((double)statContribution.amount < 0.0)
                    {
                        num31 = -num31;
                    }
                    float num32 = 0.5f;
                    float num33 = 0.5f;
                    float r;
                    float g;
                    if ((double)num31 < 0.0)
                    {
                        r = num32 + Math.Abs(num31) * 0.5f;
                        g = num33 - Math.Abs(num31) * 0.5f;
                    }
                    else
                    {
                        g = num33 + Math.Abs(num31) * 0.5f;
                        r = num32 - Math.Abs(num31) * 0.5f;
                    }
                    DevConsole.Log(statContribution.name + ": " + (num31 * 100f).ToString("0.000") + "%", new Color(r, g, 0.0f), 1f);
                }
            }
            return(num30);
        }
 public override void Update()
 {
     base.Update();
     this._sprite.frame = this._owner == null || this._raised ? 0 : 1;
     this._raiseArm     = Lerp.Float(this._raiseArm, 0.0f, 0.05f);
     this._preachWait   = Lerp.Float(this._preachWait, 0.0f, 0.06f);
     this._ringPulse    = Lerp.Float(this._ringPulse, 0.0f, 0.05f);
     if (Network.isActive)
     {
         if (this.isServerForObject)
         {
             if (this.controlling1)
             {
                 Duck duck = this.GetDuck(0);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling1 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling2)
             {
                 Duck duck = this.GetDuck(1);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling2 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling3)
             {
                 Duck duck = this.GetDuck(2);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling3 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling4)
             {
                 Duck duck = this.GetDuck(3);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling4 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
         }
         else
         {
             Duck duck1 = this.GetDuck(0);
             if (duck1 != null)
             {
                 if (this.controlling1)
                 {
                     duck1.listening = true;
                     duck1.Fondle((Thing)duck1.holdObject);
                     foreach (Equipment equipment in duck1._equipment)
                     {
                         duck1.Fondle((Thing)equipment);
                     }
                     duck1.Fondle((Thing)duck1._ragdollInstance);
                     duck1.Fondle((Thing)duck1._trappedInstance);
                     duck1.Fondle((Thing)duck1._cookedInstance);
                 }
                 if (!this.controlling1 && this.prevControlling1)
                 {
                     duck1.listening = false;
                 }
                 this.prevControlling1 = this.controlling1;
             }
             Duck duck2 = this.GetDuck(1);
             if (duck2 != null)
             {
                 if (this.controlling2)
                 {
                     duck2.listening = true;
                     duck2.Fondle((Thing)duck2.holdObject);
                     foreach (Equipment equipment in duck2._equipment)
                     {
                         duck2.Fondle((Thing)equipment);
                     }
                     duck2.Fondle((Thing)duck2._ragdollInstance);
                     duck2.Fondle((Thing)duck2._trappedInstance);
                     duck2.Fondle((Thing)duck2._cookedInstance);
                 }
                 if (!this.controlling2 && this.prevControlling2)
                 {
                     duck2.listening = false;
                 }
                 this.prevControlling2 = this.controlling2;
             }
             Duck duck3 = this.GetDuck(2);
             if (duck3 != null)
             {
                 if (this.controlling3)
                 {
                     duck3.listening = true;
                     duck3.Fondle((Thing)duck3.holdObject);
                     foreach (Equipment equipment in duck3._equipment)
                     {
                         duck3.Fondle((Thing)equipment);
                     }
                     duck3.Fondle((Thing)duck3._ragdollInstance);
                     duck3.Fondle((Thing)duck3._trappedInstance);
                     duck3.Fondle((Thing)duck3._cookedInstance);
                 }
                 if (!this.controlling3 && this.prevControlling3)
                 {
                     duck3.listening = false;
                 }
                 this.prevControlling3 = this.controlling3;
             }
             Duck duck4 = this.GetDuck(3);
             if (duck4 != null)
             {
                 if (this.controlling4)
                 {
                     duck4.listening = true;
                     duck4.Fondle((Thing)duck4.holdObject);
                     foreach (Equipment equipment in duck4._equipment)
                     {
                         duck4.Fondle((Thing)equipment);
                     }
                     duck4.Fondle((Thing)duck4._ragdollInstance);
                     duck4.Fondle((Thing)duck4._trappedInstance);
                     duck4.Fondle((Thing)duck4._cookedInstance);
                 }
                 if (!this.controlling4 && this.prevControlling4)
                 {
                     duck4.listening = false;
                 }
                 this.prevControlling4 = this.controlling4;
             }
         }
     }
     if (this._triggerHeld && this.isServerForObject && (this.duck != null && (double)this._preachWait <= 0.0 & this.duck.quack < 1) && this.duck.grounded)
     {
         if (Network.isActive)
         {
             this._netPreach.Play();
         }
         else
         {
             SFX.Play("preach" + (object)Rando.Int(5), Rando.Float(0.8f, 1f), Rando.Float(-0.2f, -0.3f));
         }
         this.duck.quack = (int)(byte)Rando.Int(12, 30);
         this.duck.profile.stats.timePreaching += (float)this.duck.quack / 0.1f * Maths.IncFrameTimer();
         this._preachWait = Rando.Float(1.8f, 2.5f);
         this._ringPulse  = 1f;
         if (Rando.Int(1) == 0)
         {
             this._raiseArm = Rando.Float(1.2f, 2f);
         }
         Ragdoll ragdoll = Level.Nearest <Ragdoll>(this.x, this.y, (Thing)this);
         if (ragdoll != null && ragdoll.captureDuck != null && (ragdoll.captureDuck.dead && Level.CheckLine <Block>(this.duck.position, ragdoll.position) == null) && (double)(ragdoll.position - this.duck.position).length < (double)this._ammoType.range)
         {
             if (Network.isActive)
             {
                 this.Fondle((Thing)ragdoll.captureDuck);
                 this.Fondle((Thing)ragdoll);
                 Send.Message((NetMessage) new NMLayToRest(ragdoll.captureDuck.profile.networkIndex));
             }
             ragdoll.captureDuck.LayToRest(this.duck.profile);
         }
         foreach (Duck duck in Level.current.things[typeof(Duck)])
         {
             if (duck != this.duck && duck.grounded && (!(duck.holdObject is GoodBook) && Level.CheckLine <Block>(this.duck.position, duck.position) == null) && (double)(duck.position - this.duck.position).length < (double)this._ammoType.range)
             {
                 if (duck.dead)
                 {
                     this.Fondle((Thing)duck);
                     duck.LayToRest(this.duck.profile);
                 }
                 else if (duck.converted != this.duck && this.duck.converted != duck && duck.profile.team != this.duck.profile.team)
                 {
                     if (Network.isActive)
                     {
                         if (duck.profile.networkIndex == (byte)0)
                         {
                             this.controlling1 = true;
                         }
                         if (duck.profile.networkIndex == (byte)1)
                         {
                             this.controlling2 = true;
                         }
                         if (duck.profile.networkIndex == (byte)2)
                         {
                             this.controlling3 = true;
                         }
                         if (duck.profile.networkIndex == (byte)3)
                         {
                             this.controlling4 = true;
                         }
                     }
                     duck.listening = true;
                     this.Fondle((Thing)duck);
                     this.Fondle((Thing)duck.holdObject);
                     foreach (Thing t in duck._equipment)
                     {
                         this.Fondle(t);
                     }
                     this.Fondle((Thing)duck._ragdollInstance);
                     this.Fondle((Thing)duck._trappedInstance);
                     this.Fondle((Thing)duck._cookedInstance);
                     duck.listenTime = 80;
                     if ((double)this.owner.x < (double)duck.x)
                     {
                         duck.offDir = (sbyte)-1;
                     }
                     else
                     {
                         duck.offDir = (sbyte)1;
                     }
                     duck.ThrowItem(false);
                     duck.conversionResistance -= 30;
                     if (duck.conversionResistance <= 0)
                     {
                         duck.ConvertDuck(this.duck.converted != null ? this.duck.converted : this.duck);
                         if (Network.isActive)
                         {
                             Send.Message((NetMessage) new NMConversion(duck.profile.networkIndex, this.duck.profile.networkIndex));
                         }
                         duck.conversionResistance = 50;
                     }
                 }
             }
         }
     }
     this._haloAlpha = Lerp.Float(this._haloAlpha, !this._triggerHeld || this.duck == null || !this.duck.grounded ? 0.0f : 1f, 0.05f);
 }
 public int GetProfileScore() => (int)Math.Round((double)Maths.Clamp((float)((double)this.CalculateProfileScore() * 0.300000011920929 * 250.0), -50f, 200f));
        public override void Update()
        {
            if (this._harpoon == null)
            {
                return;
            }
            if (this.isServerForObject)
            {
                this.ropeData.Clear();
                this.SerializeRope(this._rope);
            }
            else
            {
                this.ropeData.SeekToStart();
                this.DeserializeRope(this._rope);
            }
            if (this._rope != null)
            {
                this._rope.SetServer(this.isServerForObject);
            }
            if (this.isServerForObject && this._equippedDuck != null && this.duck != null)
            {
                if (this.duck._trapped != null)
                {
                    this.Degrapple();
                }
                ATTracer atTracer = new ATTracer();
                float    num      = atTracer.range = this._grappleLength;
                atTracer.penetration = 1f;
                float ang = 45f;
                if (this.offDir < (sbyte)0)
                {
                    ang = 135f;
                }
                if (this._harpoon.inGun)
                {
                    Vec2 p1 = this.Offset(this.barrelOffset);
                    if (this._lagFrames > 0)
                    {
                        --this._lagFrames;
                        if (this._lagFrames == 0)
                        {
                            this._canGrab = false;
                        }
                        else
                        {
                            ang = Maths.PointDirection(p1, this._lastHit);
                        }
                    }
                    atTracer.penetration = 9f;
                    Bullet bullet = new Bullet(p1.x, p1.y, (AmmoType)atTracer, ang, this.owner, tracer: true);
                    this._wallPoint     = bullet.end;
                    this._grappleTravel = bullet.travelDirNormalized;
                    num = (p1 - this._wallPoint).length;
                }
                if ((double)num < (double)this._grappleLength - 2.0 && (double)num <= (double)this._grappleDist + 16.0)
                {
                    this._lastHit = this._wallPoint;
                    this._canGrab = true;
                }
                else if (this._canGrab && this._lagFrames == 0)
                {
                    this._lagFrames = 6;
                    this._wallPoint = this._lastHit;
                }
                else
                {
                    this._canGrab = false;
                }
                this._grappleDist = num;
                if (this.duck.inputProfile.Pressed("JUMP") && this.duck._trapped == null)
                {
                    if (this._harpoon.inGun)
                    {
                        if (!this.duck.grounded && this.duck.framesSinceJump > 6 && this._canGrab && (!(this.duck.holdObject is TV) || (this.duck.holdObject as TV)._ruined || (!(this.duck.holdObject as TV).channel || !this.duck._double) || this.duck._groundValid <= 0))
                        {
                            this._harpoon.Fire(this.wallPoint, this.grappelTravel);
                            this._rope = new Rope(this.barrelPosition.x, this.barrelPosition.y, (Thing)null, (Thing)this._harpoon, (Thing)this.duck, tex: this._ropeSprite, belongsTo: ((Thing)this));
                            Level.Add((Thing)this._rope);
                        }
                    }
                    else
                    {
                        this.Degrapple();
                        this._lagFrames = 0;
                        this._canGrab   = false;
                    }
                }
            }
            base.Update();
            if (this.owner != null)
            {
                this.offDir = this.owner.offDir;
            }
            if (this.duck != null)
            {
                this.duck.grappleMul = false;
            }
            if (!this.isServerForObject || this._rope == null)
            {
                return;
            }
            if (this.owner != null)
            {
                this._rope.position = this.owner.position;
            }
            else
            {
                this._rope.position = this.position;
                if (this.prevOwner != null)
                {
                    PhysicsObject prevOwner = this.prevOwner as PhysicsObject;
                    prevOwner.frictionMult   = 1f;
                    prevOwner.gravMultiplier = 1f;
                    this._prevOwner          = (Thing)null;
                    this.frictionMult        = 1f;
                    this.gravMultiplier      = 1f;
                    if (this.prevOwner is Duck)
                    {
                        (this.prevOwner as Duck).grappleMul = false;
                    }
                }
            }
            if (!this._harpoon.stuck)
            {
                return;
            }
            if (this.duck != null)
            {
                if (!this.duck.grounded)
                {
                    this.duck.frictionMult = 0.0f;
                }
                else
                {
                    this.duck.frictionMult   = 1f;
                    this.duck.gravMultiplier = 1f;
                }
                if ((double)this._rope.properLength > 0.0)
                {
                    if (this.duck.inputProfile.Down("UP") && (double)this._rope.properLength >= 16.0)
                    {
                        this._rope.properLength -= 2f;
                    }
                    if (this.duck.inputProfile.Down("DOWN") && (double)this._rope.properLength <= 256.0)
                    {
                        this._rope.properLength += 2f;
                    }
                    this._rope.properLength = Maths.Clamp(this._rope.properLength, 16f, 256f);
                }
            }
            else if (!this.grounded)
            {
                this.frictionMult = 0.0f;
            }
            else
            {
                this.frictionMult   = 1f;
                this.gravMultiplier = 1f;
            }
            Vec2 vec2_1 = this._rope.attach1.position - this._rope.attach2.position;

            if ((double)this._rope.properLength < 0.0)
            {
                this._rope.properLength = vec2_1.length;
            }
            if ((double)vec2_1.length <= (double)this._rope.properLength)
            {
                return;
            }
            vec2_1 = vec2_1.normalized;
            if (this.duck != null)
            {
                this.duck.grappleMul = true;
                PhysicsObject duck = (PhysicsObject)this.duck;
                if (this.duck.ragdoll != null)
                {
                    this.Degrapple();
                }
                else
                {
                    Vec2 position = duck.position;
                    duck.position = this._rope.attach2.position + vec2_1 * this._rope.properLength;
                    Vec2 vec2_2 = duck.position - duck.lastPosition;
                    duck.hSpeed = vec2_2.x;
                    duck.vSpeed = vec2_2.y;
                }
            }
            else
            {
                Vec2 position = this.position;
                this.position = this._rope.attach2.position + vec2_1 * this._rope.properLength;
                Vec2 vec2_2 = this.position - this.lastPosition;
                this.hSpeed = vec2_2.x;
                this.vSpeed = vec2_2.y;
            }
        }
 public string GetCoolnessString() => this._hotnessStrings[(int)Math.Floor((double)((float)(Maths.Clamp(this.GetProfileScore(), -50, 200) + 50) / 250f) * 8.98999977111816)];
Example #23
0
 public override void OnSoftImpact(MaterialThing with, ImpactedFrom from)
 {
     if (this._fade || with is Gun || (with is AutoPlatform || with is Nubber) && (double)this.vSpeed <= 0.0)
     {
         return;
     }
     if (with is PhysicsObject)
     {
         this._isVolatile = -1f;
     }
     if ((double)this._startWait <= 0.0 && !this._fade && ((double)this.totalImpactPower > 2.0 && ((double)this._isVolatile <= 0.0 || !(with is Block)) || this._blowUp))
     {
         int num1 = 0;
         for (int index = 0; index < 1; ++index)
         {
             ExplosionPart explosionPart = new ExplosionPart(this.x - 8f + Rando.Float(16f), this.y - 8f + Rando.Float(16f));
             explosionPart.xscale *= 0.7f;
             explosionPart.yscale *= 0.7f;
             Level.Add((Thing)explosionPart);
             ++num1;
         }
         SFX.Play("explode");
         for (int index = 0; index < 12; ++index)
         {
             float      num2       = (float)((double)index * 30.0 - 10.0) + Rando.Float(20f);
             ATShrapnel atShrapnel = new ATShrapnel();
             atShrapnel.range = 25f + Rando.Float(10f);
             Level.Add((Thing) new Bullet(this.x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 8.0), this.y - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 8.0), (AmmoType)atShrapnel, num2)
             {
                 firedFrom = (Thing)this
             });
         }
         this._fade = true;
         this.y    += 10000f;
     }
     else
     {
         if (with is IPlatform)
         {
             return;
         }
         if (from == ImpactedFrom.Left || from == ImpactedFrom.Right)
         {
             this.BounceH();
         }
         if (from != ImpactedFrom.Top && from != ImpactedFrom.Bottom)
         {
             return;
         }
         this.BounceV();
     }
 }
 public override void Update()
 {
     if (this.owner is Duck owner)
     {
         if (this.isServerForObject)
         {
             if (owner.inputProfile.Pressed("SHOOT"))
             {
                 this.currentPitch = 2;
             }
             if (owner.inputProfile.Pressed("STRAFE"))
             {
                 this.currentPitch = 0;
             }
             if (owner.inputProfile.Pressed("RAGDOLL"))
             {
                 this.currentPitch = 1;
             }
             if ((double)owner.inputProfile.leftTrigger > 0.5 && !this.leftPressed)
             {
                 this.currentPitch = 2;
                 this.leftPressed  = true;
             }
             if ((double)owner.inputProfile.rightTrigger > 0.5 && !this.rightPressed)
             {
                 this.currentPitch = 3;
                 this.rightPressed = true;
             }
             if (owner.inputProfile.Released("STRAFE") && this.currentPitch == 0)
             {
                 this.currentPitch = -1;
             }
             if (owner.inputProfile.Released("SHOOT") && this.currentPitch == 2)
             {
                 this.currentPitch = -1;
             }
             if (owner.inputProfile.Released("RAGDOLL") && this.currentPitch == 1)
             {
                 this.currentPitch = -1;
             }
             if ((double)owner.inputProfile.leftTrigger <= 0.5)
             {
                 if (this.currentPitch == 2 && this.leftPressed)
                 {
                     this.currentPitch = -1;
                 }
                 this.leftPressed = false;
             }
             if ((double)owner.inputProfile.rightTrigger <= 0.5)
             {
                 if (this.currentPitch == 3 && this.rightPressed)
                 {
                     this.currentPitch = -1;
                 }
                 this.rightPressed = false;
             }
             this.notePitch = this.currentPitch < 0 || this._raised ? 0.0f : (float)((double)this.currentPitch / 3.0 + 0.00999999977648258);
         }
         if ((double)this.notePitch != (double)this.prevNotePitch)
         {
             if ((double)this.notePitch != 0.0)
             {
                 if (this.noteSound != null)
                 {
                     this.noteSound.Stop();
                     this.noteSound = (Sound)null;
                 }
                 int num = (int)Math.Round((double)this.notePitch * 3.0);
                 if (num < 0)
                 {
                     num = 0;
                 }
                 if (num > 12)
                 {
                     num = 12;
                 }
                 if (this.noteSound == null)
                 {
                     this.hitPitch  = this.notePitch;
                     this.noteSound = SFX.Play("trumpet0" + Change.ToString((object)(num + 1)), 0.8f);
                     Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector));
                 }
                 else
                 {
                     this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.00999999977648258), -1f, 1f);
                 }
             }
             else if (this.noteSound != null)
             {
                 this.noteSound.Stop();
                 this.noteSound = (Sound)null;
             }
         }
         if (this._raised)
         {
             this.collisionOffset = new Vec2(4f, -4f);
             this.collisionSize   = new Vec2(8f, 8f);
             this._holdOffset     = new Vec2(0.0f, 0.0f);
             this.handOffset      = new Vec2(0.0f, 0.0f);
             this.OnReleaseAction();
         }
         else
         {
             this.collisionOffset = new Vec2(-6f, -4f);
             this.collisionSize   = new Vec2(8f, 8f);
             this._holdOffset     = new Vec2(10f, -2f);
             this.handOffset      = new Vec2(5f, -2f);
         }
     }
     else
     {
         this.leftPressed     = false;
         this.rightPressed    = false;
         this.currentPitch    = -1;
         this.collisionOffset = new Vec2(-6f, -4f);
         this.collisionSize   = new Vec2(8f, 8f);
         this._holdOffset     = new Vec2(6f, 2f);
     }
     this.prevNotePitch = this.notePitch;
     base.Update();
 }
 public override void Update()
 {
     if (this._explodeFrames < 0)
     {
         float x    = this.x;
         float ypos = this.y - 2f;
         Level.Add((Thing) new ExplosionPart(x, ypos));
         int num1 = 6;
         if (Graphics.effectsLevel < 2)
         {
             num1 = 3;
         }
         for (int index = 0; index < num1; ++index)
         {
             float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
             float num2 = Rando.Float(12f, 20f);
             Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
         }
         this._explodeFrames = 4;
     }
     else
     {
         --this._explodeFrames;
         if (this._explodeFrames != 0)
         {
             return;
         }
         float         x          = this.x;
         float         num1       = this.y - 2f;
         List <Bullet> varBullets = new List <Bullet>();
         for (int index = 0; index < 20; ++index)
         {
             float           num2            = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
             ATPropExplosion atPropExplosion = new ATPropExplosion();
             atPropExplosion.range = 60f + Rando.Float(18f);
             Bullet bullet = new Bullet(x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 6.0), num1 - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 6.0), (AmmoType)atPropExplosion, num2);
             bullet.firedFrom = (Thing)this;
             varBullets.Add(bullet);
             Level.Add((Thing)bullet);
         }
         if (Network.isActive)
         {
             Send.Message((NetMessage) new NMExplodingProp(varBullets), NetMessagePriority.ReliableOrdered);
             varBullets.Clear();
         }
         Graphics.flashAdd = 1.3f;
         Layer.Game.darken = 1.3f;
         foreach (Window window in Level.CheckCircleAll <Window>(this.position, 40f))
         {
             if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
             {
                 window.Destroy((DestroyType) new DTImpact((Thing)this));
             }
         }
         SFX.Play("explode");
         Level.Remove((Thing)this);
     }
 }
        public override void Activate(DeathCrate c, bool server = true)
        {
            float x    = c.x;
            float ypos = c.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            if (server)
            {
                for (int index = 0; index < 8; ++index)
                {
                    Present present = new Present(c.x, c.y);
                    float   num2    = (float)index / 7f;
                    present.hSpeed = (float)((double)num2 * 30.0 - 15.0) * Rando.Float(0.5f, 1f);
                    present.vSpeed = Rando.Float(-3f, -11f);
                    Level.Add((Thing)present);
                }
                for (int index = 0; index < 4; ++index)
                {
                    Flower flower = new Flower(c.x, c.y);
                    float  num2   = (float)index / 3f;
                    flower.hSpeed = (float)((double)num2 * 20.0 - 10.0) * Rando.Float(0.5f, 1f);
                    flower.vSpeed = Rando.Float(-3f, -11f);
                    Level.Add((Thing)flower);
                }
                Level.Remove((Thing)c);
            }
            Graphics.FlashScreen();
            SFX.Play("harp");
        }
        public override void Activate(DeathCrate c, bool server = true)
        {
            float x    = c.x;
            float ypos = c.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            if (server)
            {
                for (int index = 0; index < 18; ++index)
                {
                    float  deg  = (float)index * 22.5f;
                    double num2 = (double)Rando.Float(8f, 14f);
                    Level.Add((Thing) new QuadLaserBullet(c.x, c.y, new Vec2((float)Math.Cos((double)Maths.DegToRad(deg)), (float)-Math.Sin((double)Maths.DegToRad(deg)))));
                }
                Level.Remove((Thing)c);
            }
            Graphics.FlashScreen();
            SFX.Play("explode");
        }
        public override void Update()
        {
            if (!this._opening && this.opened && Editor.gamepadMode)
            {
                if (this._gridMenu != null && this._gridMenu.opened || this._saveMenu != null && this._saveMenu.opened || (this._newMenu != null && this._newMenu.opened || this._quitMenu != null && this._quitMenu.opened) || this._uploadMenu != null && this._uploadMenu.opened)
                {
                    return;
                }
                if (Input.Pressed("UP"))
                {
                    this.opened = false;
                    if (this.owner is ContextMenu owner)
                    {
                        owner._opening = true;
                        foreach (ToolbarButton button in this._buttons)
                        {
                            button.hover = false;
                        }
                        Editor.infoText = "";
                        return;
                    }
                }
                if (Input.Pressed("DOWN"))
                {
                    this.opened = false;
                    if (this.owner is ContextMenu owner)
                    {
                        ++owner.selectedIndex;
                        foreach (ToolbarButton button in this._buttons)
                        {
                            button.hover = false;
                        }
                        Editor.infoText = "";
                        return;
                    }
                }
                if (Input.Pressed("LEFT"))
                {
                    --this._selectedIndex;
                }
                else if (Input.Pressed("RIGHT"))
                {
                    ++this._selectedIndex;
                }
                this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._buttons.Count - 1);
                int num = 0;
                foreach (ToolbarButton button in this._buttons)
                {
                    if (this._selectedIndex == num)
                    {
                        button.hover    = true;
                        Editor.infoText = button.hoverText;
                        if (Input.Pressed("SELECT"))
                        {
                            this.ButtonPressed(button);
                        }
                    }
                    else
                    {
                        button.hover = false;
                    }
                    ++num;
                }
            }
            float x = this.position.x;

            this._newButton.x = x;
            this._newButton.y = this.position.y;
            float num1 = x + 18f;

            this._saveButton.x = num1;
            this._saveButton.y = this.position.y;
            float num2 = num1 + 18f;

            this._loadButton.x = num2;
            this._loadButton.y = this.position.y;
            float num3 = num2 + 18f;

            this._playButton.x = num3;
            this._playButton.y = this.position.y;
            float num4 = num3 + 18f;

            this._gridButton.x = num4;
            this._gridButton.y = this.position.y;
            if (Steam.IsInitialized())
            {
                num4 += 18f;
                this._steamButton.x = num4;
                this._steamButton.y = this.position.y;
            }
            this._quitButton.x = num4 + 18f;
            this._quitButton.y = this.position.y;
            foreach (Thing button in this._buttons)
            {
                button.DoUpdate();
            }
            base.Update();
        }
 public override void Update()
 {
     if (this._testMode)
     {
         this._wait += Maths.IncFrameTimer();
         if (Keyboard.Pressed(Keys.F5) || (double)this._wait > 0.1)
         {
             this._wait = 0.0f;
             try
             {
                 this._tie        = new SpriteMap((Tex2D)ContentPack.LoadTexture2D("tieTest.png"), 64, 64);
                 this._tie.center = new Vec2(26f, 27f);
             }
             catch (Exception ex)
             {
             }
         }
     }
     DuckGame.Graphics.fadeAdd = Lerp.Float(DuckGame.Graphics.fadeAdd, 0.0f, 0.01f);
     if (Main.isDemo && this._skip && !this._firedSkipLogic)
     {
         this._firedSkipLogic = true;
         Vote.CloseVoting();
         HUD.CloseAllCorners();
         this.DoSkip();
     }
     if ((double)DuckGame.Graphics.fade > 0.990000009536743 && !this._skip && Vote.Passed(VoteType.Skip))
     {
         this._skip = true;
     }
     if (this._talker.finished || !HighlightLevel._cancelSkip && this._skip && !Main.isDemo)
     {
         this._done -= 0.04f;
     }
     DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, (double)this._done < 0.0 ? 0.0f : 1f, 0.02f);
     if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && (this._talker.finished || this._skip))
     {
         if (this._endOfHighlights || this._skip)
         {
             Vote.CloseVoting();
             Level.current = (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true);
         }
         else
         {
             Level.current = (Level) new HighlightPlayback(4);
         }
     }
     if (this._state == TVState.ShowPedestals)
     {
         this._waitZoom -= 0.008f;
         if ((double)this._waitZoom < 0.00999999977648258)
         {
             this._waitZoom     = 0.0f;
             this._desiredState = TVState.ShowNewscaster;
         }
     }
     if (this._state == TVState.ShowHotness && this._hotness.ready)
     {
         this._talker.Resume();
     }
     if (this._state == TVState.ShowInterview)
     {
         this._interviewWait -= 0.02f;
         if ((double)this._interviewWait < 0.0 && !this._askedQuestion)
         {
             this._talker.InsertLine(Script.winner() + "! To what do you attribute your success?", this._interviewIndex);
             this._talker.Resume();
             this._askedQuestion = true;
         }
     }
     this._cameraOffset.x = Lerp.Float(this._cameraOffset.x, HighlightLevel._image != null ? 20f : 0.0f, 2f);
     this._talker.active  = this._talker.visible = this._state != TVState.ShowPedestals;
     if (this._state == this._desiredState)
     {
         return;
     }
     this._talker.active = false;
     this._transition.PlaySwipe();
     if (!this._transition.doTransition)
     {
         return;
     }
     this._state = this._desiredState;
 }
Example #30
0
        // Token: 0x0600254F RID: 9551
        protected bool OnDestroybam(DestroyType type = null)
        {
            if (!base.isServerForObject)
            {
                return(false);
            }
            ATRCShrapnel shrap = new ATRCShrapnel();

            shrap.MakeNetEffect(this.position, false);
            List <Bullet> firedBullets = new List <Bullet>();

            for (int i = 0; i < 20; i++)
            {
                float dir = (float)i * 18f - 5f + Rando.Float(10f);
                shrap       = new ATRCShrapnel();
                shrap.range = 55f + Rando.Float(14f);
                Bullet bullet = new Bullet(base.x + (float)(Math.Cos((double)Maths.DegToRad(dir)) * 6.0), base.y - (float)(Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                bullet.firedFrom = this;
                firedBullets.Add(bullet);
                Level.Add(bullet);
            }
            if (Network.isActive)
            {
                Send.Message(new NMFireGun(null, firedBullets, 0, false, 4, false), NetMessagePriority.ReliableOrdered, null);
                firedBullets.Clear();
            }
            Level.Remove(this);
            return(true);
        }