public static Boolean IsValidTreeRootTile(TileRef tile)
 {
     return tile.Active && (tile.Type == 2 || tile.Type == 23 || tile.Type == 60);
 }
예제 #2
0
        //this uses the new queue system for queries
        public void logTile(string playername, int x, int y, int action, int type, TileRef currentstate)
        {
            DateTime value = DateTime.Now;
            string time = value.ToString("yyyyMMddHHmmssffff");
            playername = playername.Replace("'", @"\'");

            //the following is to avoid changing the mysql tablestructure
            //with the TDSM b36 API changes
            string actionstring = "";
            int tile = 0;
            int wall = 0;
            string tiletype = "";
            if (action == 0) //remove tile
            {
                actionstring = "BREAK";
                tile = currentstate.Type;
                tiletype = "BLOCK";
            }
            else if (action == 1) //place tile
            {
                actionstring = "PLACED";
                tile = type;
                tiletype = "BLOCK";
            }
            else if (action == 2) //remove wall
            {
                actionstring = "BREAK";
                wall = currentstate.Wall;
                tiletype = "WALL";
            }
            else if (action == 3) //place wall
            {
                actionstring = "PLACED";
                wall = type;
                tiletype = "WALL";
            }
            else if (action == 4) //broke corruption thorns by walking through them
            {
                actionstring = "BREAK";
                tile = type;
                tiletype = "THORN";
                if (!logplants)
                    return;
            }
            else if (action > 4)
            {
                //invalid or unknown (to me) action
                ProgramLog.Error.Log("[Mysql] Invalid action send by player: " + playername);
                ProgramLog.Error.Log("[Mysql] Action not logged. Pester elevatorguy to add action #" + action + " to the action list!");
                return;
            }
            //logplants information
            //73 grass, 52 is vines
            //83 flower
            //32 and 24 is corruption grass
            //74, 62 jungle
            //71, 3 mushrooms
            if (!logplants && (tile == 73 || tile == 52 || tile == 83 || tile == 32 || tile == 24 || tile == 74 || tile == 62 || tile == 71 || tile == 3))
                return;
            // makes the query
            string query =
                "INSERT INTO terraria_tiles ( timestamp, player, x, y, action, tile, tiletype, wall ) " +
                "VALUES ( '" + time + "', '" + playername + "', '" + x + "', '" + y + "', '" + actionstring + "', '" + tile + "', '" + tiletype + "', '" + wall + "' );";

            //adds to queue
            q.add(query);
        }
 private static TileRef[,] GetTiles(int x, int y)
 {
     TileRef[,] tiles = new TileRef[3,3];
     for (int modX = 0; modX < 3; modX++)
     {
         for (int modY = 0; modY < 3; modY++)
         {
             tiles[modX, modY] = GetTile(x - 1 + modX, y - 1 + modY);
         }
     }
     return tiles;
 }
 /// <summary>
 /// Tries to find if a tile is within the region.
 /// </summary>
 /// <param name="tile>Tile to find in the region.</param>
 /// <returns>True on find</returns>
 public Boolean HasTile(TileRef tile)
 {
     return GetTiles.Contains(tile);
 }
예제 #5
0
파일: Liquid.cs 프로젝트: amarriner/Liquid
 public LiquidTile(int xIn, int yIn, TileRef tileIn)
 {
     x = xIn;
     y = yIn;
     tileRef = tileIn;
 }
        public static double QuickWater(int verbose = 0, int minY = -1, int maxY = -1, ProgressLogger prog = null)
        {
            int num = 0;

            if (minY == -1)
            {
                minY = 3;
            }

            if (maxY == -1)
            {
                maxY = Main.maxTilesY - 3;
            }

            for (int i = maxY; i >= minY; i--)
            {
                if (prog != null)
                {
                    if (verbose > 0)
                    {
                        float num2 = (float)(maxY - i) / (float)(maxY - minY + 1);
                        num2 /= (float)verbose;
                        //Main.statusText = "Settling liquids: " + (int)(num2 * 100f + 1f) + "%";
                        prog.Value += (int)(num2 * 100f + 1f);
                    }
                    else if (verbose < 0)
                    {
                        float num3 = (float)(maxY - i) / (float)(maxY - minY + 1);
                        num3 /= (float)(-(float)verbose);
                        //Main.statusText = "Creating underworld: " + (int)(num3 * 100f + 1f) + "%";
                        prog.Value += (int)(num3 * 100f + 1f);
                    }
                }

                for (int j = 0; j < 2; j++)
                {
                    int num4 = 2;
                    int num5 = Main.maxTilesX - 2;
                    int num6 = 1;
                    if (j == 1)
                    {
                        num4 = Main.maxTilesX - 2;
                        num5 = 2;
                        num6 = -1;
                    }
                    for (int num7 = num4; num7 != num5; num7 += num6)
                    {
                        if (Main.tile.At(num7, i).Liquid > 0)
                        {
                            int  num8  = -num6;
                            bool flag  = false;
                            int  num9  = num7;
                            int  num10 = i;
                            bool flag2 = Main.tile.At(num7, i).Lava;
                            byte b     = Main.tile.At(num7, i).Liquid;
                            Main.tile.At(num7, i).SetLiquid(0);
                            bool flag3 = true;
                            int  num11 = 0;
                            while (flag3 && num9 > 3 && num9 < Main.maxTilesX - 3 && num10 < Main.maxTilesY - 3)
                            {
                                flag3 = false;
                                while (Main.tile.At(num9, num10 + 1).Liquid == 0 && num10 < Main.maxTilesY - 5 && (!Main.tile.At(num9, num10 + 1).Active || !Main.tileSolid[(int)Main.tile.At(num9, num10 + 1).Type] || Main.tileSolidTop[(int)Main.tile.At(num9, num10 + 1).Type]))
                                {
                                    flag  = true;
                                    num8  = num6;
                                    num11 = 0;
                                    flag3 = true;
                                    num10++;
                                    if (num10 > WorldModify.waterLine)
                                    {
                                        flag2 = true;
                                    }
                                }
                                if (Main.tile.At(num9, num10 + 1).Liquid > 0 && Main.tile.At(num9, num10 + 1).Liquid < 255 && Main.tile.At(num9, num10 + 1).Lava == flag2)
                                {
                                    int num12 = (int)(255 - Main.tile.At(num9, num10 + 1).Liquid);
                                    if (num12 > (int)b)
                                    {
                                        num12 = (int)b;
                                    }
                                    TileRef expr_25A = Main.tile.At(num9, num10 + 1);
                                    expr_25A.AddLiquid((byte)num12);
                                    b -= (byte)num12;
                                    if (b <= 0)
                                    {
                                        num++;
                                        break;
                                    }
                                }
                                if (num11 == 0)
                                {
                                    if (Main.tile.At(num9 + num8, num10).Liquid == 0 && (!Main.tile.At(num9 + num8, num10).Active || !Main.tileSolid[(int)Main.tile.At(num9 + num8, num10).Type] || Main.tileSolidTop[(int)Main.tile.At(num9 + num8, num10).Type]))
                                    {
                                        num11 = num8;
                                    }
                                    else
                                    {
                                        if (Main.tile.At(num9 - num8, num10).Liquid == 0 && (!Main.tile.At(num9 - num8, num10).Active || !Main.tileSolid[(int)Main.tile.At(num9 - num8, num10).Type] || Main.tileSolidTop[(int)Main.tile.At(num9 - num8, num10).Type]))
                                        {
                                            num11 = -num8;
                                        }
                                    }
                                }
                                if (num11 != 0 && Main.tile.At(num9 + num11, num10).Liquid == 0 && (!Main.tile.At(num9 + num11, num10).Active || !Main.tileSolid[(int)Main.tile.At(num9 + num11, num10).Type] || Main.tileSolidTop[(int)Main.tile.At(num9 + num11, num10).Type]))
                                {
                                    flag3 = true;
                                    num9 += num11;
                                }
                                if (flag && !flag3)
                                {
                                    flag  = false;
                                    flag3 = true;
                                    num8  = -num6;
                                    num11 = 0;
                                }
                            }
                            if (num7 != num9 && i != num10)
                            {
                                num++;
                            }
                            Main.tile.At(num9, num10).SetLiquid(b);
                            Main.tile.At(num9, num10).SetLava(flag2);
                            if (Main.tile.At(num9 - 1, num10).Liquid > 0 && Main.tile.At(num9 - 1, num10).Lava != flag2)
                            {
                                if (flag2)
                                {
                                    Liquid.LavaCheck(num9, num10);
                                }
                                else
                                {
                                    Liquid.LavaCheck(num9 - 1, num10);
                                }
                            }
                            else
                            {
                                if (Main.tile.At(num9 + 1, num10).Liquid > 0 && Main.tile.At(num9 + 1, num10).Lava != flag2)
                                {
                                    if (flag2)
                                    {
                                        Liquid.LavaCheck(num9, num10);
                                    }
                                    else
                                    {
                                        Liquid.LavaCheck(num9 + 1, num10);
                                    }
                                }
                                else
                                {
                                    if (Main.tile.At(num9, num10 - 1).Liquid > 0 && Main.tile.At(num9, num10 - 1).Lava != flag2)
                                    {
                                        if (flag2)
                                        {
                                            Liquid.LavaCheck(num9, num10);
                                        }
                                        else
                                        {
                                            Liquid.LavaCheck(num9, num10 - 1);
                                        }
                                    }
                                    else
                                    {
                                        if (Main.tile.At(num9, num10 + 1).Liquid > 0 && Main.tile.At(num9, num10 + 1).Lava != flag2)
                                        {
                                            if (flag2)
                                            {
                                                Liquid.LavaCheck(num9, num10);
                                            }
                                            else
                                            {
                                                Liquid.LavaCheck(num9, num10 + 1);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return((double)num);
        }
        public void Update()
        {
            if (Main.tile.At(this.x, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x, this.y).Type])
            {
                if (Main.tile.At(this.x, this.y).Type != 10)
                {
                    Main.tile.At(this.x, this.y).SetLiquid(0);
                }
                this.kill = 9;
                return;
            }
            byte  liquid = Main.tile.At(this.x, this.y).Liquid;
            float num    = 0f;

            if (this.y > Main.maxTilesY - 200 && !Main.tile.At(this.x, this.y).Lava&& Main.tile.At(this.x, this.y).Liquid > 0)
            {
                byte b = 2;
                if (Main.tile.At(this.x, this.y).Liquid < b)
                {
                    b = Main.tile.At(this.x, this.y).Liquid;
                }
                TileRef expr_16F = Main.tile.At(this.x, this.y);
                expr_16F.AddLiquid(-b);
            }

            if (Main.tile.At(this.x, this.y).Liquid == 0)
            {
                this.kill = 9;
                return;
            }

            if (Main.tile.At(this.x, this.y).Lava)
            {
                Liquid.LavaCheck(this.x, this.y);
                if (!Liquid.quickFall)
                {
                    if (this.delay < 5)
                    {
                        this.delay++;
                        return;
                    }
                    this.delay = 0;
                }
            }
            else
            {
                if (Main.tile.At(this.x - 1, this.y).Lava)
                {
                    Liquid.AddWater(this.x - 1, this.y);
                }
                if (Main.tile.At(this.x + 1, this.y).Lava)
                {
                    Liquid.AddWater(this.x + 1, this.y);
                }
                if (Main.tile.At(this.x, this.y - 1).Lava)
                {
                    Liquid.AddWater(this.x, this.y - 1);
                }
                if (Main.tile.At(this.x, this.y + 1).Lava)
                {
                    Liquid.AddWater(this.x, this.y + 1);
                }
            }

            if ((!Main.tile.At(this.x, this.y + 1).Active || !Main.tileSolid[(int)Main.tile.At(this.x, this.y + 1).Type] || Main.tileSolidTop[(int)Main.tile.At(this.x, this.y + 1).Type]) && (Main.tile.At(this.x, this.y + 1).Liquid <= 0 || Main.tile.At(this.x, this.y + 1).Lava == Main.tile.At(this.x, this.y).Lava) && Main.tile.At(this.x, this.y + 1).Liquid < 255)
            {
                num = (float)(255 - Main.tile.At(this.x, this.y + 1).Liquid);
                if (num > (float)Main.tile.At(this.x, this.y).Liquid)
                {
                    num = (float)Main.tile.At(this.x, this.y).Liquid;
                }
                TileRef expr_42E = Main.tile.At(this.x, this.y);
                expr_42E.AddLiquid(-(byte)num);
                TileRef expr_455 = Main.tile.At(this.x, this.y + 1);
                expr_455.AddLiquid(+(byte)num);
                Main.tile.At(this.x, this.y + 1).SetLava(Main.tile.At(this.x, this.y).Lava);
                Liquid.AddWater(this.x, this.y + 1);
                Main.tile.At(this.x, this.y + 1).SetSkipLiquid(true);
                Main.tile.At(this.x, this.y).SetSkipLiquid(true);
                if (Main.tile.At(this.x, this.y).Liquid > 250)
                {
                    Main.tile.At(this.x, this.y).SetLiquid(255);
                }
                else
                {
                    Liquid.AddWater(this.x - 1, this.y);
                    Liquid.AddWater(this.x + 1, this.y);
                }
            }

            if (Main.tile.At(this.x, this.y).Liquid > 0)
            {
                bool flag  = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (Main.tile.At(this.x - 1, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x - 1, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x - 1, this.y).Type])
                {
                    flag = false;
                }
                else if (Main.tile.At(this.x - 1, this.y).Liquid > 0 && Main.tile.At(this.x - 1, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                {
                    flag = false;
                }
                else if (Main.tile.At(this.x - 2, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x - 2, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x - 2, this.y).Type])
                {
                    flag3 = false;
                }
                else if (Main.tile.At(this.x - 2, this.y).Liquid == 0)
                {
                    flag3 = false;
                }
                else if (Main.tile.At(this.x - 2, this.y).Liquid > 0 && Main.tile.At(this.x - 2, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                {
                    flag3 = false;
                }

                if (Main.tile.At(this.x + 1, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x + 1, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x + 1, this.y).Type])
                {
                    flag2 = false;
                }
                else
                {
                    if (Main.tile.At(this.x + 1, this.y).Liquid > 0 && Main.tile.At(this.x + 1, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                    {
                        flag2 = false;
                    }
                    else
                    {
                        if (Main.tile.At(this.x + 2, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x + 2, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x + 2, this.y).Type])
                        {
                            flag4 = false;
                        }
                        else
                        {
                            if (Main.tile.At(this.x + 2, this.y).Liquid == 0)
                            {
                                flag4 = false;
                            }
                            else
                            {
                                if (Main.tile.At(this.x + 2, this.y).Liquid > 0 && Main.tile.At(this.x + 2, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                                {
                                    flag4 = false;
                                }
                            }
                        }
                    }
                }
                int num2 = 0;
                if (Main.tile.At(this.x, this.y).Liquid < 3)
                {
                    num2 = -1;
                }
                if (flag && flag2)
                {
                    if (flag3 && flag4)
                    {
                        bool flag5 = true;
                        bool flag6 = true;
                        if (Main.tile.At(this.x - 3, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x - 3, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x - 3, this.y).Type])
                        {
                            flag5 = false;
                        }
                        else
                        {
                            if (Main.tile.At(this.x - 3, this.y).Liquid == 0)
                            {
                                flag5 = false;
                            }
                            else
                            {
                                if (Main.tile.At(this.x - 3, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                                {
                                    flag5 = false;
                                }
                            }
                        }
                        if (Main.tile.At(this.x + 3, this.y).Active&& Main.tileSolid[(int)Main.tile.At(this.x + 3, this.y).Type] && !Main.tileSolidTop[(int)Main.tile.At(this.x + 3, this.y).Type])
                        {
                            flag6 = false;
                        }
                        else
                        {
                            if (Main.tile.At(this.x + 3, this.y).Liquid == 0)
                            {
                                flag6 = false;
                            }
                            else
                            {
                                if (Main.tile.At(this.x + 3, this.y).Lava != Main.tile.At(this.x, this.y).Lava)
                                {
                                    flag6 = false;
                                }
                            }
                        }
                        if (flag5 && flag6)
                        {
                            num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x - 2, this.y).Liquid + Main.tile.At(this.x + 2, this.y).Liquid + Main.tile.At(this.x - 3, this.y).Liquid + Main.tile.At(this.x + 3, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                            num = (float)Math.Round((double)(num / 7f));
                            int num3 = 0;
                            Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 1, this.y);
                                Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                                Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            Main.tile.At(this.x - 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 2, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 2, this.y);
                                Main.tile.At(this.x - 2, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            Main.tile.At(this.x + 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 2, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 2, this.y);
                                Main.tile.At(this.x + 2, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            Main.tile.At(this.x - 3, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 3, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 3, this.y);
                                Main.tile.At(this.x - 3, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            Main.tile.At(this.x + 3, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 3, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 3, this.y);
                                Main.tile.At(this.x + 3, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num3++;
                            }
                            if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 1, this.y);
                            }
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                            }
                            if (Main.tile.At(this.x - 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 2, this.y);
                            }
                            if (Main.tile.At(this.x + 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 2, this.y);
                            }
                            if (Main.tile.At(this.x - 3, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 3, this.y);
                            }
                            if (Main.tile.At(this.x + 3, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 3, this.y);
                            }
                            if (num3 != 6 || Main.tile.At(this.x, this.y - 1).Liquid <= 0)
                            {
                                Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                            }
                        }
                        else
                        {
                            int num4 = 0;
                            num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x - 2, this.y).Liquid + Main.tile.At(this.x + 2, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                            num = (float)Math.Round((double)(num / 5f));
                            Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 1, this.y);
                                Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num4++;
                            }
                            Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                                Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num4++;
                            }
                            Main.tile.At(this.x - 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 2, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 2, this.y);
                                Main.tile.At(this.x - 2, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num4++;
                            }
                            Main.tile.At(this.x + 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 2, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 2, this.y);
                                Main.tile.At(this.x + 2, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num4++;
                            }
                            if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 1, this.y);
                            }
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                            }
                            if (Main.tile.At(this.x - 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 2, this.y);
                            }
                            if (Main.tile.At(this.x + 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 2, this.y);
                            }
                            if (num4 != 4 || Main.tile.At(this.x, this.y - 1).Liquid <= 0)
                            {
                                Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                            }
                        }
                    }
                    else
                    {
                        if (flag3)
                        {
                            num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x - 2, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                            num = (float)Math.Round((double)(num / 4f) + 0.001);
                            Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x - 1, this.y);
                                Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                            }
                            Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                                Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                            }
                            Main.tile.At(this.x - 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x - 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                            {
                                Main.tile.At(this.x - 2, this.y).SetLiquid((byte)num);
                                Liquid.AddWater(this.x - 2, this.y);
                            }
                            Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                        }
                        else
                        {
                            if (flag4)
                            {
                                num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x + 2, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                                num = (float)Math.Round((double)(num / 4f) + 0.001);
                                Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                                if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                                {
                                    Liquid.AddWater(this.x - 1, this.y);
                                    Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                                }
                                Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                                if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                                {
                                    Liquid.AddWater(this.x + 1, this.y);
                                    Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                                }
                                Main.tile.At(this.x + 2, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                                if (Main.tile.At(this.x + 2, this.y).Liquid != (byte)num || Main.tile.At(this.x, this.y).Liquid != (byte)num)
                                {
                                    Main.tile.At(this.x + 2, this.y).SetLiquid((byte)num);
                                    Liquid.AddWater(this.x + 2, this.y);
                                }
                                Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                            }
                            else
                            {
                                num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                                num = (float)Math.Round((double)(num / 3f) + 0.001);
                                Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                                if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                                {
                                    Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                                }
                                if (Main.tile.At(this.x, this.y).Liquid != (byte)num || Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                                {
                                    Liquid.AddWater(this.x - 1, this.y);
                                }
                                Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                                if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                                {
                                    Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                                }
                                if (Main.tile.At(this.x, this.y).Liquid != (byte)num || Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                                {
                                    Liquid.AddWater(this.x + 1, this.y);
                                }
                                Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                            }
                        }
                    }
                }
                else
                {
                    if (flag)
                    {
                        num = (float)((int)(Main.tile.At(this.x - 1, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                        num = (float)Math.Round((double)(num / 2f) + 0.001);
                        if (Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                        {
                            Main.tile.At(this.x - 1, this.y).SetLiquid((byte)num);
                        }
                        Main.tile.At(this.x - 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                        if (Main.tile.At(this.x, this.y).Liquid != (byte)num || Main.tile.At(this.x - 1, this.y).Liquid != (byte)num)
                        {
                            Liquid.AddWater(this.x - 1, this.y);
                        }
                        Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                    }
                    else
                    {
                        if (flag2)
                        {
                            num = (float)((int)(Main.tile.At(this.x + 1, this.y).Liquid + Main.tile.At(this.x, this.y).Liquid) + num2);
                            num = (float)Math.Round((double)(num / 2f) + 0.001);
                            if (Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                            {
                                Main.tile.At(this.x + 1, this.y).SetLiquid((byte)num);
                            }
                            Main.tile.At(this.x + 1, this.y).SetLava(Main.tile.At(this.x, this.y).Lava);
                            if (Main.tile.At(this.x, this.y).Liquid != (byte)num || Main.tile.At(this.x + 1, this.y).Liquid != (byte)num)
                            {
                                Liquid.AddWater(this.x + 1, this.y);
                            }
                            Main.tile.At(this.x, this.y).SetLiquid((byte)num);
                        }
                    }
                }
            }
            if (Main.tile.At(this.x, this.y).Liquid == liquid)
            {
                this.kill++;
                return;
            }
            if (Main.tile.At(this.x, this.y).Liquid == 254 && liquid == 255)
            {
                Main.tile.At(this.x, this.y).SetLiquid(255);
                this.kill++;
                return;
            }
            Liquid.AddWater(this.x, this.y - 1);
            this.kill = 0;
        }