Esempio n. 1
0
        public static SmallSmoke New(float xpos, float ypos, float depth = 0.8f, float scaleMul = 1f)
        {
            SmallSmoke smallSmoke;

            if (SmallSmoke._objects[SmallSmoke._lastActiveObject] == null)
            {
                smallSmoke = new SmallSmoke();
                SmallSmoke._objects[SmallSmoke._lastActiveObject] = smallSmoke;
            }
            else
            {
                smallSmoke = SmallSmoke._objects[SmallSmoke._lastActiveObject];
            }
            SmallSmoke._lastActiveObject = (SmallSmoke._lastActiveObject + 1) % SmallSmoke.kMaxObjects;
            smallSmoke.Init(xpos, ypos);
            smallSmoke.ResetProperties();
            smallSmoke._sprite.globalIndex = (int)Thing.GetGlobalIndex();
            smallSmoke.globalIndex         = Thing.GetGlobalIndex();
            smallSmoke.depth = (Depth)depth;
            smallSmoke.s1   *= scaleMul;
            smallSmoke.s2   *= scaleMul;
            if (SmallSmoke.shortlife)
            {
                smallSmoke.lifeTake = 0.14f;
            }
            return(smallSmoke);
        }
Esempio n. 2
0
 public override void Update()
 {
     base.Update();
     this._life        = 1f;
     this.angleDegrees = this._spinAngle;
     if ((bool)this._sparkTimer)
     {
         Level.Add((Thing)Spark.New(this.x, this.y - 2f, new Vec2(Rando.Float(-1f, 1f), -0.5f), 0.1f));
     }
     if (!(bool)this._explodeTimer)
     {
         return;
     }
     SFX.Play("littleGun", Rando.Float(0.8f, 1f), Rando.Float(-0.5f, 0.5f));
     for (int index = 0; index < 8; ++index)
     {
         float      num        = (float)((double)index * 45.0 - 5.0) + Rando.Float(10f);
         ATShrapnel atShrapnel = new ATShrapnel();
         atShrapnel.range = 8f + Rando.Float(3f);
         Level.Add((Thing) new Bullet(this.x + (float)(Math.Cos((double)Maths.DegToRad(num)) * 6.0), this.y - (float)(Math.Sin((double)Maths.DegToRad(num)) * 6.0), (AmmoType)atShrapnel, num)
         {
             firedFrom = (Thing)this
         });
     }
     Level.Add((Thing)SmallSmoke.New(this.x, this.y));
     if ((double)Rando.Float(1f) < 0.100000001490116)
     {
         Level.Add((Thing)SmallFire.New(this.x, this.y, 0.0f, 0.0f, firedFrom: ((Thing)this)));
     }
     Level.Remove((Thing)this);
 }
 public override void Update()
 {
     if ((double)Rando.Float(2f) < 0.300000011920929)
     {
         this.vSpeed += Rando.Float(3.5f) - 2f;
     }
     if ((double)Rando.Float(9f) < 0.100000001490116)
     {
         this.vSpeed += Rando.Float(3.1f) - 3f;
     }
     if ((double)Rando.Float(14f) < 0.100000001490116)
     {
         this.vSpeed += Rando.Float(4f) - 5f;
     }
     if ((double)Rando.Float(25f) < 0.100000001490116)
     {
         this.vSpeed += Rando.Float(6f) - 7f;
     }
     Level.Add((Thing)SmallSmoke.New(this.x, this.y));
     if ((double)this.hSpeed > 0.0)
     {
         this._sprite.angleDegrees = 90f;
     }
     else if ((double)this.hSpeed < 0.0)
     {
         this._sprite.angleDegrees = -90f;
     }
     base.Update();
 }
Esempio n. 4
0
        protected override bool OnDestroy(DestroyType type = null)
        {
            this._hitPoints = 0.0f;
            Level.Remove((Thing)this);
            SFX.Play("crateDestroy");
            Vec2 vec2 = Vec2.Zero;

            if (type is DTShot)
            {
                vec2 = (type as DTShot).bullet.travelDirNormalized;
            }
            for (int index = 0; index < 6; ++index)
            {
                Thing thing = (Thing)WoodDebris.New(this.x - 8f + Rando.Float(16f), this.y - 8f + Rando.Float(16f));
                thing.hSpeed = (float)(((double)Rando.Float(1f) > 0.5 ? 1.0 : -1.0) * (double)Rando.Float(3f) + (double)Math.Sign(vec2.x) * 0.5);
                thing.vSpeed = -Rando.Float(1f);
                Level.Add(thing);
            }
            for (int index = 0; index < 5; ++index)
            {
                SmallSmoke smallSmoke = SmallSmoke.New(this.x + Rando.Float(-6f, 6f), this.y + Rando.Float(-6f, 6f));
                smallSmoke.hSpeed += Rando.Float(-0.3f, 0.3f);
                smallSmoke.vSpeed -= Rando.Float(0.1f, 0.2f);
                Level.Add((Thing)smallSmoke);
            }
            return(true);
        }
Esempio n. 5
0
        protected override bool OnDestroy(DestroyType type = null)
        {
            this._hitPoints = 0.0f;
            Level.Remove((Thing)this);
            SFX.Play("glassHit");
            Vec2 hitAngle = Vec2.Zero;

            if (type is DTShot)
            {
                hitAngle = (type as DTShot).bullet.travelDirNormalized;
            }
            for (int index = 0; index < 8; ++index)
            {
                Thing thing = (Thing) new GlassParticle(this.x + Rando.Float(-4f, 4f), this.y + Rando.Float(-4f, 4f), hitAngle);
                Level.Add(thing);
                thing.hSpeed = (float)((double)hitAngle.x * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929));
                thing.vSpeed = (float)((double)hitAngle.y * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929)) - Rando.Float(2f);
                Level.Add(thing);
            }
            for (int index = 0; index < 5; ++index)
            {
                SmallSmoke smallSmoke = SmallSmoke.New(this.x + Rando.Float(-6f, 6f), this.y + Rando.Float(-6f, 6f));
                smallSmoke.hSpeed += Rando.Float(-0.3f, 0.3f);
                smallSmoke.vSpeed -= Rando.Float(0.1f, 0.2f);
                Level.Add((Thing)smallSmoke);
            }
            return(true);
        }
Esempio n. 6
0
 protected override bool OnDestroy(DestroyType type = null)
 {
     if (this._duckOwner == null)
     {
         return(false);
     }
     if (!this.destroyed)
     {
         this._duckOwner.hSpeed = this.hSpeed;
         bool wasKilled = type != null;
         if (!wasKilled && this.jumpCountdown > 0.01f)
         {
             this._duckOwner.vSpeed = Duck.JumpSpeed;
         }
         else
         {
             this._duckOwner.vSpeed = (wasKilled ? (this.vSpeed - 1f) : -3f);
         }
         this._duckOwner.x = base.x;
         this._duckOwner.y = base.y - 10f;
         for (int i = 0; i < 4; i++)
         {
             SmallSmoke s = SmallSmoke.New(base.x + Rando.Float(-4f, 4f), base.y + Rando.Float(-4f, 4f));
             s.hSpeed += this.hSpeed * Rando.Float(0.3f, 0.5f);
             s.vSpeed -= Rando.Float(0.1f, 0.2f);
             Level.Add(s);
         }
         if (this.owner != null)
         {
             Duck d = this.owner as Duck;
             if (d != null)
             {
                 d.holdObject = null;
             }
         }
         if (Network.isActive)
         {
             if (!wasKilled)
             {
                 this._duckOwner.Fondle(this);
                 this.authority += 45;
             }
             this.active  = false;
             this.visible = false;
             this.owner   = null;
         }
         else
         {
             Level.Remove(this);
         }
         if (wasKilled && !this._duckOwner.killingNet)
         {
             this._duckOwner.killingNet = true;
             this._duckOwner.Destroy(type);
         }
         this._duckOwner._trapped = null;
     }
     return(true);
 }
Esempio n. 7
0
        // Token: 0x0600230B RID: 8971
        public void PullEngine()
        {
            float pitch = this.souped ? 0.3f : 0f;

            if (!this._flooded && this._gas > 0f && (this._warmUp > 0.5f || this._engineResistance < 1f))
            {
                SFX.Play("chainsawFire", 1f, 0f, 0f, false);
                this._started    = true;
                this._engineSpin = 1.5f;
                for (int i = 0; i < 2; i++)
                {
                    Level.Add(SmallSmoke.New(base.x + (float)(this.offDir * 4), base.y + 5f));
                }
                this._flooded = false;
                this._flood   = 0f;
            }
            else
            {
                if (this._flooded && this._gas > 0f)
                {
                    SFX.Play("chainsawFlooded", 0.9f, Rando.Float(-0.2f, 0.2f), 0f, false);
                    this._engineSpin = 1.6f;
                }
                else
                {
                    if (this._gas == 0f || Rando.Float(1f) > 0.3f)
                    {
                        SFX.Play("chainsawPull", 1f, pitch, 0f, false);
                    }
                    else
                    {
                        SFX.Play("chainsawFire", 1f, pitch, 0f, false);
                    }
                    this._engineSpin = 0.8f;
                }
                if (Rando.Float(1f) > 0.8f)
                {
                    this._flooded = false;
                    this._flood   = 0f;
                }
            }
            this._engineResistance -= 0.5f;
            if (this._gas > 0f)
            {
                int num = this._flooded ? 4 : 2;
                for (int j = 0; j < num; j++)
                {
                    Level.Add(SmallSmoke.New(base.x + (float)(this.offDir * 4), base.y + 5f));
                }
            }
        }
Esempio n. 8
0
        public override void OnSoftImpact(MaterialThing with, ImpactedFrom from)
        {
            if (Network.isActive && this.connection != DuckNetwork.localConnection)
            {
                return;
            }
            switch (with)
            {
            case Duck duck when !duck.inNet && !duck.dead:
                duck.Netted(this);
                if (duck._trapped != null)
                {
                    for (int index = 0; index < 4; ++index)
                    {
                        SmallSmoke smallSmoke = SmallSmoke.New(duck._trapped.x + Rando.Float(-4f, 4f), duck._trapped.y + Rando.Float(-4f, 4f));
                        smallSmoke.hSpeed += duck._trapped.hSpeed * Rando.Float(0.3f, 0.5f);
                        smallSmoke.vSpeed -= Rando.Float(0.1f, 0.2f);
                        Level.Add((Thing)smallSmoke);
                    }
                }
                if (Recorder.currentRecording == null)
                {
                    break;
                }
                Recorder.currentRecording.LogBonus();
                break;

            case RagdollPart ragdollPart when ragdollPart.doll.captureDuck != null && !ragdollPart.doll.captureDuck.dead:
                Duck captureDuck = ragdollPart.doll.captureDuck;
                this.Fondle((Thing)ragdollPart.doll);
                ragdollPart.doll.Unragdoll();
                captureDuck.Netted(this);
                if (captureDuck._trapped != null)
                {
                    for (int index = 0; index < 4; ++index)
                    {
                        SmallSmoke smallSmoke = SmallSmoke.New(captureDuck._trapped.x + Rando.Float(-4f, 4f), captureDuck._trapped.y + Rando.Float(-4f, 4f));
                        smallSmoke.hSpeed += captureDuck._trapped.hSpeed * Rando.Float(0.3f, 0.5f);
                        smallSmoke.vSpeed -= Rando.Float(0.1f, 0.2f);
                        Level.Add((Thing)smallSmoke);
                    }
                }
                if (Recorder.currentRecording == null)
                {
                    break;
                }
                Recorder.currentRecording.LogBonus();
                break;
            }
        }
Esempio n. 9
0
 protected override bool OnDestroy(DestroyType type = null)
 {
     this._hitPoints = 0.0f;
     for (int index = 0; index < 6; ++index)
     {
         Level.Add((Thing) new GlassParticle(this.x - 8f + Rando.Float(16f), this.y - 8f + Rando.Float(16f), new Vec2(Rando.Float(-2f, 2f), Rando.Float(-2f, 2f))));
     }
     for (int index = 0; index < 5; ++index)
     {
         SmallSmoke smallSmoke = SmallSmoke.New(this.x + Rando.Float(-6f, 6f), this.y + Rando.Float(-6f, 6f));
         smallSmoke.hSpeed += Rando.Float(-0.3f, 0.3f);
         smallSmoke.vSpeed -= Rando.Float(0.1f, 0.2f);
         Level.Add((Thing)smallSmoke);
     }
     SFX.Play("crateDestroy");
     Level.Remove((Thing)this);
     return(true);
 }
Esempio n. 10
0
 public void Land()
 {
   this.landed = true;
   if (this.owner == null)
     SFX.Play("rockHitGround2", 0.7f);
   if (this.flipped > 0)
   {
     for (int index = 0; index < 2; ++index)
       Level.Add((Thing) SmallSmoke.New(this.bottomRight.x, this.bottomRight.y));
   }
   else
   {
     if (this.flipped >= 0)
       return;
     for (int index = 0; index < 2; ++index)
       Level.Add((Thing) SmallSmoke.New(this.bottomLeft.x, this.bottomLeft.y));
   }
 }
Esempio n. 11
0
        public override void OnPressAction()
        {
            if (this.owner == null)
            {
                return;
            }
            Thing owner = this.owner;
            Duck  duck  = this.duck;

            if (duck != null)
            {
                ++duck.profile.stats.presentsOpened;
                this.duck.ThrowItem();
            }
            Level.Remove((Thing)this);
            Level.Add((Thing) new OpenPresent(this.x, this.y, this._sprite.frame));
            for (int index = 0; index < 4; ++index)
            {
                Level.Add((Thing)SmallSmoke.New(this.x + Rando.Float(-2f, 2f), this.y + Rando.Float(-2f, 2f)));
            }
            SFX.Play("harp", 0.8f);
            if (this._contains == (System.Type)null)
            {
                this.Initialize();
            }
            if (!(Editor.CreateThing(this._contains) is Holdable thing))
            {
                return;
            }
            if (Rando.Int(500) == 1 && thing is Gun && (thing as Gun).CanSpawnInfinite())
            {
                (thing as Gun).infiniteAmmoVal = true;
                (thing as Gun).infinite.value  = true;
            }
            thing.x = owner.x;
            thing.y = owner.y;
            Level.Add((Thing)thing);
            if (duck == null)
            {
                return;
            }
            duck.GiveHoldable(thing);
            duck.resetAction = true;
        }
Esempio n. 12
0
        public static SmallSmoke New(float xpos, float ypos)
        {
            SmallSmoke smallSmoke;

            if (SmallSmoke._objects[SmallSmoke._lastActiveObject] == null)
            {
                smallSmoke = new SmallSmoke();
                SmallSmoke._objects[SmallSmoke._lastActiveObject] = smallSmoke;
            }
            else
            {
                smallSmoke = SmallSmoke._objects[SmallSmoke._lastActiveObject];
            }
            SmallSmoke._lastActiveObject = (SmallSmoke._lastActiveObject + 1) % SmallSmoke.kMaxObjects;
            smallSmoke.Init(xpos, ypos);
            smallSmoke.ResetProperties();
            smallSmoke._sprite.globalIndex = (int)Thing.GetGlobalIndex();
            smallSmoke.globalIndex         = Thing.GetGlobalIndex();
            smallSmoke.depth = new Depth(0.8f);
            return(smallSmoke);
        }
Esempio n. 13
0
        public void Spawn()
        {
            if (this.randomSpawn)
            {
                List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables);
                this.contains = physicsObjects[Rando.Int(physicsObjects.Count - 1)];
            }
            this._spawnWait = 0.0f;
            ++this._numSpawned;
            if (!(Editor.CreateThing(this.contains) is PhysicsObject thing))
            {
                return;
            }
            Vec2 vec2 = Maths.AngleToVec(Maths.DegToRad(this.direction)) * this.firePower;

            thing.position = this.position + vec2.normalized * 8f;
            thing.hSpeed   = vec2.x;
            thing.vSpeed   = vec2.y;
            Level.Add((Thing)thing);
            Level.Add((Thing)SmallSmoke.New(thing.x, thing.y));
            Level.Add((Thing)SmallSmoke.New(thing.x, thing.y));
            SFX.Play("netGunFire", Rando.Float(0.9f, 1f), Rando.Float(-0.1f, 0.1f));
            if (thing is Equipment)
            {
                (thing as Equipment).autoEquipTime = 0.5f;
            }
            if (thing is ChokeCollar)
            {
                (thing as ChokeCollar).ball.hSpeed = thing.hSpeed;
                (thing as ChokeCollar).ball.vSpeed = thing.vSpeed;
            }
            if (!(thing is Sword))
            {
                return;
            }
            (thing as Sword)._wasLifted      = true;
            (thing as Sword)._framesExisting = 16;
        }
Esempio n. 14
0
 public override void Update()
 {
     this.impacting.Clear();
     if (this._up && this._popup && this.holdObject is Gun)
     {
         Gun   holdObject = this.holdObject as Gun;
         float num        = 300f;
         if (holdObject.ammoType != null)
         {
             num = holdObject.ammoType.range;
         }
         Vec2 vec2 = this.holdObject.position + new Vec2((float)this.offDir * num, 0.0f);
         foreach (Duck duck in Level.current.things[typeof(Duck)].Where <Thing>((Func <Thing, bool>)(d => !(d is TargetDuck))))
         {
             if ((Collision.Line(this.holdObject.position + new Vec2(0.0f, -5f), vec2 + new Vec2(0.0f, -5f), duck.rectangle) || Collision.Line(this.holdObject.position + new Vec2(0.0f, 5f), vec2 + new Vec2(0.0f, 5f), duck.rectangle)) && Level.CheckLine <Block>(this.holdObject.position, duck.position) == null)
             {
                 this._waitFire -= 0.03f;
                 break;
             }
         }
         bool flag = false;
         if ((double)this._autoFireWait > 0.0)
         {
             this._autoFireWait -= Maths.IncFrameTimer();
             if ((double)this._autoFireWait <= 0.0)
             {
                 flag = true;
             }
         }
         if ((double)this._waitFire <= 0.0 || flag)
         {
             holdObject.PressAction();
             this._waitFire = 1f;
         }
         if ((double)this._waitFire < 1.0)
         {
             this._waitFire += 0.01f;
         }
     }
     this.UpdateCollision();
     this.UpdateSkeleton();
     if ((double)this._hitPoints <= 0.0)
     {
         this.Destroy((DestroyType) new DTCrush((PhysicsObject)null));
     }
     if (!this._up)
     {
         this._timeCount = 0.0f;
         if (this._popup)
         {
             this._upSpeed += 0.1f;
         }
         if (this._stance != TargetStance.Fly)
         {
             this.yscale += this._upSpeed;
             if ((double)this.yscale < 1.0)
             {
                 return;
             }
             this.yscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             this.SpawnHoldObject();
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
         else
         {
             this.xscale += this._upSpeed;
             if ((double)this.xscale < 1.0)
             {
                 return;
             }
             this.xscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
     }
     else
     {
         this._timeCount += Maths.IncFrameTimer();
         if (this._popup && (double)this.time.value != 0.0 && (double)this._timeCount >= (double)this.time.value)
         {
             SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
             this.PopDown();
         }
         else
         {
             if (!this._popup)
             {
                 this._upSpeed += 0.1f;
             }
             if (this._stance != TargetStance.Fly)
             {
                 this.yscale -= this._upSpeed;
                 if ((double)this.yscale >= 0.0)
                 {
                     return;
                 }
                 this.yscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
             else
             {
                 this.xscale -= this._upSpeed;
                 if ((double)this.xscale >= 0.0)
                 {
                     return;
                 }
                 this.xscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
         }
     }
 }
Esempio n. 15
0
        public override void OnHit(bool destroyed, Bullet b)
        {
            if (!b.isLocal)
            {
                return;
            }
            if (destroyed)
            {
                new ATMissileShrapnel().MakeNetEffect(b.position, false);
                Random random = (Random)null;
                if (Network.isActive && b.isLocal)
                {
                    random          = Rando.generator;
                    Rando.generator = new Random(NetRand.currentSeed);
                }
                List <Bullet> varBullets = new List <Bullet>();
                for (int index = 0; index < 12; ++index)
                {
                    float             num = (float)((double)index * 30.0 - 10.0) + Rando.Float(20f);
                    ATMissileShrapnel atMissileShrapnel = new ATMissileShrapnel();
                    atMissileShrapnel.range = 15f + Rando.Float(5f);
                    Vec2   vec2   = new Vec2((float)Math.Cos((double)Maths.DegToRad(num)), (float)Math.Sin((double)Maths.DegToRad(num)));
                    Bullet bullet = new Bullet(b.x + vec2.x * 8f, b.y - vec2.y * 8f, (AmmoType)atMissileShrapnel, num);
                    bullet.firedFrom = (Thing)b;
                    varBullets.Add(bullet);
                    Level.Add((Thing)bullet);
                    Level.Add((Thing)Spark.New(b.x + Rando.Float(-8f, 8f), b.y + Rando.Float(-8f, 8f), vec2 + new Vec2(Rando.Float(-0.1f, 0.1f), Rando.Float(-0.1f, 0.1f))));
                    Level.Add((Thing)SmallSmoke.New(b.x + vec2.x * 8f + Rando.Float(-8f, 8f), b.y + vec2.y * 8f + Rando.Float(-8f, 8f)));
                }
                if (Network.isActive && b.isLocal)
                {
                    Send.Message((NetMessage) new NMFireGun((Gun)null, varBullets, (byte)0, false), NetMessagePriority.ReliableOrdered);
                    varBullets.Clear();
                }
                if (Network.isActive && b.isLocal)
                {
                    Rando.generator = random;
                }
                foreach (Window window in Level.CheckCircleAll <Window>(b.position, 30f))
                {
                    if (b.isLocal)
                    {
                        Thing.Fondle((Thing)window, DuckNetwork.localConnection);
                    }
                    if (Level.CheckLine <Block>(b.position, window.position, (Thing)window) == null)
                    {
                        window.Destroy((DestroyType) new DTImpact((Thing)b));
                    }
                }
                foreach (PhysicsObject physicsObject in Level.CheckCircleAll <PhysicsObject>(b.position, 70f))
                {
                    if (b.isLocal && b.owner == null)
                    {
                        Thing.Fondle((Thing)physicsObject, DuckNetwork.localConnection);
                    }
                    if ((double)(physicsObject.position - b.position).length < 30.0)
                    {
                        physicsObject.Destroy((DestroyType) new DTImpact((Thing)b));
                    }
                    physicsObject.sleeping = false;
                    physicsObject.vSpeed   = -2f;
                }
                HashSet <ushort> varBlocks = new HashSet <ushort>();
                foreach (BlockGroup blockGroup1 in Level.CheckCircleAll <BlockGroup>(b.position, 50f))
                {
                    if (blockGroup1 != null)
                    {
                        BlockGroup   blockGroup2 = blockGroup1;
                        List <Block> blockList   = new List <Block>();
                        foreach (Block block in blockGroup2.blocks)
                        {
                            if (Collision.Circle(b.position, 28f, block.rectangle))
                            {
                                block.shouldWreck = true;
                                if (block is AutoBlock)
                                {
                                    varBlocks.Add((block as AutoBlock).blockIndex);
                                }
                            }
                        }
                        blockGroup2.Wreck();
                    }
                }
                foreach (Block block in Level.CheckCircleAll <Block>(b.position, 28f))
                {
                    switch (block)
                    {
                    case AutoBlock _:
                        block.skipWreck   = true;
                        block.shouldWreck = true;
                        if (block is AutoBlock)
                        {
                            varBlocks.Add((block as AutoBlock).blockIndex);
                            continue;
                        }
                        continue;

                    case Door _:
                    case VerticalDoor _:
                        Level.Remove((Thing)block);
                        block.Destroy((DestroyType) new DTRocketExplosion((Thing)null));
                        continue;

                    default:
                        continue;
                    }
                }
                if (Network.isActive && b.isLocal && varBlocks.Count > 0)
                {
                    Send.Message((NetMessage) new NMDestroyBlocks(varBlocks));
                }
            }
            base.OnHit(destroyed, b);
        }
Esempio n. 16
0
 public override void Update()
 {
     if (Network.isActive && this._prevVisible && !this.visible)
     {
         for (int i = 0; i < 4; i++)
         {
             SmallSmoke s = SmallSmoke.New(base.x + Rando.Float(-4f, 4f), base.y + Rando.Float(-4f, 4f));
             s.hSpeed += this.hSpeed * Rando.Float(0.3f, 0.5f);
             s.vSpeed -= Rando.Float(0.1f, 0.2f);
             Level.Add(s);
         }
     }
     if (this._duckOwner == null)
     {
         return;
     }
     this._framesSinceTransfer++;
     base.Update();
     if (base.y > Level.current.lowestPoint + 100f)
     {
         this.OnDestroy(new DTFall());
     }
     this.jumpCountdown -= Maths.IncFrameTimer();
     this._prevVisible   = this.visible;
     this._shakeInc     += 0.8f;
     this._shakeMult     = Lerp.Float(this._shakeMult, 0f, 0.05f);
     if (Network.isActive && this._duckOwner._trapped == this && !this._duckOwner.isServerForObject && this._duckOwner.inputProfile.Pressed("JUMP", false))
     {
         this._shakeMult = 1f;
     }
     if (this._duckOwner.isServerForObject && this._duckOwner._trapped == this)
     {
         if (!this.visible)
         {
             base.y = -9999f;
         }
         if (!this.infinite)
         {
             this._duckOwner.profile.stats.timeInNet += Maths.IncFrameTimer();
             if (this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult    = 1f;
                 this._trapTime    -= 0.007f;
                 this.jumpCountdown = 0.25f;
             }
             if (base.grounded && this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult = 1f;
                 this._trapTime -= 0.028f;
                 if (this.owner == null)
                 {
                     if (Math.Abs(this.hSpeed) < 1f && this._framesSinceTransfer > 30)
                     {
                         this._duckOwner.Fondle(this);
                     }
                     this.vSpeed -= Rando.Float(0.8f, 1.1f);
                     if (this._duckOwner.inputProfile.Down("LEFT") && this.hSpeed > -1f)
                     {
                         this.hSpeed -= Rando.Float(0.6f, 0.8f);
                     }
                     if (this._duckOwner.inputProfile.Down("RIGHT") && this.hSpeed < 1f)
                     {
                         this.hSpeed += Rando.Float(0.6f, 0.8f);
                     }
                 }
             }
             if (this._duckOwner.inputProfile.Pressed("JUMP", false) && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e.PressAction();
             }
             if (this._duckOwner.inputProfile.Released("JUMP") && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e2 = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e2.ReleaseAction();
             }
             this._trapTime -= 0.0028f;
             if (this._trapTime <= 0f || this._duckOwner.dead)
             {
                 this.OnDestroy(null);
             }
         }
         if (this.owner == null)
         {
             base.depth = this._duckOwner.depth;
         }
         this._duckOwner.position = this.position;
         this._duckOwner.UpdateSkeleton();
     }
 }
        public override void Update()
        {
            if (!this._initLinks)
            {
                this._initLinks = true;
                Vec2 vec2 = new Vec2(0.0f, -1f);
                if (this.direction == 1)
                {
                    vec2 = new Vec2(0.0f, 1f);
                }
                else if (this.direction == 2)
                {
                    vec2 = new Vec2(-1f, 0.0f);
                }
                else if (this.direction == 3)
                {
                    vec2 = new Vec2(1f, 0.0f);
                }
                this._link = Level.CheckRay <Teleporter>(this.position + new Vec2(0.0f, -8f) + vec2 * 20f, this.position + new Vec2(0.0f, -8f) + vec2 * 5000f);
                this._dir  = vec2;
            }
            if (this._link == null)
            {
                return;
            }
            IEnumerable <ITeleport> source = Level.CheckRectAll <ITeleport>(this.topLeft, this.bottomRight);

            for (int index = 0; index < this._teleported.Count; ++index)
            {
                ITeleport teleport = this._teleported[index];
                if (!source.Contains <ITeleport>(teleport))
                {
                    this._teleported.RemoveAt(index);
                    --index;
                }
            }
            foreach (ITeleport teleport1 in source)
            {
                if (this.noduck.value)
                {
                    switch (teleport1)
                    {
                    case Duck _:
                    case Ragdoll _:
                    case RagdollPart _:
                    case TrappedDuck _:
                        continue;
                    }
                }
                ITeleport teleport2 = teleport1;
                if ((teleport2 as Thing).owner == null && (teleport2 as Thing).isServerForObject && (!this._teleported.Contains(teleport2) && !this._teleporting.Contains(teleport2)))
                {
                    this._teleporting.Add(teleport2);
                }
            }
            int num1;

            for (int index1 = 0; index1 < this._teleporting.Count; index1 = num1 + 1)
            {
                Thing thing = this._teleporting[index1] as Thing;
                this._teleporting.RemoveAt(index1);
                for (int index2 = 0; index2 < 2; ++index2)
                {
                    Level.Add((Thing)SmallSmoke.New(thing.position.x + Rando.Float(-8f, 8f), thing.position.y + Rando.Float(-8f, 8f)));
                }
                Vec2 position1 = thing.position;
                thing.position = this._link.position - (this.position - thing.position);
                if (thing is RagdollPart)
                {
                    thing.position.y = this._link.position.y;
                }
                this._link._teleported.Add(thing as ITeleport);
                if (thing is PhysicsObject)
                {
                    if ((double)thing.hSpeed > 0.0)
                    {
                        thing.position.x = this._link.position.x + 8f;
                    }
                    else
                    {
                        thing.position.x = this._link.position.x - 8f;
                    }
                }
                for (int index2 = 0; index2 < 2; ++index2)
                {
                    Level.Add((Thing)SmallSmoke.New(thing.position.x + Rando.Float(-8f, 8f), thing.position.y + Rando.Float(-8f, 8f)));
                }
                num1 = index1 - 1;
                Vec2 vec2      = position1;
                Vec2 position2 = thing.position;
                if (thing is Duck && (thing as Duck).sliding)
                {
                    vec2.y      += 9f;
                    position2.y += 9f;
                }
                if ((double)this._dir.y != 0.0)
                {
                    vec2.x      = this.position.x;
                    position2.x = this._link.position.x;
                }
                float num2 = Math.Max((double)this._dir.x != 0.0 ? thing.height : thing.width, 8f);
                this.warpLines.Add(new WarpLine()
                {
                    start = vec2,
                    end   = position2,
                    lerp  = 0.6f,
                    wide  = num2
                });
                thing.OnTeleport();
            }
        }
Esempio n. 18
0
        // Token: 0x0600230C RID: 8972
        public override void Update()
        {
            base.Update();
            float num = 1f;

            if (this.souped)
            {
                num = 1.3f;
            }
            if (this._swordSwing.finished)
            {
                this._swordSwing.speed = 0f;
            }
            if (this._hitWait > 0)
            {
                this._hitWait--;
            }
            if (this._gas < 0.01f)
            {
                this.ammo = 0;
            }
            this._framesExisting++;
            if (this._framesExisting > 100)
            {
                this._framesExisting = 100;
            }
            float pitch = this.souped ? 0.3f : 0f;

            this._sound.lerpVolume = ((this._started && !this._throttle) ? 0.6f : 0f);
            this._sound.pitch      = pitch;
            if (this._started)
            {
                this._warmUp += 0.001f;
                if (this._warmUp > 1f)
                {
                    this._warmUp = 1f;
                }
                if (!this._puffClick && this._idleWave > 0.9f)
                {
                    this._skipSmoke = !this._skipSmoke;
                    if (this._throttle || !this._skipSmoke)
                    {
                        Level.Add(SmallSmoke.New(base.x + (float)(this.offDir * 4), base.y + 5f, this._smokeFlipper ? -0.1f : 0.8f, 0.7f));
                        this._smokeFlipper = !this._smokeFlipper;
                        this._puffClick    = true;
                    }
                }
                else if (this._puffClick && this._idleWave < 0f)
                {
                    this._puffClick = false;
                }
                if (this._pullState < 0)
                {
                    float num2 = 1f + Maths.NormalizeSection(this._engineSpin, 1f, 2f) * 2f;
                    float num3 = this._idleWave;
                    if (num2 > 1f)
                    {
                        num3 = this._spinWave;
                    }
                    this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f + num3 * num2), 0.23f);
                    this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f + num3 * num2), 0.23f);
                    float num4 = Maths.NormalizeSection(this._engineSpin, 1f, 2f) * 3f;
                    this._rotSway = this._idleWave.normalized * num4 * 0.03f;
                }
                else
                {
                    this._rotSway = 0f;
                }
                this._gas -= 3E-05f;
                if (this._throttle)
                {
                    this._gas -= 0.0002f;
                }
                if (this._gas < 0f)
                {
                    this._gas      = 0f;
                    this._started  = false;
                    this._throttle = false;
                }
                if (this._triggerHeld)
                {
                    if (this._releasedSincePull)
                    {
                        if (!this._throttle)
                        {
                            this._throttle = true;
                            SFX.Play("chainsawBladeRevUp", 0.5f, pitch, 0f, false);
                        }
                        this._engineSpin = Lerp.FloatSmooth(this._engineSpin, 4f, 0.1f, 1f);
                    }
                }
                else
                {
                    if (this._throttle)
                    {
                        this._throttle = false;
                        if (this._engineSpin > 1.7f)
                        {
                            SFX.Play("chainsawBladeRevDown", 0.5f, pitch, 0f, false);
                        }
                    }
                    this._engineSpin        = Lerp.FloatSmooth(this._engineSpin, 0f, 0.1f, 1f);
                    this._releasedSincePull = true;
                }
            }
            else
            {
                this._warmUp -= 0.001f;
                if (this._warmUp < 0f)
                {
                    this._warmUp = 0f;
                }
                this._releasedSincePull = false;
                this._throttle          = false;
            }
            this._bladeSound.lerpSpeed  = 0.1f;
            this._throttleWait          = Lerp.Float(this._throttleWait, this._throttle ? 1f : 0f, 0.07f);
            this._bladeSound.lerpVolume = ((this._throttleWait > 0.96f) ? 0.6f : 0f);
            if (this._struggling)
            {
                this._bladeSound.lerpVolume = 0f;
            }
            this._bladeSoundLow.lerpVolume = ((this._throttleWait > 0.96f && this._struggling) ? 0.6f : 0f);
            this._bladeSound.pitch         = pitch;
            this._bladeSoundLow.pitch      = pitch;
            if (this.owner == null)
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(13f, 11f);
            }
            else if (base.duck != null && (base.duck.sliding || base.duck.crouch))
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(6f, 11f);
            }
            else
            {
                this.collisionOffset = new Vec2(-8f, -6f);
                this.collisionSize   = new Vec2(10f, 11f);
            }
            if (this.owner != null)
            {
                this._resetDuck = false;
                if (this._pullState == -1)
                {
                    if (!this._started)
                    {
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 0)
                {
                    this._animRot    = Lerp.FloatSmooth(this._animRot, -0.4f, 0.15f, 1f);
                    this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, -2f), 0.25f);
                    this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-4f, 4f), 0.23f);
                    if (this._animRot <= -0.35f)
                    {
                        this._animRot   = -0.4f;
                        this._pullState = 1;
                        this.PullEngine();
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 1)
                {
                    this._releasePull = false;
                    this._holdOffset  = Lerp.Vec2Smooth(this._holdOffset, new Vec2(2f, 3f), 0.23f);
                    this.handOffset   = Lerp.Vec2Smooth(this.handOffset, new Vec2(-4f, -2f), 0.23f);
                    this._animRot     = Lerp.FloatSmooth(this._animRot, -0.5f, 0.07f, 1f);
                    if (this._animRot < -0.45f)
                    {
                        this._animRot   = -0.5f;
                        this._pullState = 2;
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 2)
                {
                    if (this._releasePull || !this._triggerHeld)
                    {
                        this._releasePull = true;
                        if (this._started)
                        {
                            this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(0f, 2f + this._idleWave.normalized), 0.23f);
                            this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f + this._idleWave.normalized), 0.23f);
                            this._animRot    = Lerp.FloatSmooth(this._animRot, 0f, 0.1f, 1f);
                            if (this._animRot > -0.07f)
                            {
                                this._animRot   = 0f;
                                this._pullState = -1;
                            }
                        }
                        else
                        {
                            this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-4f, 4f), 0.24f);
                            this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, -2f), 0.24f);
                            this._animRot    = Lerp.FloatSmooth(this._animRot, -0.4f, 0.12f, 1f);
                            if (this._animRot > -0.44f)
                            {
                                this._releasePull = false;
                                this._animRot     = -0.4f;
                                this._pullState   = 3;
                                this._holdOffset  = new Vec2(-4f, 4f);
                                this.handOffset   = new Vec2(-2f, -2f);
                            }
                        }
                    }
                    this._upWait = 0f;
                }
                else if (this._pullState == 3)
                {
                    this._releasePull = false;
                    this._upWait     += 0.1f;
                    if (this._upWait > 6f)
                    {
                        this._pullState = -1;
                    }
                }
                this._bladeSpin += this._engineSpin;
                while (this._bladeSpin >= 1f)
                {
                    this._bladeSpin -= 1f;
                    int num5 = this._sprite.frame + 1;
                    if (num5 > 15)
                    {
                        num5 = 0;
                    }
                    this._sprite.frame = num5;
                }
                this._engineSpin        = Lerp.FloatSmooth(this._engineSpin, 0f, 0.1f, 1f);
                this._engineResistance  = Lerp.FloatSmooth(this._engineResistance, 1f, 0.01f, 1f);
                this._hold              = -0.4f;
                this.center             = new Vec2(8f, 7f);
                this._framesSinceThrown = 0;
            }
            else
            {
                this._rotSway = 0f;
                this._shing   = false;
                this._animRot = Lerp.FloatSmooth(this._animRot, 0f, 0.18f, 1f);
                if (this._framesSinceThrown == 1)
                {
                    this._throwSpin = base.angleDegrees;
                }
                this._hold        = 0f;
                base.angleDegrees = this._throwSpin;
                this.center       = new Vec2(8f, 7f);
                bool flag  = false;
                bool flag2 = false;
                if ((Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 2f || !base.grounded) && this.gravMultiplier > 0f)
                {
                    if (!base.grounded && Level.CheckRect <Block>(this.position + new Vec2(-8f, -6f), this.position + new Vec2(8f, -2f), null) != null)
                    {
                        flag2 = true;
                    }
                    if (!flag2 && !this._grounded && Level.CheckPoint <IPlatform>(this.position + new Vec2(0f, 8f), null, null) == null)
                    {
                        if (this.offDir > 0)
                        {
                            this._throwSpin += (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 1f + 5f;
                        }
                        else
                        {
                            this._throwSpin -= (Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed)) * 1f + 5f;
                        }
                        flag = true;
                    }
                }
                if (!flag || flag2)
                {
                    this._throwSpin %= 360f;
                    if (this._throwSpin < 0f)
                    {
                        this._throwSpin += 360f;
                    }
                    if (flag2)
                    {
                        if (Math.Abs(this._throwSpin - 90f) < Math.Abs(this._throwSpin + 90f))
                        {
                            this._throwSpin = Lerp.Float(this._throwSpin, 90f, 16f);
                        }
                        else
                        {
                            this._throwSpin = Lerp.Float(-90f, 0f, 16f);
                        }
                    }
                    else if (this._throwSpin > 90f && this._throwSpin < 270f)
                    {
                        this._throwSpin = Lerp.Float(this._throwSpin, 180f, 14f);
                    }
                    else
                    {
                        if (this._throwSpin > 180f)
                        {
                            this._throwSpin -= 360f;
                        }
                        else if (this._throwSpin < -180f)
                        {
                            this._throwSpin += 360f;
                        }
                        this._throwSpin = Lerp.Float(this._throwSpin, 0f, 14f);
                    }
                }
            }
            if (Math.Abs(this._angle) > 1f)
            {
                this._flood += 0.005f;
                if (this._flood > 1f)
                {
                    this._flooded = true;
                    this._started = false;
                }
                this._gasDripFrames++;
                if (this._gas > 0f && this._flooded && this._gasDripFrames > 2)
                {
                    FluidData gas = Fluid.Gas;
                    gas.amount = 0.003f;
                    this._gas -= 0.005f;
                    if (this._gas < 0f)
                    {
                        this._gas = 0f;
                    }
                    Level.Add(new Fluid(base.x, base.y, Vec2.Zero, gas, null, 1f));
                    this._gasDripFrames = 0;
                }
                if (this._gas <= 0f)
                {
                    this._started = false;
                }
            }
            else
            {
                this._flood -= 0.008f;
                if (this._flood < 0f)
                {
                    this._flood = 0f;
                }
            }
            if (base.duck != null)
            {
                base.duck.frictionMult = 1f;
                if (this._skipSpark > 0)
                {
                    this._skipSpark++;
                    if (this._skipSpark > 2)
                    {
                        this._skipSpark = 0;
                    }
                }
                if (base.duck.sliding && this._throttle && this._skipSpark == 0)
                {
                    if (Level.CheckLine <Block>(this.barrelStartPos + new Vec2(0f, 8f), base.barrelPosition + new Vec2(0f, 8f), null) != null)
                    {
                        this._skipSpark = 1;
                        Vec2 value = this.position + base.barrelVector * 5f;
                        for (int i = 0; i < 2; i++)
                        {
                            Level.Add(Spark.New(value.x, value.y, new Vec2((float)this.offDir * Rando.Float(0f, 2f), Rando.Float(0.5f, 1.5f)), 0.02f));
                            value += base.barrelVector * 2f;
                            this._fireTrailWait -= 0.5f;
                            if (this.souped && this._fireTrailWait <= 0f)
                            {
                                this._fireTrailWait = 1f;
                                SmallFire smallFire = SmallFire.New(value.x, value.y, (float)this.offDir * Rando.Float(0f, 2f), Rando.Float(0.5f, 1.5f), false, null, true, null, false);
                                smallFire.waitToHurt = Rando.Float(1f, 2f);
                                smallFire.whoWait    = (this.owner as Duck);
                                Level.Add(smallFire);
                            }
                        }
                        if (this.offDir > 0 && this.owner.hSpeed < (float)(this.offDir * 6) * num)
                        {
                            this.owner.hSpeed = (float)(this.offDir * 6) * num;
                        }
                        else if (this.offDir < 0 && this.owner.hSpeed > (float)(this.offDir * 6) * num)
                        {
                            this.owner.hSpeed = (float)(this.offDir * 6) * num;
                        }
                    }
                    else if (this.offDir > 0 && this.owner.hSpeed < (float)(this.offDir * 3) * num)
                    {
                        this.owner.hSpeed = (float)(this.offDir * 3) * num;
                    }
                    else if (this.offDir < 0 && this.owner.hSpeed > (float)(this.offDir * 3) * num)
                    {
                        this.owner.hSpeed = (float)(this.offDir * 3) * num;
                    }
                }
                if (this._pullState == -1)
                {
                    if (!this._throttle)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0.3f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(-2f, 2f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(-3f, 4f), 0.23f);
                    }
                    else if (this._shing)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, -1.8f, 0.4f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                        if (this._animRot < -1.5f)
                        {
                            this._shing = false;
                        }
                    }
                    else if (base.duck.crouch)
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0.4f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    else if (base.duck.inputProfile.Down("UP"))
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, -0.9f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                    else
                    {
                        this._animRot    = MathHelper.Lerp(this._animRot, 0f, 0.2f);
                        this.handOffset  = Lerp.Vec2Smooth(this.handOffset, new Vec2(1f, 0f), 0.25f);
                        this._holdOffset = Lerp.Vec2Smooth(this._holdOffset, new Vec2(1f, 2f), 0.23f);
                    }
                }
            }
            else if (!this._resetDuck && base.prevOwner != null)
            {
                PhysicsObject physicsObject = base.prevOwner as PhysicsObject;
                if (physicsObject != null)
                {
                    physicsObject.frictionMult = 1f;
                }
                this._resetDuck = true;
            }
            if (this._skipDebris > 0)
            {
                this._skipDebris++;
            }
            if (this._skipDebris > 3)
            {
                this._skipDebris = 0;
            }
            this._struggling = false;
            if (this.owner != null && this._started && this._throttle && !this._shing)
            {
                (this.Offset(base.barrelOffset) - this.position).Normalize();
                this.Offset(base.barrelOffset);
                IEnumerable <IAmADuck> enumerable = Level.CheckLineAll <IAmADuck>(this.barrelStartPos, base.barrelPosition);
                Block block3 = Level.CheckLine <Block>(this.barrelStartPos, base.barrelPosition, null);
                if (this.owner != null)
                {
                    foreach (MaterialThing materialThing in Level.CheckLineAll <MaterialThing>(this.barrelStartPos, base.barrelPosition))
                    {
                        if (materialThing.Hurt((materialThing is Door) ? 1.8f : 0.5f))
                        {
                            if (base.duck != null && base.duck.sliding && materialThing is Door && (materialThing as Door)._jammed)
                            {
                                materialThing.Destroy(new DTImpale(this));
                            }
                            else
                            {
                                this._struggling = true;
                                if (base.duck != null)
                                {
                                    base.duck.frictionMult = 4f;
                                }
                                if (this._skipDebris == 0)
                                {
                                    this._skipDebris = 1;
                                    Vec2 value2 = Collision.LinePoint(this.barrelStartPos, base.barrelPosition, materialThing.rectangle);
                                    if (value2 != Vec2.Zero)
                                    {
                                        value2 += base.barrelVector * Rando.Float(0f, 3f);
                                        Vec2 vec = -base.barrelVector.Rotate(Rando.Float(-0.2f, 0.2f), Vec2.Zero);
                                        if (materialThing.physicsMaterial == PhysicsMaterial.Wood)
                                        {
                                            WoodDebris woodDebris = WoodDebris.New(value2.x, value2.y);
                                            woodDebris.hSpeed = vec.x * 3f;
                                            woodDebris.vSpeed = vec.y * 3f;
                                            Level.Add(woodDebris);
                                        }
                                        else if (materialThing.physicsMaterial == PhysicsMaterial.Metal)
                                        {
                                            Spark spark = Spark.New(value2.x, value2.y, Vec2.Zero, 0.02f);
                                            spark.hSpeed = vec.x * 3f;
                                            spark.vSpeed = vec.y * 3f;
                                            Level.Add(spark);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                bool flag3 = false;
                if (block3 != null && !(block3 is Door))
                {
                    this.Shing(block3);
                    if (block3 is Window)
                    {
                        block3.Destroy(new DTImpact(this));
                    }
                }
                else
                {
                    foreach (Thing thing in Level.current.things[typeof(Sword)])
                    {
                        Sword sword = (Sword)thing;
                        if (sword.owner != null && sword.crouchStance && !sword.jabStance && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, sword.barrelStartPos, sword.barrelPosition))
                        {
                            this.Shing(sword);
                            sword.Shing();
                            sword.owner.hSpeed     += (float)this.offDir * 3f;
                            sword.owner.vSpeed     -= 2f;
                            base.duck.hSpeed       += -(float)this.offDir * 3f;
                            base.duck.vSpeed       -= 2f;
                            sword.duck.crippleTimer = 1f;
                            base.duck.crippleTimer  = 1f;
                            flag3 = true;
                        }
                    }
                    if (!flag3)
                    {
                        Thing ignore = null;
                        if (base.duck != null)
                        {
                            ignore = base.duck.GetEquipment(typeof(Helmet));
                        }
                        QuadLaserBullet quadLaserBullet = Level.CheckLine <QuadLaserBullet>(this.position, base.barrelPosition, null);
                        if (quadLaserBullet != null)
                        {
                            this.Shing(quadLaserBullet);
                            Vec2  travel = quadLaserBullet.travel;
                            float length = travel.length;
                            float num6   = 1f;
                            if (this.offDir > 0 && travel.x < 0f)
                            {
                                num6 = 1.5f;
                            }
                            else if (this.offDir < 0 && travel.x > 0f)
                            {
                                num6 = 1.5f;
                            }
                            if (this.offDir > 0)
                            {
                                travel = new Vec2(length * num6, 0f);
                            }
                            else
                            {
                                travel = new Vec2(-length * num6, 0f);
                            }
                            quadLaserBullet.travel = travel;
                        }
                        else
                        {
                            Helmet helmet = Level.CheckLine <Helmet>(this.barrelStartPos, base.barrelPosition, ignore);
                            if (helmet != null && helmet.equippedDuck != null)
                            {
                                this.Shing(helmet);
                                helmet.owner.hSpeed     += (float)this.offDir * 3f;
                                helmet.owner.vSpeed     -= 2f;
                                helmet.duck.crippleTimer = 1f;
                                helmet.Hurt(0.53f);
                                flag3 = true;
                            }
                            else
                            {
                                if (base.duck != null)
                                {
                                    ignore = base.duck.GetEquipment(typeof(ChestPlate));
                                }
                                ChestPlate chestPlate = Level.CheckLine <ChestPlate>(this.barrelStartPos, base.barrelPosition, ignore);
                                if (chestPlate != null && chestPlate.equippedDuck != null)
                                {
                                    this.Shing(chestPlate);
                                    chestPlate.owner.hSpeed     += (float)this.offDir * 3f;
                                    chestPlate.owner.vSpeed     -= 2f;
                                    chestPlate.duck.crippleTimer = 1f;
                                    chestPlate.Hurt(0.53f);
                                    flag3 = true;
                                }
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    foreach (Thing thing2 in Level.current.things[typeof(Chainsaw)])
                    {
                        Chainsaw chainsaw = (Chainsaw)thing2;
                        if (chainsaw != this && chainsaw.owner != null && Collision.LineIntersect(this.barrelStartPos, base.barrelPosition, chainsaw.barrelStartPos, chainsaw.barrelPosition))
                        {
                            this.Shing(chainsaw);
                            chainsaw.Shing(this);
                            chainsaw.owner.hSpeed     += (float)this.offDir * 2f;
                            chainsaw.owner.vSpeed     -= 1.5f;
                            base.duck.hSpeed          += -(float)this.offDir * 2f;
                            base.duck.vSpeed          -= 1.5f;
                            chainsaw.duck.crippleTimer = 1f;
                            base.duck.crippleTimer     = 1f;
                            flag3 = true;
                            if (Recorder.currentRecording != null)
                            {
                                Recorder.currentRecording.LogBonus();
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    foreach (IAmADuck amADuck in enumerable)
                    {
                        if (amADuck != base.duck)
                        {
                            MaterialThing materialThing2 = amADuck as MaterialThing;
                            if (materialThing2 != null)
                            {
                                materialThing2.velocity += new Vec2((float)this.offDir * 0.8f, -0.8f);
                                materialThing2.Destroy(new DTImpale(this));
                                if (base.duck != null)
                                {
                                    base.duck._timeSinceChainKill = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 19
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();
        }
Esempio n. 20
0
        public override void Update()
        {
            Options.openOnClose = this._pauseMenu;
            if (this.spawnKey)
            {
                if ((double)this.spawnKeyWait > 0.0)
                {
                    this.spawnKeyWait -= Maths.IncFrameTimer();
                }
                else
                {
                    SFX.Play("ching");
                    this.spawnKey = false;
                    Key key = new Key(this._prizeTable.x, this._prizeTable.y);
                    key.vSpeed = -4f;
                    key.depth  = this._duck.depth + 50;
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)key);
                }
            }
            Chancy.Update();
            if (this._pendingSpawns != null && this._pendingSpawns.Count > 0)
            {
                Duck pendingSpawn = this._pendingSpawns[0];
                this.AddThing((Thing)pendingSpawn);
                this._pendingSpawns.RemoveAt(0);
                this._duck   = pendingSpawn;
                this._arcade = this.things[typeof(ArcadeMode)].First <Thing>() as ArcadeMode;
            }
            Layer.Lighting.fade  = Layer.Lighting2.fade = 1f - Math.Min(1f, Math.Max(0.0f, (float)((1.0 - (double)Layer.Game.fade) * 1.5)));
            this.backgroundColor = Color.Black;
            if (UnlockScreen.open || ArcadeHUD.open)
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = false;
                }
                this._prizeTable.visible = false;
            }
            else
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = true;
                }
                this._prizeTable.visible = true;
            }
            if (this._state == this._desiredState && this._state != ArcadeState.UnlockMachine && this._state != ArcadeState.LaunchChallenge)
            {
                if (!this._quitting)
                {
                    if (Input.Pressed("START"))
                    {
                        this._pauseGroup.Open();
                        this._pauseMenu.Open();
                        MonoMain.pauseMenu = this._pauseGroup;
                        if (!this._paused)
                        {
                            Music.Pause();
                            SFX.Play("pause", 0.6f);
                            this._paused           = true;
                            this._duck.immobilized = true;
                        }
                        this.simulatePhysics = false;
                        return;
                    }
                    if (this._paused && MonoMain.pauseMenu == null)
                    {
                        this._paused = false;
                        SFX.Play("resume", 0.6f);
                        if (this._quit.value)
                        {
                            this._quitting = true;
                        }
                        else
                        {
                            Music.Resume();
                            this._duck.immobilized = false;
                            this.simulatePhysics   = true;
                        }
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
                    if ((double)Graphics.fade > 0.00999999977648258)
                    {
                        return;
                    }
                    Level.current = (Level) new TitleScreen();
                    return;
                }
            }
            if (this._paused)
            {
                return;
            }
            if (this._hud.launchChallenge)
            {
                this._desiredState = ArcadeState.LaunchChallenge;
            }
            if (this._desiredState != this._state)
            {
                this._duck.active = false;
                bool flag = false;
                if (this._desiredState == ArcadeState.ViewChallenge)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._hud.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                else if (this._desiredState == ArcadeState.Normal)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                    if (Unlockables.HasPendingUnlocks())
                    {
                        MonoMain.pauseMenu = (UIComponent) new UIUnlockBox(Unlockables.GetPendingUnlocks().ToList <Unlockable>(), Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f);
                    }
                }
                else if (this._desiredState == ArcadeState.ViewSpecialChallenge || this._desiredState == ArcadeState.ViewChallengeList || this._desiredState == ArcadeState.ViewProfileSelector)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.UnlockMachine)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        HUD.CloseAllCorners();
                    }
                    if (this._state == ArcadeState.ViewChallenge)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    this._duck.alpha         = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    this._unlockMachineWait  = 1f;
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.LaunchChallenge)
                {
                    if (!this._flipState)
                    {
                        HUD.CloseAllCorners();
                    }
                    Music.volume             = Lerp.Float(Music.volume, 0.0f, 0.01f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.02f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if ((double)this._hud.alpha == 0.0)
                    {
                        flag = true;
                    }
                }
                if (this._desiredState == ArcadeState.UnlockScreen)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._unlockScreen.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                this._flipState = true;
                if (this._launchedChallenge)
                {
                    Layer.Background.fade = 0.0f;
                    Layer.Game.fade       = 0.0f;
                }
                if (!flag)
                {
                    return;
                }
                this._flipState = false;
                HUD.CloseAllCorners();
                this._state = this._desiredState;
                if (this._state == ArcadeState.ViewChallenge)
                {
                    if (this._afterChallenge)
                    {
                        Music.Play("Arcade");
                        this._afterChallenge = false;
                    }
                    this._hud.MakeActive();
                    Level.Add((Thing)this._hud);
                    this._duck.active = false;
                }
                else if (this._state == ArcadeState.LaunchChallenge)
                {
                    ArcadeLevel.currentArcade = this;
                    foreach (Thing thing in this.things[typeof(ChallengeConfetti)])
                    {
                        Level.Remove(thing);
                    }
                    Music.Stop();
                    Level.current = (Level) new ChallengeLevel(this._hud.selected.challenge.fileName);
                    if (!this.launchSpecialChallenge)
                    {
                        this._desiredState        = ArcadeState.ViewChallenge;
                        this._hud.launchChallenge = false;
                        this._launchedChallenge   = false;
                        this._afterChallenge      = true;
                    }
                    else
                    {
                        this._desiredState          = ArcadeState.ViewSpecialChallenge;
                        this._hud.launchChallenge   = false;
                        this._launchedChallenge     = false;
                        this._afterChallenge        = true;
                        this.launchSpecialChallenge = false;
                    }
                }
                else
                {
                    if (this._state == ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    if (this._state == ArcadeState.Normal)
                    {
                        this._unlockMachines.Clear();
                        foreach (ArcadeMachine challenge in this._challenges)
                        {
                            if (challenge.CheckUnlocked())
                            {
                                this._unlockMachines.Add(challenge);
                            }
                        }
                        if (this._unlockMachines.Count > 0)
                        {
                            this._desiredState = ArcadeState.UnlockMachine;
                        }
                        else
                        {
                            if (!this.basementWasUnlocked && Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]))
                            {
                                this.spawnKey            = true;
                                this.basementWasUnlocked = true;
                            }
                            this._duck.active = true;
                        }
                    }
                    else if (this._state == ArcadeState.ViewSpecialChallenge)
                    {
                        this._duck.active = false;
                        if (this._afterChallenge)
                        {
                            Music.Play("Arcade");
                            this._afterChallenge = false;
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                            Chancy.afterChallenge     = true;
                            Chancy.afterChallengeWait = 1f;
                        }
                        else
                        {
                            HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                            HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@CANCEL");
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                        }
                        this._duck.active = false;
                    }
                    else if (this._state == ArcadeState.ViewProfileSelector)
                    {
                        this._duck.active = false;
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole == null)
                        {
                            return;
                        }
                        HUD.CloseAllCorners();
                        arcadeHatConsole.Open();
                    }
                    else if (this._state == ArcadeState.ViewChallengeList)
                    {
                        this._duck.active = false;
                        HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                        HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@BACK");
                    }
                    else
                    {
                        if (this._state != ArcadeState.UnlockScreen)
                        {
                            return;
                        }
                        this.basementWasUnlocked = Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]);
                        this._unlockScreen.MakeActive();
                        this._duck.active = false;
                    }
                }
            }
            else if (this._state == ArcadeState.Normal || this._state == ArcadeState.UnlockMachine)
            {
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                if (this._state == ArcadeState.Normal)
                {
                    object obj = (object)null;
                    foreach (ArcadeMachine challenge in this._challenges)
                    {
                        double length = (double)(this._duck.position - challenge.position).length;
                        if (challenge.hover)
                        {
                            obj = (object)challenge;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._hud.activeChallengeGroup = challenge.data;
                                this._desiredState             = ArcadeState.ViewChallenge;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)challenge);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                        if (this._prizeTable.hover)
                        {
                            obj = (object)this._prizeTable;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._desiredState             = ArcadeState.UnlockScreen;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)this._prizeTable);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                    }
                    if (Chancy.hover && Input.Pressed("SHOOT"))
                    {
                        this._desiredState = ArcadeState.ViewSpecialChallenge;
                        HUD.CloseAllCorners();
                        this._hoverMachine        = (ArcadeMachine)null;
                        this._hoverThing          = (object)null;
                        Chancy.hover              = false;
                        Chancy.lookingAtChallenge = true;
                        Chancy.OpenChallengeView();
                    }
                    else
                    {
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole != null && Input.Pressed("SHOOT") && arcadeHatConsole.hover)
                        {
                            this._desiredState = ArcadeState.ViewProfileSelector;
                            HUD.CloseAllCorners();
                            this._hoverMachine = (ArcadeMachine)null;
                            this._hoverThing   = (object)null;
                        }
                        else
                        {
                            Chancy.hover = false;
                            if (!Chancy.atCounter)
                            {
                                if ((double)(this._duck.position - Chancy.standingPosition).length < 22.0)
                                {
                                    obj          = (object)Chancy.context;
                                    Chancy.hover = true;
                                }
                                if ((double)Chancy.standingPosition.x < (double)Layer.Game.camera.left - 16.0 || (double)Chancy.standingPosition.x > (double)Layer.Game.camera.right + 16.0 || ((double)Chancy.standingPosition.y < (double)Layer.Game.camera.top - 16.0 || (double)Chancy.standingPosition.y > (double)Layer.Game.camera.bottom + 16.0))
                                {
                                    Chancy.atCounter       = true;
                                    Chancy.activeChallenge = (ChallengeData)null;
                                }
                            }
                            else if (this._prizeTable.hoverChancyChallenge)
                            {
                                obj = (object)this._arcade;
                                if (Input.Pressed("SHOOT"))
                                {
                                    this._desiredState = ArcadeState.ViewChallengeList;
                                    HUD.CloseAllCorners();
                                    Chancy.OpenChallengeList();
                                    this._hoverMachine   = (ArcadeMachine)null;
                                    this._hoverThing     = (object)null;
                                    Chancy.hover         = false;
                                    Chancy.lookingAtList = true;
                                    return;
                                }
                            }
                            if (this._hoverThing == obj)
                            {
                                return;
                            }
                            HUD.CloseAllCorners();
                            this._hoverThing   = obj;
                            this._hoverMachine = !(this._hoverThing is ArcadeMachine) ? (ArcadeMachine)null : obj as ArcadeMachine;
                            if (this._hoverMachine != null)
                            {
                                HUD.AddCornerControl(HUDCorner.BottomLeft, "PLAY@SHOOT@");
                                string text = this._hoverMachine.data.name + " ";
                                foreach (string challenge1 in this._hoverMachine.data.challenges)
                                {
                                    ChallengeData challenge2 = Challenges.GetChallenge(challenge1);
                                    if (challenge2 != null)
                                    {
                                        ChallengeSaveData saveData = Challenges.GetSaveData(challenge2.levelID, this._duck.profile);
                                        if (saveData.trophy == TrophyType.Baseline)
                                        {
                                            text += "@BASELINE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Bronze)
                                        {
                                            text += "@BRONZE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Silver)
                                        {
                                            text += "@SILVER@";
                                        }
                                        else if (saveData.trophy == TrophyType.Gold)
                                        {
                                            text += "@GOLD@";
                                        }
                                        else if (saveData.trophy == TrophyType.Platinum)
                                        {
                                            text += "@PLATINUM@";
                                        }
                                        else if (saveData.trophy == TrophyType.Developer)
                                        {
                                            text += "@DEVELOPER@";
                                        }
                                    }
                                }
                                HUD.AddCornerMessage(HUDCorner.TopLeft, text);
                            }
                            else if (this._prizeTable.hover)
                            {
                                if (this._prizeTable.hoverChancyChallenge)
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                }
                                else
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@SPEND TICKETS");
                                    HUD.AddCornerCounter(HUDCorner.BottomLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                                }
                            }
                            else
                            {
                                switch (obj)
                                {
                                case ArcadeMode _:
                                    if (!this._prizeTable.hoverChancyChallenge)
                                    {
                                        break;
                                    }
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                    break;

                                case Chancy _:
                                    HUD.AddCornerControl(HUDCorner.BottomLeft, "CHANCY@SHOOT@");
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (this._state != ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    this._unlockMachineWait   -= 0.02f;
                    Layer.Lighting2.targetFade = Lerp.Float(Layer.Lighting2.targetFade, 0.5f, 0.01f);
                    if ((double)this._unlockMachineWait >= 0.0)
                    {
                        return;
                    }
                    if (this._unlockingMachine)
                    {
                        this._unlockingMachine = false;
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        this._unlockMachineWait = 1f;
                    }
                    else if (this._unlockMachines.Count > 0)
                    {
                        this._unlockMachines[0].unlocked = true;
                        this._unlockMachines.RemoveAt(0);
                        this._unlockingMachine = this._unlockMachines.Count > 0;
                        SFX.Play("lightTurnOn", pitch: Rando.Float(-0.1f, 0.1f));
                        this._unlockMachineWait    = 1f;
                        Layer.Lighting2.targetFade = 1f;
                    }
                    else
                    {
                        this._desiredState = ArcadeState.Normal;
                    }
                }
            }
            else if (this._state == ArcadeState.ViewChallenge)
            {
                Graphics.fade         = Lerp.Float(Graphics.fade, 1f, 0.05f);
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.05f);
                if (!this._hud.quitOut)
                {
                    return;
                }
                this._hud.quitOut  = false;
                this._desiredState = ArcadeState.Normal;
                if (Chancy.activeChallenge != null)
                {
                    return;
                }
                List <ChallengeData> chancyChallenges = Challenges.GetEligibleIncompleteChancyChallenges(Profiles.active[0]);
                if (chancyChallenges.Count <= 0)
                {
                    return;
                }
                Vec2          position      = this._duck.position;
                ArcadeMachine arcadeMachine = Level.Nearest <ArcadeMachine>(this._duck.x, this._duck.y);
                if (arcadeMachine != null)
                {
                    position = arcadeMachine.position;
                }
                chancyChallenges.OrderBy <ChallengeData, int>((Func <ChallengeData, int>)(v => v.GetRequirementValue()));
                Chancy.AddProposition(chancyChallenges[chancyChallenges.Count - 1], position);
            }
            else if (this._state == ArcadeState.UnlockScreen)
            {
                if (!this._unlockScreen.quitOut)
                {
                    return;
                }
                this._unlockScreen.quitOut = false;
                this._desiredState         = ArcadeState.Normal;
            }
            else if (this._state == ArcadeState.ViewSpecialChallenge)
            {
                if (!this.launchSpecialChallenge)
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                    if (Input.Pressed("QUACK"))
                    {
                        if (this.returnToChallengeList)
                        {
                            this._desiredState   = ArcadeState.ViewChallengeList;
                            Chancy.hover         = false;
                            Chancy.lookingAtList = true;
                        }
                        else
                        {
                            this._desiredState = ArcadeState.Normal;
                        }
                        Chancy.lookingAtChallenge = false;
                        HUD.CloseAllCorners();
                        SFX.Play("consoleCancel");
                    }
                    else
                    {
                        if (!Input.Pressed("SELECT"))
                        {
                            return;
                        }
                        this.launchSpecialChallenge = true;
                        SFX.Play("consoleSelect");
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.05f);
                    if ((double)Graphics.fade >= 0.00999999977648258)
                    {
                        return;
                    }
                    this._hud.launchChallenge = true;
                    this._hud.selected        = new ChallengeCard(0.0f, 0.0f, Chancy.activeChallenge);
                    HUD.CloseAllCorners();
                }
            }
            else if (this._state == ArcadeState.ViewChallengeList)
            {
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                if (Input.Pressed("QUACK"))
                {
                    this._desiredState        = ArcadeState.Normal;
                    Chancy.lookingAtChallenge = false;
                    Chancy.lookingAtList      = false;
                    HUD.CloseAllCorners();
                    SFX.Play("consoleCancel");
                }
                else
                {
                    if (!Input.Pressed("SELECT"))
                    {
                        return;
                    }
                    Chancy.AddProposition(Chancy.selectedChallenge, Chancy.standingPosition);
                    this.returnToChallengeList = true;
                    this._desiredState         = ArcadeState.ViewSpecialChallenge;
                    HUD.CloseAllCorners();
                    this._hoverMachine        = (ArcadeMachine)null;
                    this._hoverThing          = (object)null;
                    Chancy.hover              = false;
                    Chancy.lookingAtChallenge = true;
                    Chancy.lookingAtList      = false;
                    Chancy.OpenChallengeView();
                }
            }
            else
            {
                if (this._state != ArcadeState.ViewProfileSelector)
                {
                    return;
                }
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                if (arcadeHatConsole == null || arcadeHatConsole.IsOpen())
                {
                    return;
                }
                foreach (ArcadeMachine challenge in this._challenges)
                {
                    challenge.unlocked = challenge.CheckUnlocked(false);
                }
                this._unlockMachines.Clear();
                this.UpdateDefault();
                this._desiredState = ArcadeState.Normal;
            }
        }
 public override void Update()
 {
     base.Update();
     this.offDir = (sbyte)1;
     if ((double)this._hitPoints <= 0.0)
     {
         if (this.graphic != this._toreUp)
         {
             float     num1  = this._fluidLevel * 0.5f;
             float     num2  = this._fluidLevel * 0.5f;
             FluidData fluid = this._fluid;
             fluid.amount = num1 / 20f;
             for (int index = 0; index < 20; ++index)
             {
                 Level.Add((Thing) new Fluid(this.x + Rando.Float(-4f, 4f), this.y + Rando.Float(-4f, 4f), new Vec2(Rando.Float(-4f, 4f), Rando.Float(-4f, 0.0f)), fluid));
             }
             fluid.amount = num2;
             Level.Add((Thing) new Fluid(this.x, this.y - 8f, new Vec2(0.0f, -1f), fluid));
             Level.Add((Thing)SmallSmoke.New(this.x, this.y));
             SFX.Play("bulletHitWater");
             SFX.Play("crateDestroy");
         }
         this.graphic            = (Sprite)this._toreUp;
         this._onFire            = false;
         this.burnt              = 0.0f;
         this._weight            = 0.1f;
         this._collisionSize.y   = 8f;
         this._collisionOffset.y = -3f;
     }
     this.burnSpeed = 0.0015f;
     if (this._onFire && (double)this.burnt < 0.899999976158142)
     {
         if ((double)this.burnt > 0.300000011920929)
         {
             this.graphic = this._melting;
         }
         this.yscale             = (float)(0.5 + (1.0 - (double)this.burnt) * 0.5);
         this.centery            = (float)(8.0 - (double)this.burnt * 7.0);
         this._collisionOffset.y = (float)((double)this.burnt * 7.0 - 8.0);
         this._collisionSize.y   = (float)(16.0 - (double)this.burnt * 7.0);
     }
     if (!this._bottomHoles && (double)this.burnt > 0.600000023841858)
     {
         this._bottomHoles = true;
         this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(-1f, -1f), 1f, new Vec2(-7f, 8f))
         {
             holeThickness = 2f
         });
         this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(1f, -1f), 1f, new Vec2(7f, 8f))
         {
             holeThickness = 2f
         });
     }
     if (this._owner != null)
     {
         this.hSpeed = this.owner.hSpeed;
         this.vSpeed = this.owner.vSpeed;
     }
     if (this._alternate == 0)
     {
         foreach (FluidStream hole in this._holes)
         {
             hole.onFire = this.onFire;
             hole.hSpeed = this.hSpeed;
             hole.vSpeed = this.vSpeed;
             hole.DoUpdate();
             hole.position   = this.Offset(hole.offset);
             hole.sprayAngle = this.OffsetLocal(hole.startSprayAngle);
             float num1 = (float)(1.0 - ((double)hole.offset.y - (double)this.topLocal) / ((double)this.bottomLocal - (double)this.topLocal));
             if ((double)hole.x > (double)this.left - 2.0 && (double)hole.x < (double)this.right + 2.0 && (double)num1 < (double)this._fluidLevel)
             {
                 float     num2  = Maths.Clamp(this._fluidLevel - num1, 0.1f, 1f) * 0.008f * hole.holeThickness;
                 FluidData fluid = this._fluid;
                 fluid.amount = num2;
                 hole.Feed(fluid);
                 this._fluidLevel -= num2;
                 this._lossAccum  += num2;
                 while ((double)this._lossAccum > 0.0500000007450581)
                 {
                     this._lossAccum -= 0.05f;
                     if (this.sequence != null && this.sequence.isValid && ChallengeLevel.running)
                     {
                         ++ChallengeLevel.goodiesGot;
                         SFX.Play("tinyTick");
                     }
                 }
             }
         }
     }
     this.weight = this._fluidLevel * 10f;
     ++this._alternate;
     if (this._alternate <= 4)
     {
         return;
     }
     this._alternate = 0;
 }
Esempio n. 22
0
 public override void Update()
 {
     if (!this.burntOut && (double)this.burnt >= 1.0)
     {
         Vec2 vec2 = this.Offset(new Vec2(10f, 0.0f));
         Level.Add((Thing)SmallSmoke.New(vec2.x, vec2.y));
         this._onFire   = false;
         this.flammable = 0.0f;
         this.burntOut  = true;
     }
     if (this._topBullet != null)
     {
         this._topBullet.DoUpdate();
         int num = (int)((double)this.ammo / (double)this.bulletsTillRemove);
         if (num < this.numHanging)
         {
             this._topBullet = this._topBullet.childThing as ChaingunBullet;
             if (this._topBullet != null)
             {
                 this._topBullet.parentThing = (Thing)this;
             }
         }
         this.numHanging = num;
     }
     this._fireWait = (float)(0.649999976158142 + (double)Maths.NormalizeSection(this._barrelHeat, 5f, 9f) * 3.0) + Rando.Float(0.25f);
     if ((double)this._barrelHeat > 10.0)
     {
         this._barrelHeat = 10f;
     }
     this._barrelHeat -= 0.005f;
     if ((double)this._barrelHeat < 0.0)
     {
         this._barrelHeat = 0.0f;
     }
     if (!this.burntOut)
     {
         this._sprite.speed = this._spin;
         this._tip.speed    = this._spin;
         if ((double)this._spin > 0.0)
         {
             this._spin -= 0.01f;
         }
         else
         {
             this._spin = 0.0f;
         }
     }
     base.Update();
     if (this._topBullet == null)
     {
         return;
     }
     if (!this.graphic.flipH)
     {
         this._topBullet.chainOffset = new Vec2(1f, 5f);
     }
     else
     {
         this._topBullet.chainOffset = new Vec2(-1f, 5f);
     }
 }
Esempio n. 23
0
 // Token: 0x0600198A RID: 6538
 public override void Update()
 {
     base.Update();
     this._sprite.currentAnimation = (this._receivingSignal ? "beep" : "idle");
     this._idle.lerpVolume         = Math.Min(this._idleSpeed * 10f, 0.7f);
     if (base._destroyed)
     {
         this._idle.lerpVolume = 0f;
         this._idle.lerpSpeed  = 1f;
     }
     this._idle.pitch = 0.5f + this._idleSpeed * 0.5f;
     if (this.moveLeft)
     {
         if (this.hSpeed > -this._maxSpeed)
         {
             this.hSpeed -= 0.4f;
         }
         else
         {
             this.hSpeed = -this._maxSpeed;
         }
         this.offDir      = -1;
         this._idleSpeed += 0.03f;
         this._inc++;
     }
     if (this.moveRight)
     {
         if (this.hSpeed < this._maxSpeed)
         {
             this.hSpeed += 0.4f;
         }
         else
         {
             this.hSpeed = this._maxSpeed;
         }
         this.offDir      = 1;
         this._idleSpeed += 0.03f;
         this._inc++;
     }
     if (this._idleSpeed > 0.1f)
     {
         this._inc = 0;
         Level.Add(SmallSmoke.New(base.x - (float)(this.offDir * 10), base.y));
     }
     if (!this.moveLeft && !this.moveRight)
     {
         this._idleSpeed -= 0.03f;
     }
     if (this._idleSpeed > 1f)
     {
         this._idleSpeed = 1f;
     }
     if (this._idleSpeed < 0f)
     {
         this._idleSpeed = 0f;
     }
     if (this.jump && base.grounded)
     {
         this.vSpeed -= 4.8f;
     }
     this._tilt        = MathHelper.Lerp(this._tilt, -this.hSpeed, 0.4f);
     this._waveMult    = MathHelper.Lerp(this._waveMult, -this.hSpeed, 0.1f);
     base.angleDegrees = this._tilt * 2f + this._wave.value * (this._waveMult * (this._maxSpeed - Math.Abs(this.hSpeed)));
     if (base.isServerForObject && base.y > Level.current.lowestPoint + 100f && !this.destroyed)
     {
         this.Destroy(new DTFall());
     }
 }