public FluidPuddle(float xpos, float ypos, Block b) : base(xpos, ypos) { this._collisionOffset.y = -4f; this._collisionSize.y = 1f; this._block = b; this.depth = new Depth(0.3f); this.flammable = 0.9f; this.alpha = 0.0f; List <BlockCorner> groupCorners = b.GetGroupCorners(); this._leftCorner = (BlockCorner)null; this._rightCorner = (BlockCorner)null; foreach (BlockCorner blockCorner in groupCorners) { if ((double)Math.Abs(ypos - blockCorner.corner.y) < 4.0) { if ((double)blockCorner.corner.x > (double)xpos) { if (this._rightCorner == null) { this._rightCorner = blockCorner; } else if ((double)blockCorner.corner.x < (double)this._rightCorner.corner.x) { this._rightCorner = blockCorner; } } else if ((double)blockCorner.corner.x < (double)xpos) { if (this._leftCorner == null) { this._leftCorner = blockCorner; } else if ((double)blockCorner.corner.x > (double)this._leftCorner.corner.x) { this._leftCorner = blockCorner; } } } } }
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; }