private unsafe void InternalDraw(SpriteBatch spriteBatch, Vector2 drawOffset, int waterStyle, float globalAlpha, bool isBackgroundDraw) { Rectangle drawArea = _drawArea; Main.tileBatch.Begin(); fixed(LiquidDrawCache *ptr = &_drawCache[0]) { LiquidDrawCache *ptr2 = ptr; for (int i = drawArea.X; i < drawArea.X + drawArea.Width; i++) { for (int j = drawArea.Y; j < drawArea.Y + drawArea.Height; j++) { if (ptr2->IsVisible) { Rectangle sourceRectangle = ptr2->SourceRectangle; if (ptr2->IsSurfaceLiquid) { sourceRectangle.Y = 1280; } else { sourceRectangle.Y += _animationFrame * 80; } Vector2 liquidOffset = ptr2->LiquidOffset; float num = ptr2->Opacity * (isBackgroundDraw ? 1f : DEFAULT_OPACITY[ptr2->Type]); int num2 = ptr2->Type; switch (num2) { case 0: num2 = waterStyle; num *= globalAlpha; break; case 2: num2 = 11; break; } num = Math.Min(1f, num); Lighting.GetCornerColors(i, j, out VertexColors vertices); vertices.BottomLeftColor *= num; vertices.BottomRightColor *= num; vertices.TopLeftColor *= num; vertices.TopRightColor *= num; Main.DrawTileInWater(drawOffset, i, j); Main.tileBatch.Draw(_liquidTextures[num2].get_Value(), new Vector2(i << 4, j << 4) + drawOffset + liquidOffset, sourceRectangle, vertices, Vector2.Zero, 1f, SpriteEffects.None); } ptr2++; } } } Main.tileBatch.End(); }
public unsafe void InternalDraw(SpriteBatch spriteBatch, Vector2 drawOffset, int waterStyle, float globalAlpha, bool isBackgroundDraw) { Rectangle rectangle1 = _drawArea; fixed(LiquidDrawCache *liquidDrawCachePtr1 = &_drawCache[0]) { LiquidDrawCache *liquidDrawCachePtr2 = liquidDrawCachePtr1; for (int centerX = rectangle1.X; centerX < rectangle1.X + rectangle1.Width; ++centerX) { for (int centerY = rectangle1.Y; centerY < rectangle1.Y + rectangle1.Height; ++centerY) { if (liquidDrawCachePtr2->IsVisible) { Rectangle rectangle2 = liquidDrawCachePtr2->SourceRectangle; if (liquidDrawCachePtr2->IsSurfaceLiquid) { rectangle2.Y = 1280; } else { rectangle2.Y += _animationFrame * 80; } Vector2 vector2 = liquidDrawCachePtr2->LiquidOffset; int index = liquidDrawCachePtr2->Type; switch (index) { case 0: index = waterStyle; break; case 2: index = 11; break; } VertexColors vertices; Lighting.GetColor4Slice_New(centerX, centerY, out vertices, 1f); float num = liquidDrawCachePtr2->Opacity * Math.Min(1f, isBackgroundDraw ? 1f : globalAlpha * DEFAULT_OPACITY[liquidDrawCachePtr2->Type]); vertices.BottomLeftColor *= num; vertices.BottomRightColor *= num; vertices.TopLeftColor *= num; vertices.TopRightColor *= num; Main.tileBatch.Draw(_liquidTextures[index], new Vector2((float)(centerX << 4), (float)(centerY << 4)) + drawOffset + vector2, new Rectangle?(rectangle2), vertices, Vector2.Zero, 1f, SpriteEffects.None); } ++liquidDrawCachePtr2; } } } }
public unsafe void InternalDraw(SpriteBatch spriteBatch, Vector2 drawOffset, int waterStyle, float globalAlpha, bool isBackgroundDraw) { Rectangle drawArea = _drawArea; fixed(LiquidDrawCache *ptr = &_drawCache[0]) { LiquidDrawCache *ptr2 = ptr; for (int i = drawArea.X; i < drawArea.X + drawArea.Width; i++) { for (int j = drawArea.Y; j < drawArea.Y + drawArea.Height; j++) { if (ptr2->IsVisible) { Rectangle sourceRectangle = ptr2->SourceRectangle; if (ptr2->IsSurfaceLiquid) { sourceRectangle.Y = 1280; } else { sourceRectangle.Y += _animationFrame * 80; } Vector2 liquidOffset = ptr2->LiquidOffset; int num = ptr2->Type; switch (num) { case 0: num = waterStyle; break; case 2: num = 11; break; } VertexColors vertices; Lighting.GetColor4Slice_New(i, j, out vertices); float num2 = ptr2->Opacity * Math.Min(1f, isBackgroundDraw ? 1f : (globalAlpha * DEFAULT_OPACITY[ptr2->Type])); vertices.BottomLeftColor *= num2; vertices.BottomRightColor *= num2; vertices.TopLeftColor *= num2; vertices.TopRightColor *= num2; Main.tileBatch.Draw(_liquidTextures[num], new Vector2(i << 4, j << 4) + drawOffset + liquidOffset, sourceRectangle, vertices, Vector2.Zero, 1f, SpriteEffects.None); } ptr2++; } } } }
private unsafe void InternalUpdate(Rectangle drawArea) { Rectangle rectangle = new Rectangle(drawArea.X - 2, drawArea.Y - 2, drawArea.Width + 4, drawArea.Height + 4); _drawArea = drawArea; Tile tile = null; fixed(LiquidCache *ptr = &_cache[0]) { LiquidCache *ptr2 = ptr; int num = rectangle.Height * 2 + 2; ptr2 = ptr; for (int i = rectangle.X; i < rectangle.X + rectangle.Width; i++) { for (int j = rectangle.Y; j < rectangle.Y + rectangle.Height; j++) { tile = _tiles[i, j]; if (tile == null) { tile = EMPTY_TILE; } ptr2->LiquidLevel = (float)(int)tile.liquid / 255f; ptr2->IsHalfBrick = (tile.halfBrick() && ptr2[-1].HasLiquid); ptr2->IsSolid = (WorldGen.SolidOrSlopedTile(tile) && !ptr2->IsHalfBrick); ptr2->HasLiquid = (tile.liquid != 0); ptr2->VisibleLiquidLevel = 0f; ptr2->HasWall = (tile.wall != 0); ptr2->Type = tile.liquidType(); if (ptr2->IsHalfBrick && !ptr2->HasLiquid) { ptr2->Type = ptr2[-1].Type; } ptr2++; } } ptr2 = ptr; float num2 = 0f; ptr2 += num; for (int k = 2; k < rectangle.Width - 2; k++) { for (int l = 2; l < rectangle.Height - 2; l++) { num2 = 0f; if (ptr2->IsHalfBrick && ptr2[-1].HasLiquid) { num2 = 1f; } else if (!ptr2->HasLiquid) { LiquidCache liquidCache = ptr2[-rectangle.Height]; LiquidCache liquidCache2 = ptr2[rectangle.Height]; LiquidCache liquidCache3 = ptr2[-1]; LiquidCache liquidCache4 = ptr2[1]; if (liquidCache.HasLiquid && liquidCache2.HasLiquid && liquidCache.Type == liquidCache2.Type) { num2 = liquidCache.LiquidLevel + liquidCache2.LiquidLevel; ptr2->Type = liquidCache.Type; } if (liquidCache3.HasLiquid && liquidCache4.HasLiquid && liquidCache3.Type == liquidCache4.Type) { num2 = Math.Max(num2, liquidCache3.LiquidLevel + liquidCache4.LiquidLevel); ptr2->Type = liquidCache3.Type; } num2 *= 0.5f; } else { num2 = ptr2->LiquidLevel; } ptr2->VisibleLiquidLevel = num2; ptr2->HasVisibleLiquid = (num2 != 0f); ptr2++; } ptr2 += 4; } ptr2 = ptr; for (int m = 0; m < rectangle.Width; m++) { for (int n = 0; n < rectangle.Height - 10; n++) { if (ptr2->HasVisibleLiquid && !ptr2->IsSolid) { ptr2->Opacity = 1f; ptr2->VisibleType = ptr2->Type; float num3 = 1f / (float)(WATERFALL_LENGTH[ptr2->Type] + 1); float num4 = 1f; for (int num5 = 1; num5 <= WATERFALL_LENGTH[ptr2->Type]; num5++) { num4 -= num3; if (ptr2[num5].IsSolid) { break; } ptr2[num5].VisibleLiquidLevel = Math.Max(ptr2[num5].VisibleLiquidLevel, ptr2->VisibleLiquidLevel * num4); ptr2[num5].Opacity = num4; ptr2[num5].VisibleType = ptr2->Type; } } if (ptr2->IsSolid) { ptr2->VisibleLiquidLevel = 1f; ptr2->HasVisibleLiquid = false; } else { ptr2->HasVisibleLiquid = (ptr2->VisibleLiquidLevel != 0f); } ptr2++; } ptr2 += 10; } ptr2 = ptr; ptr2 += num; for (int num6 = 2; num6 < rectangle.Width - 2; num6++) { for (int num7 = 2; num7 < rectangle.Height - 2; num7++) { if (!ptr2->HasVisibleLiquid || ptr2->IsSolid) { ptr2->HasLeftEdge = false; ptr2->HasTopEdge = false; ptr2->HasRightEdge = false; ptr2->HasBottomEdge = false; } else { LiquidCache liquidCache = ptr2[-1]; LiquidCache liquidCache2 = ptr2[1]; LiquidCache liquidCache3 = ptr2[-rectangle.Height]; LiquidCache liquidCache4 = ptr2[rectangle.Height]; float num8 = 0f; float num9 = 1f; float num10 = 0f; float num11 = 1f; float visibleLiquidLevel = ptr2->VisibleLiquidLevel; if (!liquidCache.HasVisibleLiquid) { num10 += liquidCache2.VisibleLiquidLevel * (1f - visibleLiquidLevel); } if (!liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid && !liquidCache2.IsHalfBrick) { num11 -= liquidCache.VisibleLiquidLevel * (1f - visibleLiquidLevel); } if (!liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid && !liquidCache3.IsHalfBrick) { num8 += liquidCache4.VisibleLiquidLevel * (1f - visibleLiquidLevel); } if (!liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid && !liquidCache4.IsHalfBrick) { num9 -= liquidCache3.VisibleLiquidLevel * (1f - visibleLiquidLevel); } ptr2->LeftWall = num8; ptr2->RightWall = num9; ptr2->BottomWall = num11; ptr2->TopWall = num10; Point zero = Point.Zero; ptr2->HasTopEdge = ((!liquidCache.HasVisibleLiquid && !liquidCache.IsSolid) || num10 != 0f); ptr2->HasBottomEdge = ((!liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid) || num11 != 1f); ptr2->HasLeftEdge = ((!liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid) || num8 != 0f); ptr2->HasRightEdge = ((!liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid) || num9 != 1f); if (!ptr2->HasLeftEdge) { if (ptr2->HasRightEdge) { zero.X += 32; } else { zero.X += 16; } } if (ptr2->HasLeftEdge && ptr2->HasRightEdge) { zero.X = 16; zero.Y += 32; if (ptr2->HasTopEdge) { zero.Y = 16; } } else if (!ptr2->HasTopEdge) { if (!ptr2->HasLeftEdge && !ptr2->HasRightEdge) { zero.Y += 48; } else { zero.Y += 16; } } if (zero.Y == 16 && (ptr2->HasLeftEdge ^ ptr2->HasRightEdge) && num7 + rectangle.Y % 2 == 0) { zero.Y += 16; } ptr2->FrameOffset = zero; } ptr2++; } ptr2 += 4; } ptr2 = ptr; ptr2 += num; for (int num12 = 2; num12 < rectangle.Width - 2; num12++) { for (int num13 = 2; num13 < rectangle.Height - 2; num13++) { if (ptr2->HasVisibleLiquid) { LiquidCache liquidCache = ptr2[-1]; LiquidCache liquidCache2 = ptr2[1]; LiquidCache liquidCache3 = ptr2[-rectangle.Height]; LiquidCache liquidCache4 = ptr2[rectangle.Height]; ptr2->VisibleLeftWall = ptr2->LeftWall; ptr2->VisibleRightWall = ptr2->RightWall; ptr2->VisibleTopWall = ptr2->TopWall; ptr2->VisibleBottomWall = ptr2->BottomWall; if (liquidCache.HasVisibleLiquid && liquidCache2.HasVisibleLiquid) { if (ptr2->HasLeftEdge) { ptr2->VisibleLeftWall = (ptr2->LeftWall * 2f + liquidCache.LeftWall + liquidCache2.LeftWall) * 0.25f; } if (ptr2->HasRightEdge) { ptr2->VisibleRightWall = (ptr2->RightWall * 2f + liquidCache.RightWall + liquidCache2.RightWall) * 0.25f; } } if (liquidCache3.HasVisibleLiquid && liquidCache4.HasVisibleLiquid) { if (ptr2->HasTopEdge) { ptr2->VisibleTopWall = (ptr2->TopWall * 2f + liquidCache3.TopWall + liquidCache4.TopWall) * 0.25f; } if (ptr2->HasBottomEdge) { ptr2->VisibleBottomWall = (ptr2->BottomWall * 2f + liquidCache3.BottomWall + liquidCache4.BottomWall) * 0.25f; } } } ptr2++; } ptr2 += 4; } ptr2 = ptr; ptr2 += num; for (int num14 = 2; num14 < rectangle.Width - 2; num14++) { for (int num15 = 2; num15 < rectangle.Height - 2; num15++) { if (ptr2->HasLiquid) { LiquidCache liquidCache = ptr2[-1]; LiquidCache liquidCache2 = ptr2[1]; LiquidCache liquidCache3 = ptr2[-rectangle.Height]; LiquidCache liquidCache4 = ptr2[rectangle.Height]; if (ptr2->HasTopEdge && !ptr2->HasBottomEdge && (ptr2->HasLeftEdge ^ ptr2->HasRightEdge)) { if (ptr2->HasRightEdge) { ptr2->VisibleRightWall = liquidCache2.VisibleRightWall; ptr2->VisibleTopWall = liquidCache3.VisibleTopWall; } else { ptr2->VisibleLeftWall = liquidCache2.VisibleLeftWall; ptr2->VisibleTopWall = liquidCache4.VisibleTopWall; } } else if (liquidCache2.FrameOffset.X == 16 && liquidCache2.FrameOffset.Y == 32) { if (ptr2->VisibleLeftWall > 0.5f) { ptr2->VisibleLeftWall = 0f; ptr2->FrameOffset = new Point(0, 0); } else if (ptr2->VisibleRightWall < 0.5f) { ptr2->VisibleRightWall = 1f; ptr2->FrameOffset = new Point(32, 0); } } } ptr2++; } ptr2 += 4; } ptr2 = ptr; ptr2 += num; for (int num16 = 2; num16 < rectangle.Width - 2; num16++) { for (int num17 = 2; num17 < rectangle.Height - 2; num17++) { if (ptr2->HasLiquid) { LiquidCache liquidCache = ptr2[-1]; LiquidCache liquidCache2 = ptr2[1]; LiquidCache liquidCache3 = ptr2[-rectangle.Height]; LiquidCache liquidCache4 = ptr2[rectangle.Height]; if (!ptr2->HasBottomEdge && !ptr2->HasLeftEdge && !ptr2->HasTopEdge && !ptr2->HasRightEdge) { if (liquidCache3.HasTopEdge && liquidCache.HasLeftEdge) { ptr2->FrameOffset.X = Math.Max(4, (int)(16f - liquidCache.VisibleLeftWall * 16f)) - 4; ptr2->FrameOffset.Y = 48 + Math.Max(4, (int)(16f - liquidCache3.VisibleTopWall * 16f)) - 4; ptr2->VisibleLeftWall = 0f; ptr2->VisibleTopWall = 0f; ptr2->VisibleRightWall = 1f; ptr2->VisibleBottomWall = 1f; } else if (liquidCache4.HasTopEdge && liquidCache.HasRightEdge) { ptr2->FrameOffset.X = 32 - Math.Min(16, (int)(liquidCache.VisibleRightWall * 16f) - 4); ptr2->FrameOffset.Y = 48 + Math.Max(4, (int)(16f - liquidCache4.VisibleTopWall * 16f)) - 4; ptr2->VisibleLeftWall = 0f; ptr2->VisibleTopWall = 0f; ptr2->VisibleRightWall = 1f; ptr2->VisibleBottomWall = 1f; } } } ptr2++; } ptr2 += 4; } ptr2 = ptr; ptr2 += num; fixed(LiquidDrawCache *ptr3 = &_drawCache[0]) { LiquidDrawCache *ptr4 = ptr3; for (int num18 = 2; num18 < rectangle.Width - 2; num18++) { for (int num19 = 2; num19 < rectangle.Height - 2; num19++) { if (ptr2->HasVisibleLiquid) { float num20 = Math.Min(0.75f, ptr2->VisibleLeftWall); float num21 = Math.Max(0.25f, ptr2->VisibleRightWall); float num22 = Math.Min(0.75f, ptr2->VisibleTopWall); float num23 = Math.Max(0.25f, ptr2->VisibleBottomWall); if (ptr2->IsHalfBrick && num23 > 0.5f) { num23 = 0.5f; } ptr4->IsVisible = (ptr2->HasWall || !ptr2->IsHalfBrick || !ptr2->HasLiquid); ptr4->SourceRectangle = new Rectangle((int)(16f - num21 * 16f) + ptr2->FrameOffset.X, (int)(16f - num23 * 16f) + ptr2->FrameOffset.Y, (int)Math.Ceiling((num21 - num20) * 16f), (int)Math.Ceiling((num23 - num22) * 16f)); ptr4->IsSurfaceLiquid = (ptr2->FrameOffset.X == 16 && ptr2->FrameOffset.Y == 0 && (double)(num19 + rectangle.Y) > Main.worldSurface - 40.0); ptr4->Opacity = ptr2->Opacity; ptr4->LiquidOffset = new Vector2((float)Math.Floor(num20 * 16f), (float)Math.Floor(num22 * 16f)); ptr4->Type = ptr2->VisibleType; ptr4->HasWall = ptr2->HasWall; } else { ptr4->IsVisible = false; } ptr2++; ptr4++; } ptr2 += 4; } } ptr2 = ptr; for (int num24 = rectangle.X; num24 < rectangle.X + rectangle.Width; num24++) { for (int num25 = rectangle.Y; num25 < rectangle.Y + rectangle.Height; num25++) { if (ptr2->VisibleType == 1 && ptr2->HasVisibleLiquid && Dust.lavaBubbles < 200) { if (_random.Next(700) == 0) { Dust.NewDust(new Vector2(num24 * 16, num25 * 16), 16, 16, 35, 0f, 0f, 0, Color.White); } if (_random.Next(350) == 0) { int num26 = Dust.NewDust(new Vector2(num24 * 16, num25 * 16), 16, 8, 35, 0f, 0f, 50, Color.White, 1.5f); Main.dust[num26].velocity *= 0.8f; Main.dust[num26].velocity.X *= 2f; Main.dust[num26].velocity.Y -= (float)_random.Next(1, 7) * 0.1f; if (_random.Next(10) == 0) { Main.dust[num26].velocity.Y *= _random.Next(2, 5); } Main.dust[num26].noGravity = true; } } ptr2++; } } } }
private unsafe void InternalUpdate(Rectangle drawArea) { Rectangle rectangle = new Rectangle(drawArea.X - 2, drawArea.Y - 2, drawArea.Width + 4, drawArea.Height + 4); _drawArea = drawArea; fixed(LiquidCache *liquidCachePtr1 = &_cache[0]) { int num1 = rectangle.Height * 2 + 2; LiquidCache *liquidCachePtr2 = liquidCachePtr1; for (int index1 = rectangle.X; index1 < rectangle.X + rectangle.Width; ++index1) { for (int index2 = rectangle.Y; index2 < rectangle.Y + rectangle.Height; ++index2) { Tile tile = _tiles[index1, index2] ?? EMPTY_TILE; liquidCachePtr2->LiquidLevel = (float)tile.liquid / (float)byte.MaxValue; liquidCachePtr2->IsHalfBrick = tile.halfBrick() && liquidCachePtr2[-1].HasLiquid; liquidCachePtr2->IsSolid = WorldGen.SolidOrSlopedTile(tile) && !liquidCachePtr2->IsHalfBrick; liquidCachePtr2->HasLiquid = (int)tile.liquid != 0; liquidCachePtr2->VisibleLiquidLevel = 0.0f; liquidCachePtr2->HasWall = (int)tile.wall != 0; liquidCachePtr2->Type = tile.liquidType(); if (liquidCachePtr2->IsHalfBrick && !liquidCachePtr2->HasLiquid) { liquidCachePtr2->Type = liquidCachePtr2[-1].Type; } ++liquidCachePtr2; } } LiquidCache *liquidCachePtr3 = liquidCachePtr1 + num1; LiquidCache liquidCache1; LiquidCache liquidCache2; LiquidCache liquidCache3; LiquidCache liquidCache4; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { float val1 = 0.0f; float num2; if (liquidCachePtr3->IsHalfBrick && liquidCachePtr3[-1].HasLiquid) { num2 = 1f; } else if (!liquidCachePtr3->HasLiquid) { liquidCache1 = liquidCachePtr3[-rectangle.Height]; liquidCache2 = liquidCachePtr3[rectangle.Height]; liquidCache3 = liquidCachePtr3[-1]; liquidCache4 = liquidCachePtr3[1]; if (liquidCache1.HasLiquid && liquidCache2.HasLiquid && liquidCache1.Type == liquidCache2.Type) { val1 = liquidCache1.LiquidLevel + liquidCache2.LiquidLevel; liquidCachePtr3->Type = liquidCache1.Type; } if (liquidCache3.HasLiquid && liquidCache4.HasLiquid && liquidCache3.Type == liquidCache4.Type) { val1 = Math.Max(val1, liquidCache3.LiquidLevel + liquidCache4.LiquidLevel); liquidCachePtr3->Type = liquidCache3.Type; } num2 = val1 * 0.5f; } else { num2 = liquidCachePtr3->LiquidLevel; } liquidCachePtr3->VisibleLiquidLevel = num2; liquidCachePtr3->HasVisibleLiquid = num2 != 0.0; ++liquidCachePtr3; } liquidCachePtr3 += 4; } LiquidCache *liquidCachePtr4 = liquidCachePtr1; for (int index1 = 0; index1 < rectangle.Width; ++index1) { for (int index2 = 0; index2 < rectangle.Height - 10; ++index2) { if (liquidCachePtr4->HasVisibleLiquid && !liquidCachePtr4->IsSolid) { liquidCachePtr4->Opacity = 1f; liquidCachePtr4->VisibleType = liquidCachePtr4->Type; float num2 = 1f / (float)(WATERFALL_LENGTH[liquidCachePtr4->Type] + 1); float num3 = 1f; for (int index3 = 1; index3 <= WATERFALL_LENGTH[liquidCachePtr4->Type]; ++index3) { num3 -= num2; if (!liquidCachePtr4[index3].IsSolid) { liquidCachePtr4[index3].VisibleLiquidLevel = Math.Max(liquidCachePtr4[index3].VisibleLiquidLevel, liquidCachePtr4->VisibleLiquidLevel * num3); liquidCachePtr4[index3].Opacity = num3; liquidCachePtr4[index3].VisibleType = liquidCachePtr4->Type; } else { break; } } } if (liquidCachePtr4->IsSolid) { liquidCachePtr4->VisibleLiquidLevel = 1f; liquidCachePtr4->HasVisibleLiquid = false; } else { liquidCachePtr4->HasVisibleLiquid = (double)liquidCachePtr4->VisibleLiquidLevel != 0.0; } ++liquidCachePtr4; } liquidCachePtr4 += 10; } LiquidCache *liquidCachePtr5 = liquidCachePtr1 + num1; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { if (!liquidCachePtr5->HasVisibleLiquid || liquidCachePtr5->IsSolid) { liquidCachePtr5->HasLeftEdge = false; liquidCachePtr5->HasTopEdge = false; liquidCachePtr5->HasRightEdge = false; liquidCachePtr5->HasBottomEdge = false; } else { liquidCache1 = liquidCachePtr5[-1]; liquidCache2 = liquidCachePtr5[1]; liquidCache3 = liquidCachePtr5[-rectangle.Height]; liquidCache4 = liquidCachePtr5[rectangle.Height]; float num2 = 0.0f; float num3 = 1f; float num4 = 0.0f; float num5 = 1f; float num6 = liquidCachePtr5->VisibleLiquidLevel; if (!liquidCache1.HasVisibleLiquid) { num4 += liquidCache2.VisibleLiquidLevel * (1f - num6); } if (!liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid && !liquidCache2.IsHalfBrick) { num5 -= liquidCache1.VisibleLiquidLevel * (1f - num6); } if (!liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid && !liquidCache3.IsHalfBrick) { num2 += liquidCache4.VisibleLiquidLevel * (1f - num6); } if (!liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid && !liquidCache4.IsHalfBrick) { num3 -= liquidCache3.VisibleLiquidLevel * (1f - num6); } liquidCachePtr5->LeftWall = num2; liquidCachePtr5->RightWall = num3; liquidCachePtr5->BottomWall = num5; liquidCachePtr5->TopWall = num4; Point zero = Point.Zero; liquidCachePtr5->HasTopEdge = !liquidCache1.HasVisibleLiquid && !liquidCache1.IsSolid || num4 != 0.0; liquidCachePtr5->HasBottomEdge = !liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid || num5 != 1.0; liquidCachePtr5->HasLeftEdge = !liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid || num2 != 0.0; liquidCachePtr5->HasRightEdge = !liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid || num3 != 1.0; if (!liquidCachePtr5->HasLeftEdge) { if (liquidCachePtr5->HasRightEdge) { zero.X += 32; } else { zero.X += 16; } } if (liquidCachePtr5->HasLeftEdge && liquidCachePtr5->HasRightEdge) { zero.X = 16; zero.Y += 32; if (liquidCachePtr5->HasTopEdge) { zero.Y = 16; } } else if (!liquidCachePtr5->HasTopEdge) { if (!liquidCachePtr5->HasLeftEdge && !liquidCachePtr5->HasRightEdge) { zero.Y += 48; } else { zero.Y += 16; } } if (zero.Y == 16 && liquidCachePtr5->HasLeftEdge ^ liquidCachePtr5->HasRightEdge && index2 + rectangle.Y % 2 == 0) { zero.Y += 16; } liquidCachePtr5->FrameOffset = zero; } ++liquidCachePtr5; } liquidCachePtr5 += 4; } LiquidCache *liquidCachePtr6 = liquidCachePtr1 + num1; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { if (liquidCachePtr6->HasVisibleLiquid) { liquidCache1 = liquidCachePtr6[-1]; liquidCache2 = liquidCachePtr6[1]; liquidCache3 = liquidCachePtr6[-rectangle.Height]; liquidCache4 = liquidCachePtr6[rectangle.Height]; liquidCachePtr6->VisibleLeftWall = liquidCachePtr6->LeftWall; liquidCachePtr6->VisibleRightWall = liquidCachePtr6->RightWall; liquidCachePtr6->VisibleTopWall = liquidCachePtr6->TopWall; liquidCachePtr6->VisibleBottomWall = liquidCachePtr6->BottomWall; if (liquidCache1.HasVisibleLiquid && liquidCache2.HasVisibleLiquid) { if (liquidCachePtr6->HasLeftEdge) { liquidCachePtr6->VisibleLeftWall = (float)((liquidCachePtr6->LeftWall * 2.0 + liquidCache1.LeftWall + liquidCache2.LeftWall) * 0.25); } if (liquidCachePtr6->HasRightEdge) { liquidCachePtr6->VisibleRightWall = (float)((liquidCachePtr6->RightWall * 2.0 + liquidCache1.RightWall + liquidCache2.RightWall) * 0.25); } } if (liquidCache3.HasVisibleLiquid && liquidCache4.HasVisibleLiquid) { if (liquidCachePtr6->HasTopEdge) { liquidCachePtr6->VisibleTopWall = (float)((liquidCachePtr6->TopWall * 2.0 + liquidCache3.TopWall + liquidCache4.TopWall) * 0.25); } if (liquidCachePtr6->HasBottomEdge) { liquidCachePtr6->VisibleBottomWall = (float)((liquidCachePtr6->BottomWall * 2.0 + liquidCache3.BottomWall + liquidCache4.BottomWall) * 0.25); } } } ++liquidCachePtr6; } liquidCachePtr6 += 4; } LiquidCache *liquidCachePtr7 = liquidCachePtr1 + num1; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { if (liquidCachePtr7->HasLiquid) { liquidCache1 = liquidCachePtr7[-1]; liquidCache2 = liquidCachePtr7[1]; liquidCache3 = liquidCachePtr7[-rectangle.Height]; liquidCache4 = liquidCachePtr7[rectangle.Height]; if (liquidCachePtr7->HasTopEdge && !liquidCachePtr7->HasBottomEdge && liquidCachePtr7->HasLeftEdge ^ liquidCachePtr7->HasRightEdge) { if (liquidCachePtr7->HasRightEdge) { liquidCachePtr7->VisibleRightWall = liquidCache2.VisibleRightWall; liquidCachePtr7->VisibleTopWall = liquidCache3.VisibleTopWall; } else { liquidCachePtr7->VisibleLeftWall = liquidCache2.VisibleLeftWall; liquidCachePtr7->VisibleTopWall = liquidCache4.VisibleTopWall; } } else if (liquidCache2.FrameOffset.X == 16 && liquidCache2.FrameOffset.Y == 32) { if (liquidCachePtr7->VisibleLeftWall > 0.5) { liquidCachePtr7->VisibleLeftWall = 0.0f; liquidCachePtr7->FrameOffset = new Point(0, 0); } else if (liquidCachePtr7->VisibleRightWall < 0.5) { liquidCachePtr7->VisibleRightWall = 1f; liquidCachePtr7->FrameOffset = new Point(32, 0); } } } ++liquidCachePtr7; } liquidCachePtr7 += 4; } LiquidCache *liquidCachePtr8 = liquidCachePtr1 + num1; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { if (liquidCachePtr8->HasLiquid) { liquidCache1 = liquidCachePtr8[-1]; liquidCache2 = liquidCachePtr8[1]; liquidCache3 = liquidCachePtr8[-rectangle.Height]; liquidCache4 = liquidCachePtr8[rectangle.Height]; if (!liquidCachePtr8->HasBottomEdge && !liquidCachePtr8->HasLeftEdge && (!liquidCachePtr8->HasTopEdge && !liquidCachePtr8->HasRightEdge)) { if (liquidCache3.HasTopEdge && liquidCache1.HasLeftEdge) { liquidCachePtr8->FrameOffset.X = Math.Max(4, (int)(16.0 - liquidCache1.VisibleLeftWall * 16.0)) - 4; liquidCachePtr8->FrameOffset.Y = 48 + Math.Max(4, (int)(16.0 - liquidCache3.VisibleTopWall * 16.0)) - 4; liquidCachePtr8->VisibleLeftWall = 0.0f; liquidCachePtr8->VisibleTopWall = 0.0f; liquidCachePtr8->VisibleRightWall = 1f; liquidCachePtr8->VisibleBottomWall = 1f; } else if (liquidCache4.HasTopEdge && liquidCache1.HasRightEdge) { liquidCachePtr8->FrameOffset.X = 32 - Math.Min(16, (int)(liquidCache1.VisibleRightWall * 16.0) - 4); liquidCachePtr8->FrameOffset.Y = 48 + Math.Max(4, (int)(16.0 - liquidCache4.VisibleTopWall * 16.0)) - 4; liquidCachePtr8->VisibleLeftWall = 0.0f; liquidCachePtr8->VisibleTopWall = 0.0f; liquidCachePtr8->VisibleRightWall = 1f; liquidCachePtr8->VisibleBottomWall = 1f; } } } ++liquidCachePtr8; } liquidCachePtr8 += 4; } LiquidCache *liquidCachePtr9 = liquidCachePtr1 + num1; fixed(LiquidDrawCache *liquidDrawCachePtr1 = &_drawCache[0]) { LiquidDrawCache *liquidDrawCachePtr2 = liquidDrawCachePtr1; for (int index1 = 2; index1 < rectangle.Width - 2; ++index1) { for (int index2 = 2; index2 < rectangle.Height - 2; ++index2) { if (liquidCachePtr9->HasVisibleLiquid) { float num2 = Math.Min(0.75f, liquidCachePtr9->VisibleLeftWall); float num3 = Math.Max(0.25f, liquidCachePtr9->VisibleRightWall); float num4 = Math.Min(0.75f, liquidCachePtr9->VisibleTopWall); float num5 = Math.Max(0.25f, liquidCachePtr9->VisibleBottomWall); if (liquidCachePtr9->IsHalfBrick && (double)num5 > 0.5) { num5 = 0.5f; } liquidDrawCachePtr2->IsVisible = liquidCachePtr9->HasWall || (!liquidCachePtr9->IsHalfBrick || !liquidCachePtr9->HasLiquid); liquidDrawCachePtr2->SourceRectangle = new Rectangle((int)(16.0 - num3 * 16.0) + liquidCachePtr9->FrameOffset.X, (int)(16.0 - num5 * 16.0) + liquidCachePtr9->FrameOffset.Y, (int)Math.Ceiling((num3 - num2) * 16.0), (int)Math.Ceiling((num5 - num4) * 16.0)); liquidDrawCachePtr2->IsSurfaceLiquid = liquidCachePtr9->FrameOffset.X == 16 && liquidCachePtr9->FrameOffset.Y == 0 && (index2 + rectangle.Y) > Main.worldSurface - 40.0; liquidDrawCachePtr2->Opacity = liquidCachePtr9->Opacity; liquidDrawCachePtr2->LiquidOffset = new Vector2((float)Math.Floor(num2 * 16.0), (float)Math.Floor(num4 * 16.0)); liquidDrawCachePtr2->Type = liquidCachePtr9->VisibleType; liquidDrawCachePtr2->HasWall = liquidCachePtr9->HasWall; } else { liquidDrawCachePtr2->IsVisible = false; } ++liquidCachePtr9; ++liquidDrawCachePtr2; } liquidCachePtr9 += 4; } } LiquidCache *liquidCachePtr10 = liquidCachePtr1; for (int index1 = rectangle.X; index1 < rectangle.X + rectangle.Width; ++index1) { for (int index2 = rectangle.Y; index2 < rectangle.Y + rectangle.Height; ++index2) { if ((int)liquidCachePtr10->VisibleType == 1 && liquidCachePtr10->HasVisibleLiquid && Dust.lavaBubbles < 200) { if (_random.Next(700) == 0) { Dust.NewDust(new Vector2((float)(index1 * 16), (float)(index2 * 16)), 16, 16, 35, 0.0f, 0.0f, 0, Color.White, 1f); } if (_random.Next(350) == 0) { int index3 = Dust.NewDust(new Vector2((float)(index1 * 16), (float)(index2 * 16)), 16, 8, 35, 0.0f, 0.0f, 50, Color.White, 1.5f); Main.dust[index3].velocity *= 0.8f; Main.dust[index3].velocity.X *= 2f; Main.dust[index3].velocity.Y -= (float)_random.Next(1, 7) * 0.1f; if (_random.Next(10) == 0) { Main.dust[index3].velocity.Y *= (float)_random.Next(2, 5); } Main.dust[index3].noGravity = true; } } ++liquidCachePtr10; } } } }