Exemple #1
0
 public override void Update()
 {
     if (!this._filled)
     {
         this._filled = true;
         Block b = Level.CheckRay <Block>(new Vec2(this.x, this.y), new Vec2(this.x, this.y + 64f));
         if (b != null)
         {
             FluidPuddle fluidPuddle = new FluidPuddle(this.x, b.top, b);
             Level.Add((Thing)fluidPuddle);
             float num = 0.0f;
             while ((double)fluidPuddle.CalculateDepth() < (double)((int)this.deep * 8))
             {
                 FluidData fluidType = this.GetFluidType();
                 fluidType.amount = 0.5f;
                 fluidPuddle.Feed(fluidType);
                 float depth = fluidPuddle.CalculateDepth();
                 if ((double)Math.Abs(num - depth) < 1.0 / 1000.0)
                 {
                     Level.Remove((Thing)this);
                     break;
                 }
                 num = depth;
             }
         }
     }
     base.Update();
 }
Exemple #2
0
        public override void Update()
        {
            base.Update();
            if ((double)this.damageMultiplier > 1.0)
            {
                this.damageMultiplier -= 0.2f;
            }
            else
            {
                this.damageMultiplier = 1f;
            }
            this._sprite.frame = (int)Math.Floor((1.0 - (double)this._hitPoints / (double)this._maxHealth) * 4.0);
            if ((double)this._hitPoints <= 0.0 && !this._destroyed)
            {
                this.Destroy((DestroyType) new DTImpact((Thing)this));
            }
            if (this._onFire && (double)this._burnt < 0.899999976158142)
            {
                float num = 1f - this.burnt;
                if ((double)this._hitPoints > (double)num * (double)this._maxHealth)
                {
                    this._hitPoints = num * this._maxHealth;
                }
                this._sprite.color = new Color(num, num, num);
            }
            FluidPuddle fluidPuddle = Level.CheckPoint <FluidPuddle>(this.position + new Vec2(0.0f, 4f));

            if (fluidPuddle != null)
            {
                if ((double)this.y + 4.0 - (double)fluidPuddle.top > 8.0)
                {
                    this.gravMultiplier = -0.5f;
                    this.grounded       = false;
                }
                else
                {
                    if ((double)this.y + 4.0 - (double)fluidPuddle.top < 3.0)
                    {
                        this.gravMultiplier = 0.2f;
                        this.grounded       = true;
                    }
                    else if ((double)this.y + 4.0 - (double)fluidPuddle.top > 4.0)
                    {
                        this.gravMultiplier = -0.2f;
                        this.grounded       = true;
                    }
                    this.grounded = true;
                }
            }
            else
            {
                this.gravMultiplier = 1f;
            }
        }
Exemple #3
0
        public override void Update()
        {
            base.Update();
            if ((double)this.damageMultiplier > 1.0)
            {
                this.damageMultiplier -= 0.2f;
            }
            else
            {
                this.damageMultiplier = 1f;
                this.breakPoints      = 15f;
            }
            this._sprite.frame = (int)Math.Floor((1.0 - (double)this._hitPoints / 1.0) * 4.0);
            if (this._sprite.frame == 0)
            {
                this.collisionOffset = new Vec2(-8f, -8f);
                this.collisionSize   = new Vec2(16f, 16f);
            }
            else if (this._sprite.frame == 1)
            {
                this.collisionOffset = new Vec2(-8f, -7f);
                this.collisionSize   = new Vec2(16f, 15f);
            }
            else if (this._sprite.frame == 2)
            {
                this.collisionOffset = new Vec2(-8f, -4f);
                this.collisionSize   = new Vec2(16f, 12f);
            }
            else if (this._sprite.frame == 3)
            {
                this.collisionOffset = new Vec2(-8f, -1f);
                this.collisionSize   = new Vec2(16f, 9f);
            }
            FluidPuddle fluidPuddle = Level.CheckPoint <FluidPuddle>(this.position + new Vec2(0.0f, 4f));

            if (fluidPuddle != null)
            {
                if ((double)this.y + 4.0 - (double)fluidPuddle.top > 8.0)
                {
                    this.gravMultiplier = -0.5f;
                    this.grounded       = false;
                }
                else
                {
                    if ((double)this.y + 4.0 - (double)fluidPuddle.top < 3.0)
                    {
                        this.gravMultiplier = 0.2f;
                        this.grounded       = true;
                    }
                    else if ((double)this.y + 4.0 - (double)fluidPuddle.top > 4.0)
                    {
                        this.gravMultiplier = -0.2f;
                        this.grounded       = true;
                    }
                    this.grounded = true;
                }
            }
            else
            {
                this.gravMultiplier = 1f;
            }
        }
Exemple #4
0
        public override void Update()
        {
            ++this._framesSinceFeed;
            this.fluidWave += 0.1f;
            if ((double)this.data.amount < 9.99999974737875E-05)
            {
                Level.Remove((Thing)this);
            }
            if ((double)this.collisionSize.y > 10.0)
            {
                ++this.bubbleWait;
                if (this.bubbleWait > Rando.Int(15, 25))
                {
                    for (int index = 0; index < (int)Math.Floor((double)this.collisionSize.x / 16.0); ++index)
                    {
                        if ((double)Rando.Float(1f) > 0.850000023841858)
                        {
                            Level.Add((Thing) new TinyBubble(this.left + (float)(index * 16) + Rando.Float(-4f, 4f), this.bottom + Rando.Float(-4f), 0.0f, this.top + 10f));
                        }
                    }
                    this.bubbleWait = 0;
                }
                foreach (PhysicsObject physicsObject in Level.CheckRectAll <PhysicsObject>(this.topLeft, this.bottomRight))
                {
                    physicsObject.sleeping = false;
                }
            }
            FluidPuddle fluidPuddle = Level.CheckLine <FluidPuddle>(new Vec2(this.left, this.y), new Vec2(this.right, this.y), (Thing)this);

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

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

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

            if ((double)depth > 4.0 && !this._initializedUpperCorners)
            {
                this._initializedUpperCorners = true;
                foreach (BlockCorner groupCorner in this._block.GetGroupCorners())
                {
                    if (this._leftCorner != null && (double)groupCorner.corner.x == (double)this._leftCorner.corner.x && (double)groupCorner.corner.y < (double)this._leftCorner.corner.y)
                    {
                        if (this._topLeftCorner == null)
                        {
                            this._topLeftCorner = groupCorner;
                        }
                        else if ((double)groupCorner.corner.y > (double)this._topLeftCorner.corner.y)
                        {
                            this._topLeftCorner = groupCorner;
                        }
                    }
                    else if (this._rightCorner != null && (double)groupCorner.corner.x == (double)this._rightCorner.corner.x && (double)groupCorner.corner.y < (double)this._rightCorner.corner.y)
                    {
                        if (this._topRightCorner == null)
                        {
                            this._topRightCorner = groupCorner;
                        }
                        else if ((double)groupCorner.corner.y > (double)this._topRightCorner.corner.y)
                        {
                            this._topRightCorner = groupCorner;
                        }
                    }
                }
            }
            if (this._leftStream != null)
            {
                this._leftStream.position.y = this.y - this._collisionOffset.y;
            }
            if (this._rightStream != null)
            {
                this._rightStream.position.y = this.y - this._collisionOffset.y;
            }
            this._collisionOffset.y = -depth;
            this._collisionSize.y   = depth;
        }