active() public method

public active ( ) : bool
return bool
コード例 #1
0
        public static bool IsTileTheSame(Tile tile1, Tile tile2)
        {
            if (tile1.active() != tile2.active())
                return false;

            if (tile1.active())
            {
                if (tile1.type != tile2.type)
                    return false;

                if (Main.tileFrameImportant[(int)tile1.type])
                {
                    if ((tile1.frameX != tile2.frameX) || (tile1.frameX != tile2.frameX))
                        return false;
                }
            }
            return
                tile1.wall == tile2.wall
                &&
                tile1.liquid == tile2.liquid
                &&
                tile1.lava() == tile2.lava()
                &&
                tile1.wire() == tile2.wire()
                &&
                tile1.wire2() == tile2.wire2()
                &&
                tile1.wire3() == tile2.wire3();
        }
コード例 #2
0
ファイル: Tile.cs プロジェクト: jfort/TerrariaAPI-Server
 public bool isTheSameAs(Tile compTile)
 {
     if (compTile == null)
     {
         return false;
     }
     if (this.active() != compTile.active())
     {
         return false;
     }
     if (this.active())
     {
         if (this.type != compTile.type)
         {
             return false;
         }
         if (Main.tileFrameImportant[(int)this.type])
         {
             if (this.frameX != compTile.frameX)
             {
                 return false;
             }
             if (this.frameY != compTile.frameY)
             {
                 return false;
             }
         }
     }
     if (this.wall != compTile.wall)
     {
         return false;
     }
     if (this.liquid != compTile.liquid)
     {
         return false;
     }
     if (this.liquid > 0)
     {
         if (this.lava() != compTile.lava())
         {
             return false;
         }
         if (this.honey() != compTile.honey())
         {
             return false;
         }
     }
     return this.wire() == compTile.wire() && this.wire2() == compTile.wire2() && this.wire3() == compTile.wire3() && this.halfBrick() == compTile.halfBrick() && this.actuator() == compTile.actuator() && this.inActive() == compTile.inActive() && this.wallColor() == compTile.wallColor() && this.color() == compTile.color() && this.slope() == compTile.slope();
 }
コード例 #3
0
        public static Tile ReadTile(this BinaryReader reader)
        {
            Tile tile = new Tile();
            tile.sTileHeader = reader.ReadInt16();
            tile.bTileHeader = reader.ReadByte();
            tile.bTileHeader2 = reader.ReadByte();

            // Tile type
            if (tile.active())
            {
                tile.type = reader.ReadUInt16();
                if (Main.tileFrameImportant[tile.type])
                {
                    tile.frameX = reader.ReadInt16();
                    tile.frameY = reader.ReadInt16();
                }
            }
            tile.wall = reader.ReadByte();
            tile.liquid = reader.ReadByte();
            return tile;
        }
コード例 #4
0
ファイル: TileIO.cs プロジェクト: guyde2011/tModLoader
 private static bool HasModData(Tile tile)
 {
     return (tile.active() && tile.type >= TileID.Count) || tile.wall >= WallID.Count;
 }
コード例 #5
0
ファイル: TileObjectData.cs プロジェクト: sylar605/TshockCN
 public static TileObjectData GetTileData(Tile getTile)
 {
     int num;
     if (getTile == null || !getTile.active())
     {
         return null;
     }
     int num1 = getTile.type;
     if (num1 < 0 || num1 >= TileObjectData._data.Count)
     {
         throw new ArgumentOutOfRangeException("Function called with a bad tile type");
     }
     TileObjectData item = TileObjectData._data[num1];
     if (item == null)
     {
         return null;
     }
     int num2 = getTile.frameX / item.CoordinateFullWidth;
     int num3 = getTile.frameY / item.CoordinateFullHeight;
     int styleWrapLimit = item.StyleWrapLimit;
     if (styleWrapLimit == 0)
     {
         styleWrapLimit = 1;
     }
     num = (!item.StyleHorizontal ? num2 * styleWrapLimit + num3 : num3 * styleWrapLimit + num2);
     int styleMultiplier = num / item.StyleMultiplier;
     int styleMultiplier1 = num % item.StyleMultiplier;
     if (item.SubTiles != null && styleMultiplier >= 0 && styleMultiplier < item.SubTiles.Count)
     {
         TileObjectData tileObjectDatum = item.SubTiles[styleMultiplier];
         if (tileObjectDatum != null)
         {
             item = tileObjectDatum;
         }
     }
     if (item._alternates != null)
     {
         for (int i = 0; i < item.Alternates.Count; i++)
         {
             TileObjectData item1 = item.Alternates[i];
             if (item1 != null && styleMultiplier1 >= item1.Style && styleMultiplier1 <= item1.Style + item1.RandomStyleRange)
             {
                 return item1;
             }
         }
     }
     return item;
 }
コード例 #6
0
ファイル: TileObjectData.cs プロジェクト: EmuDevs/EDTerraria
 public static TileObjectData GetTileData(Tile getTile)
 {
     if (getTile == null || !getTile.active())
         return (TileObjectData)null;
     int index1 = (int)getTile.type;
     if (index1 < 0 || index1 >= TileObjectData._data.Count)
         throw new ArgumentOutOfRangeException("Function called with a bad tile type");
     TileObjectData tileObjectData1 = TileObjectData._data[index1];
     if (tileObjectData1 == null)
         return (TileObjectData)null;
     int num1 = (int)getTile.frameX / tileObjectData1.CoordinateFullWidth;
     int num2 = (int)getTile.frameY / tileObjectData1.CoordinateFullHeight;
     int num3 = tileObjectData1.StyleWrapLimit;
     if (num3 == 0)
         num3 = 1;
     int num4 = !tileObjectData1.StyleHorizontal ? num1 * num3 + num2 : num2 * num3 + num1;
     int index2 = num4 / tileObjectData1.StyleMultiplier;
     int num5 = num4 % tileObjectData1.StyleMultiplier;
     if (tileObjectData1._subTiles != null && index2 >= 0 && index2 < tileObjectData1.SubTiles.Count)
     {
         TileObjectData tileObjectData2 = tileObjectData1.SubTiles[index2];
         if (tileObjectData2 != null)
             tileObjectData1 = tileObjectData2;
     }
     if (tileObjectData1._alternates != null)
     {
         for (int index3 = 0; index3 < tileObjectData1.Alternates.Count; ++index3)
         {
             TileObjectData tileObjectData2 = tileObjectData1.Alternates[index3];
             if (tileObjectData2 != null && num5 >= tileObjectData2.Style && num5 <= tileObjectData2.Style + tileObjectData2.RandomStyleRange)
                 return tileObjectData2;
         }
     }
     return tileObjectData1;
 }
コード例 #7
0
 public static bool validateWorld(string validatePath)
 {
     Stopwatch stopwatch = new Stopwatch();
     stopwatch.Start();
     if (WorldGen.genRand == null)
     {
         WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
     }
     bool result;
     using (FileStream fileStream = new FileStream(validatePath, FileMode.Open))
     {
         using (BinaryReader binaryReader = new BinaryReader(fileStream))
         {
             try
             {
                 int num = binaryReader.ReadInt32();
                 if (num > Main.curRelease)
                 {
                     try
                     {
                         binaryReader.Close();
                         fileStream.Close();
                     }
                     catch
                     {
                     }
                     result = false;
                 }
                 else
                 {
                     string b = binaryReader.ReadString();
                     int num2 = binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     int num3 = binaryReader.ReadInt32();
                     int num4 = binaryReader.ReadInt32();
                     if (num >= 63)
                     {
                         binaryReader.ReadByte();
                     }
                     if (num >= 44)
                     {
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                     }
                     if (num >= 60)
                     {
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         if (num >= 61)
                         {
                             binaryReader.ReadInt32();
                             binaryReader.ReadInt32();
                         }
                     }
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadDouble();
                     binaryReader.ReadDouble();
                     binaryReader.ReadDouble();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadInt32();
                     binaryReader.ReadBoolean();
                     if (num >= 70)
                     {
                         binaryReader.ReadBoolean();
                     }
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     if (num >= 56)
                     {
                         binaryReader.ReadBoolean();
                     }
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     if (num >= 66)
                     {
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 44)
                     {
                         binaryReader.ReadBoolean();
                         binaryReader.ReadBoolean();
                         binaryReader.ReadBoolean();
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 64)
                     {
                         binaryReader.ReadBoolean();
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 29)
                     {
                         binaryReader.ReadBoolean();
                         binaryReader.ReadBoolean();
                         if (num >= 34)
                         {
                             binaryReader.ReadBoolean();
                         }
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 32)
                     {
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 37)
                     {
                         binaryReader.ReadBoolean();
                     }
                     if (num >= 56)
                     {
                         binaryReader.ReadBoolean();
                     }
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadByte();
                     if (num >= 23)
                     {
                         binaryReader.ReadInt32();
                         binaryReader.ReadBoolean();
                     }
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadDouble();
                     if (num >= 53)
                     {
                         binaryReader.ReadBoolean();
                         binaryReader.ReadInt32();
                         binaryReader.ReadSingle();
                     }
                     if (num >= 54)
                     {
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                     }
                     if (num >= 55)
                     {
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                     }
                     if (num >= 60)
                     {
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                         binaryReader.ReadByte();
                     }
                     if (num >= 60)
                     {
                         binaryReader.ReadInt32();
                     }
                     if (num >= 62)
                     {
                         binaryReader.ReadInt16();
                         binaryReader.ReadSingle();
                     }
                     for (int i = 0; i < num4; i++)
                     {
                         float num5 = (float)i / (float)Main.maxTilesX;
                         Main.statusText = string.Concat(new object[]
                         {
                             Lang.gen[73],
                             " ",
                             (int)(num5 * 100f + 1f),
                             "%"
                         });
                         for (int j = 0; j < num3; j++)
                         {
                             Tile tile = new Tile();
                             tile.active(binaryReader.ReadBoolean());
                             if (tile.active())
                             {
                                 tile.type = binaryReader.ReadByte();
                                 if (tile.type == 127)
                                 {
                                     tile.active(false);
                                 }
                                 if (num < 72 && (tile.type == 35 || tile.type == 36 || tile.type == 170 || tile.type == 171 || tile.type == 172))
                                 {
                                     tile.frameX = binaryReader.ReadInt16();
                                     tile.frameY = binaryReader.ReadInt16();
                                 }
                                 else if (Main.tileFrameImportant[(int)tile.type])
                                 {
                                     if (num < 28 && tile.type == 4)
                                     {
                                         tile.frameX = 0;
                                         tile.frameY = 0;
                                     }
                                     else if (num < 40 && tile.type == 19)
                                     {
                                         tile.frameX = 0;
                                         tile.frameY = 0;
                                     }
                                     else
                                     {
                                         tile.frameX = binaryReader.ReadInt16();
                                         tile.frameY = binaryReader.ReadInt16();
                                         if (tile.type == 144)
                                         {
                                             tile.frameY = 0;
                                         }
                                     }
                                 }
                                 else
                                 {
                                     tile.frameX = -1;
                                     tile.frameY = -1;
                                 }
                                 if (num >= 48 && binaryReader.ReadBoolean())
                                 {
                                     tile.color(binaryReader.ReadByte());
                                 }
                             }
                             if (num <= 25)
                             {
                                 binaryReader.ReadBoolean();
                             }
                             if (binaryReader.ReadBoolean())
                             {
                                 tile.wall = binaryReader.ReadByte();
                                 if (num >= 48 && binaryReader.ReadBoolean())
                                 {
                                     tile.wallColor(binaryReader.ReadByte());
                                 }
                             }
                             if (binaryReader.ReadBoolean())
                             {
                                 tile.liquid = binaryReader.ReadByte();
                                 tile.lava(binaryReader.ReadBoolean());
                                 if (num >= 51)
                                 {
                                     tile.honey(binaryReader.ReadBoolean());
                                 }
                             }
                             if (num >= 33)
                             {
                                 tile.wire(binaryReader.ReadBoolean());
                             }
                             if (num >= 43)
                             {
                                 tile.wire2(binaryReader.ReadBoolean());
                                 tile.wire3(binaryReader.ReadBoolean());
                             }
                             if (num >= 41)
                             {
                                 tile.halfBrick(binaryReader.ReadBoolean());
                                 if (!Main.tileSolid[(int)tile.type])
                                 {
                                     tile.halfBrick(false);
                                 }
                                 if (num >= 49)
                                 {
                                     tile.slope(binaryReader.ReadByte());
                                     if (!Main.tileSolid[(int)tile.type])
                                     {
                                         tile.slope(0);
                                     }
                                 }
                             }
                             if (num >= 42)
                             {
                                 tile.actuator(binaryReader.ReadBoolean());
                                 tile.inActive(binaryReader.ReadBoolean());
                             }
                             if (num >= 25)
                             {
                                 int num6 = (int)binaryReader.ReadInt16();
                                 j += num6;
                             }
                         }
                     }
                     int num7 = 40;
                     if (num < 58)
                     {
                         num7 = 20;
                     }
                     for (int k = 0; k < 1000; k++)
                     {
                         if (binaryReader.ReadBoolean())
                         {
                             binaryReader.ReadInt32();
                             binaryReader.ReadInt32();
                             for (int l = 0; l < 40; l++)
                             {
                                 if (l < num7)
                                 {
                                     int num8;
                                     if (num >= 59)
                                     {
                                         num8 = (int)binaryReader.ReadInt16();
                                     }
                                     else
                                     {
                                         num8 = (int)binaryReader.ReadByte();
                                     }
                                     if (num8 > 0)
                                     {
                                         if (num >= 38)
                                         {
                                             binaryReader.ReadInt32();
                                         }
                                         else
                                         {
                                             binaryReader.ReadString();
                                         }
                                         binaryReader.ReadByte();
                                     }
                                 }
                             }
                         }
                     }
                     for (int m = 0; m < 1000; m++)
                     {
                         if (binaryReader.ReadBoolean())
                         {
                             binaryReader.ReadString();
                             binaryReader.ReadInt32();
                             binaryReader.ReadInt32();
                         }
                     }
                     bool flag = binaryReader.ReadBoolean();
                     int num9 = 0;
                     while (flag)
                     {
                         binaryReader.ReadString();
                         binaryReader.ReadSingle();
                         binaryReader.ReadSingle();
                         binaryReader.ReadBoolean();
                         binaryReader.ReadInt32();
                         binaryReader.ReadInt32();
                         flag = binaryReader.ReadBoolean();
                         num9++;
                     }
                     if (num >= 31)
                     {
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         binaryReader.ReadString();
                         if (num >= 35)
                         {
                             binaryReader.ReadString();
                             if (num >= 65)
                             {
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                                 binaryReader.ReadString();
                             }
                         }
                     }
                     if (num >= 7)
                     {
                         bool flag2 = binaryReader.ReadBoolean();
                         string text = binaryReader.ReadString();
                         int num10 = binaryReader.ReadInt32();
                         if (!flag2 || (!(text == b) && num10 != num2))
                         {
                             binaryReader.Close();
                             fileStream.Close();
                             result = false;
                             return result;
                         }
                     }
                     binaryReader.Close();
                     fileStream.Close();
                     result = true;
                 }
             }
             catch
             {
                 try
                 {
                     binaryReader.Close();
                     fileStream.Close();
                 }
                 catch
                 {
                 }
                 result = false;
             }
         }
     }
     return result;
 }
コード例 #8
0
ファイル: Tools.cs プロジェクト: Jewsus/Mazes
		public static void WriteTile(BinaryWriter writer, Tile tile)
		{
			byte flags = 0;
			if (tile.active())
			{
				flags |= 1;
			}
			if (tile.wall != 0)
			{
				flags |= 2;
			}
			if (tile.liquid > 0)
			{
				flags |= 4;
			}
			if (tile.lava())
			{
				flags |= 8;
			}
			if (tile.wire())
			{
				flags |= 16;
			}

			writer.Write(flags);
			if ((flags & 1) == 1)
			{
				writer.Write(tile.type);
				if (Main.tileFrameImportant[tile.type])
				{
					writer.Write(tile.frameNumber());
					writer.Write(tile.frameX);
					writer.Write(tile.frameY);
				}
			}
			if ((flags & 2) == 2)
			{
				writer.Write(tile.wall);
			}
			if ((flags & 4) == 4)
			{
				writer.Write(tile.liquid);
			}
		}
コード例 #9
0
        public static void LavaCheck(int x, int y)
        {
            Tile tile  = Main.tile[x - 1, y];
            Tile tile2 = Main.tile[x + 1, y];
            Tile tile3 = Main.tile[x, y - 1];
            Tile tile4 = Main.tile[x, y + 1];
            Tile tile5 = Main.tile[x, y];

            if ((tile.liquid > 0 && !tile.lava()) || (tile2.liquid > 0 && !tile2.lava()) || (tile3.liquid > 0 && !tile3.lava()))
            {
                int num  = 0;
                int type = 56;
                if (!tile.lava())
                {
                    num        += tile.liquid;
                    tile.liquid = 0;
                }
                if (!tile2.lava())
                {
                    num         += tile2.liquid;
                    tile2.liquid = 0;
                }
                if (!tile3.lava())
                {
                    num         += tile3.liquid;
                    tile3.liquid = 0;
                }
                if (tile.honey() || tile2.honey() || tile3.honey())
                {
                    type = 230;
                }
                if (num < 24)
                {
                    return;
                }
                if (tile5.active() && Main.tileObsidianKill[tile5.type])
                {
                    WorldGen.KillTile(x, y);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y);
                    }
                }
                if (!tile5.active())
                {
                    tile5.liquid = 0;
                    tile5.lava(lava: false);
                    WorldGen.PlaceTile(x, y, type, mute: true, forced: true);
                    WorldGen.SquareTileFrame(x, y);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendTileSquare(-1, x - 1, y - 1, 3);
                    }
                }
            }
            else
            {
                if (tile4.liquid <= 0 || tile4.lava())
                {
                    return;
                }
                if (Main.tileCut[tile4.type])
                {
                    WorldGen.KillTile(x, y + 1);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y + 1);
                    }
                }
                else if (tile4.active() && Main.tileObsidianKill[tile4.type])
                {
                    WorldGen.KillTile(x, y + 1);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y + 1);
                    }
                }
                if (tile4.active())
                {
                    return;
                }
                if (tile5.liquid < 24)
                {
                    tile5.liquid = 0;
                    tile5.liquidType(0);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendTileSquare(-1, x - 1, y, 3);
                    }
                    return;
                }
                int type2 = 56;
                if (tile4.honey())
                {
                    type2 = 230;
                }
                tile5.liquid = 0;
                tile5.lava(lava: false);
                tile4.liquid = 0;
                WorldGen.PlaceTile(x, y + 1, type2, mute: true, forced: true);
                WorldGen.SquareTileFrame(x, y + 1);
                if (Main.netMode == 2)
                {
                    NetMessage.SendTileSquare(-1, x - 1, y, 3);
                }
            }
        }
コード例 #10
0
        public static void DelWater(int l)
        {
            int  num   = Main.liquid[l].x;
            int  num2  = Main.liquid[l].y;
            Tile tile  = Main.tile[num - 1, num2];
            Tile tile2 = Main.tile[num + 1, num2];
            Tile tile3 = Main.tile[num, num2 + 1];
            Tile tile4 = Main.tile[num, num2];
            byte b     = 2;

            if (tile4.liquid < b)
            {
                tile4.liquid = 0;
                if (tile.liquid < b)
                {
                    tile.liquid = 0;
                }
                else
                {
                    AddWater(num - 1, num2);
                }
                if (tile2.liquid < b)
                {
                    tile2.liquid = 0;
                }
                else
                {
                    AddWater(num + 1, num2);
                }
            }
            else if (tile4.liquid < 20)
            {
                if ((tile.liquid < tile4.liquid && (!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type])) || (tile2.liquid < tile4.liquid && (!tile2.nactive() || !Main.tileSolid[tile2.type] || Main.tileSolidTop[tile2.type])) || (tile3.liquid < byte.MaxValue && (!tile3.nactive() || !Main.tileSolid[tile3.type] || Main.tileSolidTop[tile3.type])))
                {
                    tile4.liquid = 0;
                }
            }
            else if (tile3.liquid < byte.MaxValue && (!tile3.nactive() || !Main.tileSolid[tile3.type] || Main.tileSolidTop[tile3.type]) && !stuck)
            {
                Main.liquid[l].kill = 0;
                return;
            }
            if (tile4.liquid < 250 && Main.tile[num, num2 - 1].liquid > 0)
            {
                AddWater(num, num2 - 1);
            }
            if (tile4.liquid == 0)
            {
                tile4.liquidType(0);
            }
            else
            {
                if ((tile2.liquid > 0 && Main.tile[num + 1, num2 + 1].liquid < 250 && !Main.tile[num + 1, num2 + 1].active()) || (tile.liquid > 0 && Main.tile[num - 1, num2 + 1].liquid < 250 && !Main.tile[num - 1, num2 + 1].active()))
                {
                    AddWater(num - 1, num2);
                    AddWater(num + 1, num2);
                }
                if (tile4.lava())
                {
                    LavaCheck(num, num2);
                    for (int i = num - 1; i <= num + 1; i++)
                    {
                        for (int j = num2 - 1; j <= num2 + 1; j++)
                        {
                            Tile tile5 = Main.tile[i, j];
                            if (!tile5.active())
                            {
                                continue;
                            }
                            if (tile5.type == 2 || tile5.type == 23 || tile5.type == 109 || tile5.type == 199)
                            {
                                tile5.type = 0;
                                WorldGen.SquareTileFrame(i, j);
                                if (Main.netMode == 2)
                                {
                                    NetMessage.SendTileSquare(-1, num, num2, 3);
                                }
                            }
                            else if (tile5.type == 60 || tile5.type == 70)
                            {
                                tile5.type = 59;
                                WorldGen.SquareTileFrame(i, j);
                                if (Main.netMode == 2)
                                {
                                    NetMessage.SendTileSquare(-1, num, num2, 3);
                                }
                            }
                        }
                    }
                }
                else if (tile4.honey())
                {
                    HoneyCheck(num, num2);
                }
            }
            if (Main.netMode == 2)
            {
                NetSendLiquid(num, num2);
            }
            numLiquid--;
            Main.tile[Main.liquid[l].x, Main.liquid[l].y].checkingLiquid(checkingLiquid: false);
            Main.liquid[l].x    = Main.liquid[numLiquid].x;
            Main.liquid[l].y    = Main.liquid[numLiquid].y;
            Main.liquid[l].kill = Main.liquid[numLiquid].kill;
            if (Main.tileAlch[tile4.type])
            {
                WorldGen.CheckAlch(num, num2);
            }
        }
コード例 #11
0
        public static void HoneyCheck(int x, int y)
        {
            Tile tile  = Main.tile[x - 1, y];
            Tile tile2 = Main.tile[x + 1, y];
            Tile tile3 = Main.tile[x, y - 1];
            Tile tile4 = Main.tile[x, y + 1];
            Tile tile5 = Main.tile[x, y];

            if ((tile.liquid > 0 && tile.liquidType() == 0) || (tile2.liquid > 0 && tile2.liquidType() == 0) || (tile3.liquid > 0 && tile3.liquidType() == 0))
            {
                int num = 0;
                if (tile.liquidType() == 0)
                {
                    num        += tile.liquid;
                    tile.liquid = 0;
                }
                if (tile2.liquidType() == 0)
                {
                    num         += tile2.liquid;
                    tile2.liquid = 0;
                }
                if (tile3.liquidType() == 0)
                {
                    num         += tile3.liquid;
                    tile3.liquid = 0;
                }
                if (num < 32)
                {
                    return;
                }
                if (tile5.active() && Main.tileObsidianKill[tile5.type])
                {
                    WorldGen.KillTile(x, y);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y);
                    }
                }
                if (!tile5.active())
                {
                    tile5.liquid = 0;
                    tile5.liquidType(0);
                    WorldGen.PlaceTile(x, y, 229, mute: true, forced: true);
                    WorldGen.SquareTileFrame(x, y);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendTileSquare(-1, x - 1, y - 1, 3);
                    }
                }
            }
            else
            {
                if (tile4.liquid <= 0 || tile4.liquidType() != 0)
                {
                    return;
                }
                if (Main.tileCut[tile4.type])
                {
                    WorldGen.KillTile(x, y + 1);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y + 1);
                    }
                }
                else if (tile4.active() && Main.tileObsidianKill[tile4.type])
                {
                    WorldGen.KillTile(x, y + 1);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, x, y + 1);
                    }
                }
                if (tile4.active())
                {
                    return;
                }
                if (tile5.liquid < 32)
                {
                    tile5.liquid = 0;
                    tile5.liquidType(0);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendTileSquare(-1, x - 1, y, 3);
                    }
                    return;
                }
                tile5.liquid = 0;
                tile5.liquidType(0);
                tile4.liquid = 0;
                tile4.liquidType(0);
                WorldGen.PlaceTile(x, y + 1, 229, mute: true, forced: true);
                WorldGen.SquareTileFrame(x, y + 1);
                if (Main.netMode == 2)
                {
                    NetMessage.SendTileSquare(-1, x - 1, y, 3);
                }
            }
        }
コード例 #12
0
        public void Prune()
        {
            bool flag = false;

            for (int index = 0; index <= 20; ++index)
            {
                HitTile.HitTileObject hitTileObject = this.data[index];
                if (hitTileObject.type != 0)
                {
                    Tile tile = Main.tile[hitTileObject.X, hitTileObject.Y];
                    if (hitTileObject.timeToLive <= 1)
                    {
                        hitTileObject.Clear();
                        flag = true;
                    }
                    else
                    {
                        --hitTileObject.timeToLive;
                        if ((double)hitTileObject.timeToLive < 12.0)
                        {
                            hitTileObject.damage -= 10;
                        }
                        else if ((double)hitTileObject.timeToLive < 24.0)
                        {
                            hitTileObject.damage -= 7;
                        }
                        else if ((double)hitTileObject.timeToLive < 36.0)
                        {
                            hitTileObject.damage -= 5;
                        }
                        else if ((double)hitTileObject.timeToLive < 48.0)
                        {
                            hitTileObject.damage -= 2;
                        }
                        if (hitTileObject.damage < 0)
                        {
                            hitTileObject.Clear();
                            flag = true;
                        }
                        else if (hitTileObject.type == 1)
                        {
                            if (!tile.active())
                            {
                                hitTileObject.Clear();
                                flag = true;
                            }
                        }
                        else if ((int)tile.wall == 0)
                        {
                            hitTileObject.Clear();
                            flag = true;
                        }
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            int num1 = 1;

            while (flag)
            {
                flag = false;
                for (int index = num1; index < 20; ++index)
                {
                    if (this.data[this.order[index]].type == 0 && this.data[this.order[index + 1]].type != 0)
                    {
                        int num2 = this.order[index];
                        this.order[index]     = this.order[index + 1];
                        this.order[index + 1] = num2;
                        flag = true;
                    }
                }
            }
        }
コード例 #13
0
        public static bool Place(TileObject toBePlaced)
        {
            TileObjectData tileData = TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate);

            if (tileData == null)
            {
                return(false);
            }
            if (tileData.HookPlaceOverride.hook != null)
            {
                int num1;
                int num2;
                if (tileData.HookPlaceOverride.processedCoordinates)
                {
                    num1 = toBePlaced.xCoord;
                    num2 = toBePlaced.yCoord;
                }
                else
                {
                    num1 = toBePlaced.xCoord + (int)tileData.Origin.X;
                    num2 = toBePlaced.yCoord + (int)tileData.Origin.Y;
                }
                if (tileData.HookPlaceOverride.hook(num1, num2, toBePlaced.type, toBePlaced.style, 1) == tileData.HookPlaceOverride.badReturn)
                {
                    return(false);
                }
            }
            else
            {
                ushort type           = (ushort)toBePlaced.type;
                int    placementStyle = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random);
                int    num1           = 0;
                if (tileData.StyleWrapLimit > 0)
                {
                    num1            = placementStyle / tileData.StyleWrapLimit;
                    placementStyle %= tileData.StyleWrapLimit;
                }
                int num2;
                int num3;
                if (tileData.StyleHorizontal)
                {
                    num2 = tileData.CoordinateFullWidth * placementStyle;
                    num3 = tileData.CoordinateFullHeight * num1;
                }
                else
                {
                    num2 = tileData.CoordinateFullWidth * num1;
                    num3 = tileData.CoordinateFullHeight * placementStyle;
                }
                int xCoord = toBePlaced.xCoord;
                int yCoord = toBePlaced.yCoord;
                for (int index1 = 0; index1 < tileData.Width; ++index1)
                {
                    for (int index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        Tile tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2);
                        if (tileSafely.active() && Main.tileCut[(int)tileSafely.type])
                        {
                            WorldGen.KillTile(xCoord + index1, yCoord + index2, false, false, false);
                        }
                    }
                }
                for (int index1 = 0; index1 < tileData.Width; ++index1)
                {
                    int num4 = num2 + index1 * (tileData.CoordinateWidth + tileData.CoordinatePadding);
                    int num5 = num3;
                    for (int index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        Tile tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2);
                        if (!tileSafely.active())
                        {
                            tileSafely.active(true);
                            tileSafely.frameX = (short)num4;
                            tileSafely.frameY = (short)num5;
                            tileSafely.type   = type;
                        }
                        num5 += tileData.CoordinateHeights[index2] + tileData.CoordinatePadding;
                    }
                }
            }
            if (tileData.FlattenAnchors)
            {
                AnchorData anchorData = tileData.AnchorBottom;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int num = toBePlaced.xCoord + anchorData.checkStart;
                    int j   = toBePlaced.yCoord + tileData.Height;
                    for (int index = 0; index < anchorData.tileCount; ++index)
                    {
                        Tile tileSafely = Framing.GetTileSafely(num + index, j);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(num + index, j, 0);
                        }
                    }
                }
                anchorData = tileData.AnchorTop;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int num = toBePlaced.xCoord + anchorData.checkStart;
                    int j   = toBePlaced.yCoord - 1;
                    for (int index = 0; index < anchorData.tileCount; ++index)
                    {
                        Tile tileSafely = Framing.GetTileSafely(num + index, j);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(num + index, j, 0);
                        }
                    }
                }
                anchorData = tileData.AnchorRight;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int i   = toBePlaced.xCoord + tileData.Width;
                    int num = toBePlaced.yCoord + anchorData.checkStart;
                    for (int index = 0; index < anchorData.tileCount; ++index)
                    {
                        Tile tileSafely = Framing.GetTileSafely(i, num + index);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(i, num + index, 0);
                        }
                    }
                }
                anchorData = tileData.AnchorLeft;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int i   = toBePlaced.xCoord - 1;
                    int num = toBePlaced.yCoord + anchorData.checkStart;
                    for (int index = 0; index < anchorData.tileCount; ++index)
                    {
                        Tile tileSafely = Framing.GetTileSafely(i, num + index);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(i, num + index, 0);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #14
0
        public static bool CanPlace(int x, int y, int type, int style, int dir, out TileObject objectData, bool onlyCheck = false)
        {
            TileObjectData tileData1 = TileObjectData.GetTileData(type, style, 0);

            objectData = TileObject.Empty;
            if (tileData1 == null)
            {
                return(false);
            }
            int num1 = x - (int)tileData1.Origin.X;
            int num2 = y - (int)tileData1.Origin.Y;

            if (num1 < 0 || num1 + tileData1.Width >= Main.maxTilesX || (num2 < 0 || num2 + tileData1.Height >= Main.maxTilesY))
            {
                return(false);
            }
            bool flag1 = tileData1.RandomStyleRange > 0;

            if (TileObjectPreviewData.placementCache == null)
            {
                TileObjectPreviewData.placementCache = new TileObjectPreviewData();
            }
            TileObjectPreviewData.placementCache.Reset();
            int num3 = 0;
            int num4 = 0;

            if (tileData1.AlternatesCount != 0)
            {
                num4 = tileData1.AlternatesCount;
            }
            float          num5           = -1f;
            float          num6           = -1f;
            int            num7           = 0;
            TileObjectData tileObjectData = (TileObjectData)null;
            int            alternate      = num3 - 1;

            while (alternate < num4)
            {
                ++alternate;
                TileObjectData tileData2 = TileObjectData.GetTileData(type, style, alternate);
                if (tileData2.Direction == TileObjectDirection.None || (tileData2.Direction != TileObjectDirection.PlaceLeft || dir != 1) && (tileData2.Direction != TileObjectDirection.PlaceRight || dir != -1))
                {
                    int num8 = x - (int)tileData2.Origin.X;
                    int num9 = y - (int)tileData2.Origin.Y;
                    if (num8 < 5 || num8 + tileData2.Width > Main.maxTilesX - 5 || (num9 < 5 || num9 + tileData2.Height > Main.maxTilesY - 5))
                    {
                        return(false);
                    }
                    Rectangle rectangle = new Rectangle(0, 0, tileData2.Width, tileData2.Height);
                    int       X         = 0;
                    int       Y         = 0;
                    if (tileData2.AnchorTop.tileCount != 0)
                    {
                        if (rectangle.Y == 0)
                        {
                            rectangle.Y = -1;
                            ++rectangle.Height;
                            ++Y;
                        }
                        int checkStart = tileData2.AnchorTop.checkStart;
                        if (checkStart < rectangle.X)
                        {
                            rectangle.Width += rectangle.X - checkStart;
                            X          += rectangle.X - checkStart;
                            rectangle.X = checkStart;
                        }
                        int num10 = checkStart + tileData2.AnchorTop.tileCount - 1;
                        int num11 = rectangle.X + rectangle.Width - 1;
                        if (num10 > num11)
                        {
                            rectangle.Width += num10 - num11;
                        }
                    }
                    if (tileData2.AnchorBottom.tileCount != 0)
                    {
                        if (rectangle.Y + rectangle.Height == tileData2.Height)
                        {
                            ++rectangle.Height;
                        }
                        int checkStart = tileData2.AnchorBottom.checkStart;
                        if (checkStart < rectangle.X)
                        {
                            rectangle.Width += rectangle.X - checkStart;
                            X          += rectangle.X - checkStart;
                            rectangle.X = checkStart;
                        }
                        int num10 = checkStart + tileData2.AnchorBottom.tileCount - 1;
                        int num11 = rectangle.X + rectangle.Width - 1;
                        if (num10 > num11)
                        {
                            rectangle.Width += num10 - num11;
                        }
                    }
                    if (tileData2.AnchorLeft.tileCount != 0)
                    {
                        if (rectangle.X == 0)
                        {
                            rectangle.X = -1;
                            ++rectangle.Width;
                            ++X;
                        }
                        int checkStart = tileData2.AnchorLeft.checkStart;
                        if ((tileData2.AnchorLeft.type & AnchorType.Tree) == AnchorType.Tree)
                        {
                            --checkStart;
                        }
                        if (checkStart < rectangle.Y)
                        {
                            rectangle.Width += rectangle.Y - checkStart;
                            Y          += rectangle.Y - checkStart;
                            rectangle.Y = checkStart;
                        }
                        int num10 = checkStart + tileData2.AnchorLeft.tileCount - 1;
                        if ((tileData2.AnchorLeft.type & AnchorType.Tree) == AnchorType.Tree)
                        {
                            num10 += 2;
                        }
                        int num11 = rectangle.Y + rectangle.Height - 1;
                        if (num10 > num11)
                        {
                            rectangle.Height += num10 - num11;
                        }
                    }
                    if (tileData2.AnchorRight.tileCount != 0)
                    {
                        if (rectangle.X + rectangle.Width == tileData2.Width)
                        {
                            ++rectangle.Width;
                        }
                        int checkStart = tileData2.AnchorLeft.checkStart;
                        if ((tileData2.AnchorRight.type & AnchorType.Tree) == AnchorType.Tree)
                        {
                            --checkStart;
                        }
                        if (checkStart < rectangle.Y)
                        {
                            rectangle.Width += rectangle.Y - checkStart;
                            Y          += rectangle.Y - checkStart;
                            rectangle.Y = checkStart;
                        }
                        int num10 = checkStart + tileData2.AnchorRight.tileCount - 1;
                        if ((tileData2.AnchorRight.type & AnchorType.Tree) == AnchorType.Tree)
                        {
                            num10 += 2;
                        }
                        int num11 = rectangle.Y + rectangle.Height - 1;
                        if (num10 > num11)
                        {
                            rectangle.Height += num10 - num11;
                        }
                    }
                    if (onlyCheck)
                    {
                        TileObject.objectPreview.Reset();
                        TileObject.objectPreview.Active      = true;
                        TileObject.objectPreview.Type        = (ushort)type;
                        TileObject.objectPreview.Style       = (short)style;
                        TileObject.objectPreview.Alternate   = alternate;
                        TileObject.objectPreview.Size        = new Point16(rectangle.Width, rectangle.Height);
                        TileObject.objectPreview.ObjectStart = new Point16(X, Y);
                        TileObject.objectPreview.Coordinates = new Point16(num8 - X, num9 - Y);
                    }
                    float num12 = 0.0f;
                    float num13 = (float)(tileData2.Width * tileData2.Height);
                    float num14 = 0.0f;
                    float num15 = 0.0f;
                    for (int index1 = 0; index1 < tileData2.Width; ++index1)
                    {
                        for (int index2 = 0; index2 < tileData2.Height; ++index2)
                        {
                            Tile tileSafely = Framing.GetTileSafely(num8 + index1, num9 + index2);
                            bool flag2      = !tileData2.LiquidPlace(tileSafely);
                            bool flag3      = false;
                            if (tileData2.AnchorWall)
                            {
                                ++num15;
                                if (!tileData2.isValidWallAnchor((int)tileSafely.wall))
                                {
                                    flag3 = true;
                                }
                                else
                                {
                                    ++num14;
                                }
                            }
                            bool flag4 = false;
                            if (tileSafely.active() && !Main.tileCut[(int)tileSafely.type])
                            {
                                flag4 = true;
                            }
                            if (!flag4 && !flag2 && !flag3)
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[index1 + X, index2 + Y] = 1;
                                }
                                ++num12;
                            }
                            else if (onlyCheck)
                            {
                                TileObject.objectPreview[index1 + X, index2 + Y] = 2;
                            }
                        }
                    }
                    AnchorData anchorBottom = tileData2.AnchorBottom;
                    if (anchorBottom.tileCount != 0)
                    {
                        num15 += (float)anchorBottom.tileCount;
                        int height = tileData2.Height;
                        for (int index = 0; index < anchorBottom.tileCount; ++index)
                        {
                            int  num10      = anchorBottom.checkStart + index;
                            Tile tileSafely = Framing.GetTileSafely(num8 + num10, num9 + height);
                            bool flag2      = false;
                            if (tileSafely.nactive())
                            {
                                if ((anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile && Main.tileSolid[(int)tileSafely.type] && (!Main.tileSolidTop[(int)tileSafely.type] && !Main.tileNoAttach[(int)tileSafely.type]) && (tileData2.FlattenAnchors || tileSafely.blockType() == 0))
                                {
                                    flag2 = tileData2.isValidTileAnchor((int)tileSafely.type);
                                }
                                if (!flag2 && ((anchorBottom.type & AnchorType.SolidWithTop) == AnchorType.SolidWithTop || (anchorBottom.type & AnchorType.Table) == AnchorType.Table))
                                {
                                    if (TileID.Sets.Platforms[(int)tileSafely.type])
                                    {
                                        int num11 = (int)tileSafely.frameX / TileObjectData.PlatformFrameWidth();
                                        if (!tileSafely.halfBrick() && num11 >= 0 && num11 <= 7 || (num11 >= 12 && num11 <= 16 || num11 >= 25 && num11 <= 26))
                                        {
                                            flag2 = true;
                                        }
                                    }
                                    else if (Main.tileSolid[(int)tileSafely.type] && Main.tileSolidTop[(int)tileSafely.type])
                                    {
                                        flag2 = true;
                                    }
                                }
                                if (!flag2 && (anchorBottom.type & AnchorType.Table) == AnchorType.Table && (!TileID.Sets.Platforms[(int)tileSafely.type] && Main.tileTable[(int)tileSafely.type]) && tileSafely.blockType() == 0)
                                {
                                    flag2 = true;
                                }
                                if (!flag2 && (anchorBottom.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type]))
                                {
                                    switch (tileSafely.blockType())
                                    {
                                    case 4:
                                    case 5:
                                        flag2 = tileData2.isValidTileAnchor((int)tileSafely.type);
                                        break;
                                    }
                                }
                                if (!flag2 && (anchorBottom.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely.type))
                                {
                                    flag2 = true;
                                }
                            }
                            else if (!flag2 && (anchorBottom.type & AnchorType.EmptyTile) == AnchorType.EmptyTile)
                            {
                                flag2 = true;
                            }
                            if (!flag2)
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num10 + X, height + Y] = 2;
                                }
                            }
                            else
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num10 + X, height + Y] = 1;
                                }
                                ++num14;
                            }
                        }
                    }
                    AnchorData anchorTop = tileData2.AnchorTop;
                    if (anchorTop.tileCount != 0)
                    {
                        num15 += (float)anchorTop.tileCount;
                        int num10 = -1;
                        for (int index = 0; index < anchorTop.tileCount; ++index)
                        {
                            int  num11      = anchorTop.checkStart + index;
                            Tile tileSafely = Framing.GetTileSafely(num8 + num11, num9 + num10);
                            bool flag2      = false;
                            if (tileSafely.nactive())
                            {
                                if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && !Main.tileNoAttach[(int)tileSafely.type] && (tileData2.FlattenAnchors || tileSafely.blockType() == 0))
                                {
                                    flag2 = tileData2.isValidTileAnchor((int)tileSafely.type);
                                }
                                if (!flag2 && (anchorTop.type & AnchorType.SolidBottom) == AnchorType.SolidBottom && (Main.tileSolid[(int)tileSafely.type] && (!Main.tileSolidTop[(int)tileSafely.type] || TileID.Sets.Platforms[(int)tileSafely.type] && (tileSafely.halfBrick() || tileSafely.topSlope())) || (tileSafely.halfBrick() || tileSafely.topSlope())) && (!TileID.Sets.NotReallySolid[(int)tileSafely.type] && !tileSafely.bottomSlope()))
                                {
                                    flag2 = tileData2.isValidTileAnchor((int)tileSafely.type);
                                }
                                if (!flag2 && (anchorTop.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type]))
                                {
                                    switch (tileSafely.blockType())
                                    {
                                    case 2:
                                    case 3:
                                        flag2 = tileData2.isValidTileAnchor((int)tileSafely.type);
                                        break;
                                    }
                                }
                                if (!flag2 && (anchorTop.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely.type))
                                {
                                    flag2 = true;
                                }
                            }
                            else if (!flag2 && (anchorTop.type & AnchorType.EmptyTile) == AnchorType.EmptyTile)
                            {
                                flag2 = true;
                            }
                            if (!flag2)
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num11 + X, num10 + Y] = 2;
                                }
                            }
                            else
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num11 + X, num10 + Y] = 1;
                                }
                                ++num14;
                            }
                        }
                    }
                    AnchorData anchorRight = tileData2.AnchorRight;
                    if (anchorRight.tileCount != 0)
                    {
                        num15 += (float)anchorRight.tileCount;
                        int width = tileData2.Width;
                        for (int index = 0; index < anchorRight.tileCount; ++index)
                        {
                            int  num10       = anchorRight.checkStart + index;
                            Tile tileSafely1 = Framing.GetTileSafely(num8 + width, num9 + num10);
                            bool flag2       = false;
                            if (tileSafely1.nactive())
                            {
                                if (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type] && !Main.tileNoAttach[(int)tileSafely1.type] && (tileData2.FlattenAnchors || tileSafely1.blockType() == 0))
                                {
                                    flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type);
                                }
                                if (!flag2 && (anchorRight.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type]))
                                {
                                    switch (tileSafely1.blockType())
                                    {
                                    case 2:
                                    case 4:
                                        flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type);
                                        break;
                                    }
                                }
                                if (!flag2 && (anchorRight.type & AnchorType.Tree) == AnchorType.Tree && (int)tileSafely1.type == 5)
                                {
                                    flag2 = true;
                                    if (index == 0)
                                    {
                                        ++num15;
                                        Tile tileSafely2 = Framing.GetTileSafely(num8 + width, num9 + num10 - 1);
                                        if (tileSafely2.nactive() && (int)tileSafely2.type == 5)
                                        {
                                            ++num14;
                                            if (onlyCheck)
                                            {
                                                TileObject.objectPreview[width + X, num10 + Y - 1] = 1;
                                            }
                                        }
                                        else if (onlyCheck)
                                        {
                                            TileObject.objectPreview[width + X, num10 + Y - 1] = 2;
                                        }
                                    }
                                    if (index == anchorRight.tileCount - 1)
                                    {
                                        ++num15;
                                        Tile tileSafely2 = Framing.GetTileSafely(num8 + width, num9 + num10 + 1);
                                        if (tileSafely2.nactive() && (int)tileSafely2.type == 5)
                                        {
                                            ++num14;
                                            if (onlyCheck)
                                            {
                                                TileObject.objectPreview[width + X, num10 + Y + 1] = 1;
                                            }
                                        }
                                        else if (onlyCheck)
                                        {
                                            TileObject.objectPreview[width + X, num10 + Y + 1] = 2;
                                        }
                                    }
                                }
                                if (!flag2 && (anchorRight.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely1.type))
                                {
                                    flag2 = true;
                                }
                            }
                            else if (!flag2 && (anchorRight.type & AnchorType.EmptyTile) == AnchorType.EmptyTile)
                            {
                                flag2 = true;
                            }
                            if (!flag2)
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[width + X, num10 + Y] = 2;
                                }
                            }
                            else
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[width + X, num10 + Y] = 1;
                                }
                                ++num14;
                            }
                        }
                    }
                    AnchorData anchorLeft = tileData2.AnchorLeft;
                    if (anchorLeft.tileCount != 0)
                    {
                        num15 += (float)anchorLeft.tileCount;
                        int num10 = -1;
                        for (int index = 0; index < anchorLeft.tileCount; ++index)
                        {
                            int  num11       = anchorLeft.checkStart + index;
                            Tile tileSafely1 = Framing.GetTileSafely(num8 + num10, num9 + num11);
                            bool flag2       = false;
                            if (tileSafely1.nactive())
                            {
                                if (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type] && !Main.tileNoAttach[(int)tileSafely1.type] && (tileData2.FlattenAnchors || tileSafely1.blockType() == 0))
                                {
                                    flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type);
                                }
                                if (!flag2 && (anchorLeft.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type]))
                                {
                                    switch (tileSafely1.blockType())
                                    {
                                    case 3:
                                    case 5:
                                        flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type);
                                        break;
                                    }
                                }
                                if (!flag2 && (anchorLeft.type & AnchorType.Tree) == AnchorType.Tree && (int)tileSafely1.type == 5)
                                {
                                    flag2 = true;
                                    if (index == 0)
                                    {
                                        ++num15;
                                        Tile tileSafely2 = Framing.GetTileSafely(num8 + num10, num9 + num11 - 1);
                                        if (tileSafely2.nactive() && (int)tileSafely2.type == 5)
                                        {
                                            ++num14;
                                            if (onlyCheck)
                                            {
                                                TileObject.objectPreview[num10 + X, num11 + Y - 1] = 1;
                                            }
                                        }
                                        else if (onlyCheck)
                                        {
                                            TileObject.objectPreview[num10 + X, num11 + Y - 1] = 2;
                                        }
                                    }
                                    if (index == anchorLeft.tileCount - 1)
                                    {
                                        ++num15;
                                        Tile tileSafely2 = Framing.GetTileSafely(num8 + num10, num9 + num11 + 1);
                                        if (tileSafely2.nactive() && (int)tileSafely2.type == 5)
                                        {
                                            ++num14;
                                            if (onlyCheck)
                                            {
                                                TileObject.objectPreview[num10 + X, num11 + Y + 1] = 1;
                                            }
                                        }
                                        else if (onlyCheck)
                                        {
                                            TileObject.objectPreview[num10 + X, num11 + Y + 1] = 2;
                                        }
                                    }
                                }
                                if (!flag2 && (anchorLeft.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely1.type))
                                {
                                    flag2 = true;
                                }
                            }
                            else if (!flag2 && (anchorLeft.type & AnchorType.EmptyTile) == AnchorType.EmptyTile)
                            {
                                flag2 = true;
                            }
                            if (!flag2)
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num10 + X, num11 + Y] = 2;
                                }
                            }
                            else
                            {
                                if (onlyCheck)
                                {
                                    TileObject.objectPreview[num10 + X, num11 + Y] = 1;
                                }
                                ++num14;
                            }
                        }
                    }
                    if (tileData2.HookCheck.hook != null)
                    {
                        if (tileData2.HookCheck.processedCoordinates)
                        {
                            int x1 = (int)tileData2.Origin.X;
                            int y1 = (int)tileData2.Origin.Y;
                        }
                        if (tileData2.HookCheck.hook(x, y, type, style, dir) == tileData2.HookCheck.badReturn && tileData2.HookCheck.badResponse == 0)
                        {
                            num14 = 0.0f;
                            num12 = 0.0f;
                            TileObject.objectPreview.AllInvalid();
                        }
                    }
                    float num16 = num14 / num15;
                    float num17 = num12 / num13;
                    if ((double)num17 == 1.0 && (double)num15 == 0.0)
                    {
                        num16 = 1f;
                        num17 = 1f;
                    }
                    if ((double)num16 != 1.0 || (double)num17 != 1.0)
                    {
                        if ((double)num16 > (double)num5 || (double)num16 == (double)num5 && (double)num17 > (double)num6)
                        {
                            TileObjectPreviewData.placementCache.CopyFrom(TileObject.objectPreview);
                            num5           = num16;
                            num6           = num17;
                            tileObjectData = tileData2;
                            num7           = alternate;
                        }
                    }
                    else
                    {
                        num5           = 1f;
                        num6           = 1f;
                        num7           = alternate;
                        tileObjectData = tileData2;
                        break;
                    }
                }
            }
            int num18 = -1;

            if (flag1)
            {
                if (TileObjectPreviewData.randomCache == null)
                {
                    TileObjectPreviewData.randomCache = new TileObjectPreviewData();
                }
                bool flag2 = false;
                if ((int)TileObjectPreviewData.randomCache.Type == type)
                {
                    Point16 coordinates = TileObjectPreviewData.randomCache.Coordinates;
                    Point16 objectStart = TileObjectPreviewData.randomCache.ObjectStart;
                    int     num8        = (int)coordinates.X + (int)objectStart.X;
                    int     num9        = (int)coordinates.Y + (int)objectStart.Y;
                    int     num10       = x - (int)tileData1.Origin.X;
                    int     num11       = y - (int)tileData1.Origin.Y;
                    if (num8 != num10 || num9 != num11)
                    {
                        flag2 = true;
                    }
                }
                else
                {
                    flag2 = true;
                }
                num18 = !flag2 ? TileObjectPreviewData.randomCache.Random : Main.rand.Next(tileData1.RandomStyleRange);
            }
            if (onlyCheck)
            {
                if ((double)num5 != 1.0 || (double)num6 != 1.0)
                {
                    TileObject.objectPreview.CopyFrom(TileObjectPreviewData.placementCache);
                    alternate = num7;
                }
                TileObject.objectPreview.Random = num18;
                if (tileData1.RandomStyleRange > 0)
                {
                    TileObjectPreviewData.randomCache.CopyFrom(TileObject.objectPreview);
                }
            }
            if (!onlyCheck)
            {
                objectData.xCoord    = x - (int)tileObjectData.Origin.X;
                objectData.yCoord    = y - (int)tileObjectData.Origin.Y;
                objectData.type      = type;
                objectData.style     = style;
                objectData.alternate = alternate;
                objectData.random    = num18;
            }
            if ((double)num5 == 1.0)
            {
                return((double)num6 == 1.0);
            }
            return(false);
        }
コード例 #15
0
ファイル: Minecart.cs プロジェクト: Celant/TerrariaAPI-Server
 public static void PlaceTrack(Tile trackCache, int style)
 {
     trackCache.active(true);
     trackCache.type = 314;
     trackCache.frameY = -1;
     switch (style)
     {
         case 0:
         {
             trackCache.frameX = -1;
             return;
         }
         case 1:
         {
             trackCache.frameX = Minecart._firstPressureFrame;
             return;
         }
         case 2:
         {
             trackCache.frameX = Minecart._firstLeftBoostFrame;
             return;
         }
         case 3:
         {
             trackCache.frameX = Minecart._firstRightBoostFrame;
             return;
         }
         default:
         {
             return;
         }
     }
 }
コード例 #16
0
        public static void WallFrame(int i, int j, bool resetFrame = false)
        {
            if (i <= 0 || j <= 0 || i >= Main.maxTilesX - 1 || j >= Main.maxTilesY - 1 || Main.tile[i, j] == null)
            {
                return;
            }
            WorldGen.UpdateMapTile(i, j);
            Tile tile = Main.tile[i, j];

            if (tile.wall == 0)
            {
                tile.wallColor(0);
                return;
            }
            int  num   = 0;
            Tile tile2 = Main.tile[i, j - 1];

            if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
            {
                num = 1;
            }
            tile2 = Main.tile[i - 1, j];
            if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
            {
                num |= 2;
            }
            tile2 = Main.tile[i + 1, j];
            if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
            {
                num |= 4;
            }
            tile2 = Main.tile[i, j + 1];
            if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
            {
                num |= 8;
            }
            int num2 = 0;

            if (Main.wallLargeFrames[tile.wall] == 1)
            {
                num2 = phlebasTileFrameNumberLookup[j % 4][i % 3] - 1;
                tile.wallFrameNumber((byte)num2);
            }
            else if (Main.wallLargeFrames[tile.wall] == 2)
            {
                num2 = lazureTileFrameNumberLookup[i % 2][j % 2] - 1;
                tile.wallFrameNumber((byte)num2);
            }
            else if (resetFrame)
            {
                num2 = WorldGen.genRand.Next(0, 3);
                tile.wallFrameNumber((byte)num2);
            }
            else
            {
                num2 = tile.wallFrameNumber();
            }
            if (num == 15)
            {
                num += centerWallFrameLookup[i % 3][j % 3];
            }
            Point16 point = wallFrameLookup[num][num2];

            tile.wallFrameX(point.X);
            tile.wallFrameY(point.Y);
        }
コード例 #17
0
        public void ScanAndExportToMain(SceneMetricsScanSettings settings)
        {
            Reset();
            int num  = 0;
            int num2 = 0;

            if (settings.ScanOreFinderData)
            {
                _oreFinderTileLocations.Clear();
            }
            if (settings.BiomeScanCenterPositionInWorld.HasValue)
            {
                Point     point     = settings.BiomeScanCenterPositionInWorld.Value.ToTileCoordinates();
                Rectangle rectangle = WorldUtils.ClampToWorld(tileRectangle: new Rectangle(point.X - Main.buffScanAreaWidth / 2, point.Y - Main.buffScanAreaHeight / 2, Main.buffScanAreaWidth, Main.buffScanAreaHeight), world: _world);
                for (int i = rectangle.Left; i < rectangle.Right; i++)
                {
                    for (int j = rectangle.Top; j < rectangle.Bottom; j++)
                    {
                        if (!rectangle.Contains(i, j))
                        {
                            continue;
                        }
                        Tile tile = _world.Tiles[i, j];
                        if (tile == null || !tile.active())
                        {
                            continue;
                        }
                        rectangle.Contains(i, j);
                        if (!TileID.Sets.isDesertBiomeSand[tile.type] || !WorldGen.oceanDepths(i, j))
                        {
                            _tileCounts[tile.type]++;
                        }
                        if (tile.type == 215 && tile.frameY < 36)
                        {
                            HasCampfire = true;
                        }
                        if (tile.type == 49 && tile.frameX < 18)
                        {
                            num++;
                        }
                        if (tile.type == 372 && tile.frameX < 18)
                        {
                            num2++;
                        }
                        if (tile.type == 405 && tile.frameX < 54)
                        {
                            HasCampfire = true;
                        }
                        if (tile.type == 506 && tile.frameX < 72)
                        {
                            HasCatBast = true;
                        }
                        if (tile.type == 42 && tile.frameY >= 324 && tile.frameY <= 358)
                        {
                            HasHeartLantern = true;
                        }
                        if (tile.type == 42 && tile.frameY >= 252 && tile.frameY <= 286)
                        {
                            HasStarInBottle = true;
                        }
                        if (tile.type == 91 && (tile.frameX >= 396 || tile.frameY >= 54))
                        {
                            int num3 = tile.frameX / 18 - 21;
                            for (int num4 = tile.frameY; num4 >= 54; num4 -= 54)
                            {
                                num3 += 90;
                                num3 += 21;
                            }
                            int num5 = Item.BannerToItem(num3);
                            if (ItemID.Sets.BannerStrength[num5].Enabled)
                            {
                                NPCBannerBuff[num3] = true;
                                hasBanner           = true;
                            }
                        }
                        if (settings.ScanOreFinderData && Main.tileOreFinderPriority[tile.type] != 0)
                        {
                            _oreFinderTileLocations.Add(new Point(i, j));
                        }
                    }
                }
            }
            if (settings.VisualScanArea.HasValue)
            {
                Rectangle rectangle2 = WorldUtils.ClampToWorld(_world, settings.VisualScanArea.Value);
                for (int k = rectangle2.Left; k < rectangle2.Right; k++)
                {
                    for (int l = rectangle2.Top; l < rectangle2.Bottom; l++)
                    {
                        Tile tile2 = _world.Tiles[k, l];
                        if (tile2 == null || !tile2.active())
                        {
                            continue;
                        }
                        if (tile2.type == 104)
                        {
                            HasClock = true;
                        }
                        switch (tile2.type)
                        {
                        case 139:
                            if (tile2.frameX >= 36)
                            {
                                ActiveMusicBox = tile2.frameY / 36;
                            }
                            break;

                        case 207:
                            if (tile2.frameY >= 72)
                            {
                                switch (tile2.frameX / 36)
                                {
                                case 0:
                                    ActiveFountainColor = 0;
                                    break;

                                case 1:
                                    ActiveFountainColor = 12;
                                    break;

                                case 2:
                                    ActiveFountainColor = 3;
                                    break;

                                case 3:
                                    ActiveFountainColor = 5;
                                    break;

                                case 4:
                                    ActiveFountainColor = 2;
                                    break;

                                case 5:
                                    ActiveFountainColor = 10;
                                    break;

                                case 6:
                                    ActiveFountainColor = 4;
                                    break;

                                case 7:
                                    ActiveFountainColor = 9;
                                    break;

                                case 8:
                                    ActiveFountainColor = 8;
                                    break;

                                case 9:
                                    ActiveFountainColor = 6;
                                    break;

                                default:
                                    ActiveFountainColor = -1;
                                    break;
                                }
                            }
                            break;

                        case 410:
                            if (tile2.frameY >= 56)
                            {
                                int num7 = ActiveMonolithType = tile2.frameX / 36;
                            }
                            break;

                        case 509:
                            if (tile2.frameY >= 56)
                            {
                                ActiveMonolithType = 4;
                            }
                            break;

                        case 480:
                            if (tile2.frameY >= 54)
                            {
                                BloodMoonMonolith = true;
                            }
                            break;
                        }
                    }
                }
            }
            WaterCandleCount = num;
            PeaceCandleCount = num2;
            ExportTileCountsToMain();
            if (settings.ScanOreFinderData)
            {
                UpdateOreFinderData();
            }
        }
コード例 #18
0
		public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
		{
			if (!centerTile.active())
			{
				return;
			}
			ushort type = centerTile.type;
			Framing.BlockStyle blockStyle = Framing.FindBlockStyle(centerTile);
			int num = 0;
			Framing.BlockStyle blockStyle2 = default(Framing.BlockStyle);
			if (blockStyle.top)
			{
				Tile tileSafely = Framing.GetTileSafely(i, j - 1);
				if (tileSafely.active() && tileSafely.type == type)
				{
					blockStyle2 = Framing.FindBlockStyle(tileSafely);
					if (blockStyle2.bottom)
					{
						num |= 1;
					}
					else
					{
						blockStyle2.Clear();
					}
				}
			}
			Framing.BlockStyle blockStyle3 = default(Framing.BlockStyle);
			if (blockStyle.left)
			{
				Tile tileSafely2 = Framing.GetTileSafely(i - 1, j);
				if (tileSafely2.active() && tileSafely2.type == type)
				{
					blockStyle3 = Framing.FindBlockStyle(tileSafely2);
					if (blockStyle3.right)
					{
						num |= 2;
					}
					else
					{
						blockStyle3.Clear();
					}
				}
			}
			Framing.BlockStyle blockStyle4 = default(Framing.BlockStyle);
			if (blockStyle.right)
			{
				Tile tileSafely3 = Framing.GetTileSafely(i + 1, j);
				if (tileSafely3.active() && tileSafely3.type == type)
				{
					blockStyle4 = Framing.FindBlockStyle(tileSafely3);
					if (blockStyle4.left)
					{
						num |= 4;
					}
					else
					{
						blockStyle4.Clear();
					}
				}
			}
			Framing.BlockStyle blockStyle5 = default(Framing.BlockStyle);
			if (blockStyle.bottom)
			{
				Tile tileSafely4 = Framing.GetTileSafely(i, j + 1);
				if (tileSafely4.active() && tileSafely4.type == type)
				{
					blockStyle5 = Framing.FindBlockStyle(tileSafely4);
					if (blockStyle5.top)
					{
						num |= 8;
					}
					else
					{
						blockStyle5.Clear();
					}
				}
			}
			if (blockStyle2.left && blockStyle3.top)
			{
				Tile tileSafely5 = Framing.GetTileSafely(i - 1, j - 1);
				if (tileSafely5.active() && tileSafely5.type == type)
				{
					Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely5);
					if (blockStyle6.right && blockStyle6.bottom)
					{
						num |= 16;
					}
				}
			}
			if (blockStyle2.right && blockStyle4.top)
			{
				Tile tileSafely6 = Framing.GetTileSafely(i + 1, j - 1);
				if (tileSafely6.active() && tileSafely6.type == type)
				{
					Framing.BlockStyle blockStyle7 = Framing.FindBlockStyle(tileSafely6);
					if (blockStyle7.left && blockStyle7.bottom)
					{
						num |= 32;
					}
				}
			}
			if (blockStyle5.left && blockStyle3.bottom)
			{
				Tile tileSafely7 = Framing.GetTileSafely(i - 1, j + 1);
				if (tileSafely7.active() && tileSafely7.type == type)
				{
					Framing.BlockStyle blockStyle8 = Framing.FindBlockStyle(tileSafely7);
					if (blockStyle8.right && blockStyle8.top)
					{
						num |= 64;
					}
				}
			}
			if (blockStyle5.right && blockStyle4.bottom)
			{
				Tile tileSafely8 = Framing.GetTileSafely(i + 1, j + 1);
				if (tileSafely8.active() && tileSafely8.type == type)
				{
					Framing.BlockStyle blockStyle9 = Framing.FindBlockStyle(tileSafely8);
					if (blockStyle9.left && blockStyle9.top)
					{
						num |= 128;
					}
				}
			}
			if (resetFrame)
			{
				centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3));
			}
			Point16 point = Framing.selfFrame8WayLookup[num][(int)centerTile.frameNumber()];
			centerTile.frameX = point.X;
			centerTile.frameY = point.Y;
		}
コード例 #19
0
ファイル: Framing.cs プロジェクト: EmuDevs/EDTerraria
 public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
 {
     if (!centerTile.active())
         return;
     ushort num = centerTile.type;
     Framing.BlockStyle blockStyle1 = Framing.FindBlockStyle(centerTile);
     int index = 0;
     Framing.BlockStyle blockStyle2 = new Framing.BlockStyle();
     if (blockStyle1.top)
     {
         Tile tileSafely = Framing.GetTileSafely(i, j - 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             blockStyle2 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle2.bottom)
                 index |= 1;
             else
                 blockStyle2.Clear();
         }
     }
     Framing.BlockStyle blockStyle3 = new Framing.BlockStyle();
     if (blockStyle1.left)
     {
         Tile tileSafely = Framing.GetTileSafely(i - 1, j);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             blockStyle3 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle3.right)
                 index |= 2;
             else
                 blockStyle3.Clear();
         }
     }
     Framing.BlockStyle blockStyle4 = new Framing.BlockStyle();
     if (blockStyle1.right)
     {
         Tile tileSafely = Framing.GetTileSafely(i + 1, j);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             blockStyle4 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle4.left)
                 index |= 4;
             else
                 blockStyle4.Clear();
         }
     }
     Framing.BlockStyle blockStyle5 = new Framing.BlockStyle();
     if (blockStyle1.bottom)
     {
         Tile tileSafely = Framing.GetTileSafely(i, j + 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             blockStyle5 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle5.top)
                 index |= 8;
             else
                 blockStyle5.Clear();
         }
     }
     if (blockStyle2.left && blockStyle3.top)
     {
         Tile tileSafely = Framing.GetTileSafely(i - 1, j - 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle6.right && blockStyle6.bottom)
                 index |= 16;
         }
     }
     if (blockStyle2.right && blockStyle4.top)
     {
         Tile tileSafely = Framing.GetTileSafely(i + 1, j - 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle6.left && blockStyle6.bottom)
                 index |= 32;
         }
     }
     if (blockStyle5.left && blockStyle3.bottom)
     {
         Tile tileSafely = Framing.GetTileSafely(i - 1, j + 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle6.right && blockStyle6.top)
                 index |= 64;
         }
     }
     if (blockStyle5.right && blockStyle4.bottom)
     {
         Tile tileSafely = Framing.GetTileSafely(i + 1, j + 1);
         if (tileSafely.active() && (int)tileSafely.type == (int)num)
         {
             Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely);
             if (blockStyle6.left && blockStyle6.top)
                 index |= 128;
         }
     }
     if (resetFrame)
         centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3));
     Point16 point16 = Framing.selfFrame8WayLookup[index][(int)centerTile.frameNumber()];
     centerTile.frameX = point16.X;
     centerTile.frameY = point16.Y;
 }
コード例 #20
0
ファイル: TileObjectData.cs プロジェクト: EmuDevs/EDTerraria
 public static bool CheckLavaDeath(Tile checkTile)
 {
     if (!checkTile.active())
         return false;
     TileObjectData tileData = TileObjectData.GetTileData(checkTile);
     if (tileData == null)
         return Main.tileLavaDeath[(int)checkTile.type];
     return tileData.LavaDeath;
 }
        private void CompressedTileBody(byte flags, Tile tile)
        {
            Byte(flags);

            var type = tile.type;
            var wall = tile.wall;
            var liquid = tile.liquid;

            if (tile.active())
            {
                if ((flags & 32) != 0)
                {
                    Byte(type);
                }

                if ((flags & 64) != 0)
                {
                    Short(tile.frameX);
                    Short(tile.frameY);
                }
            }

            if ((flags & 4) != 0)
            {
                Byte(wall);
            }

            if ((flags & 8) != 0)
            {
                Byte(liquid);
            }
        }
コード例 #22
0
ファイル: TileObjectData.cs プロジェクト: sylar605/TshockCN
 public static bool CheckWaterDeath(Tile checkTile)
 {
     if (!checkTile.active())
     {
         return false;
     }
     TileObjectData tileData = TileObjectData.GetTileData(checkTile);
     if (tileData != null)
     {
         return tileData.WaterDeath;
     }
     return Main.tileWaterDeath[checkTile.type];
 }
        private byte CompressedTileFlags(Tile tile, Tile last)
        {
            byte flags = 0;

            var active = tile.active();
            var type = tile.type;

            if (active != last.active()) flags |= 1;
            //if (tile.lighted != last.) flags |= 2;
            if (tile.wall != last.wall) flags |= 4;
            if (tile.liquid != last.liquid) flags |= 8;
            if (tile.lava() != last.lava()) flags |= 16;
            if (active)
            {
                if (last.type != type || (flags & 1) != 0) flags |= 32;

                if (Main.tileFrameImportant[type] && (last.frameX != tile.frameX || last.frameY != tile.frameY || (flags & 1) != 0))
                {
                    flags |= 64;
                }
            }

            return flags;
        }
コード例 #24
0
ファイル: WorldGen.cs プロジェクト: Celant/TerrariaAPI-Server
 public static bool SolidOrSlopedTile(Tile tile)
 {
     return tile != null && tile.active() && Main.tileSolid[(int)tile.type] && !Main.tileSolidTop[(int)tile.type] && !tile.inActive();
 }
        private void Tile(Tile tile)
        {
            byte flags = 0;

            var active = tile.active();
            var wall = tile.wall;
            var liquid = tile.liquid;

            if (active) flags += 1;
            //if (tile.Lighted)    flags += 2; //UNUSED
            if (wall > 0) flags += 4;
            if (liquid > 0) flags += 8;
            if (tile.wire()) flags += 16;
            if (tile.halfBrick()) flags += 32;
            if (tile.actuator()) flags += 64;
            if (tile.inActive()) flags += 128;

            Byte(flags);

            byte tileColour = 0, wallColour = 0;
            flags = 0;
            if (tile.wire2()) flags += 1;
            if (tile.wire3()) flags += 2;
            if (tile.active() && tile.color() > 0)
            {
                flags += 4;
                tileColour = tile.color();
            }
            if (tile.wall > 0 && tile.wallColor() > 0)
            {
                flags += 8;
                wallColour = tile.wallColor();
            }
            Byte(flags + (byte)(tile.slope() << 4));

            if (tileColour > 0) Byte(tileColour);
            if (wallColour > 0) Byte(wallColour);

            if (tile.active())
            {
                UShort(tile.type);
                if (Main.tileFrameImportant[(int)tile.type])
                {
                    Short(tile.frameX);
                    Short(tile.frameY);
                }
            }
            if (tile.wall > 0) Byte(tile.wall);

            if (tile.liquid > 0)
            {
                Byte(tile.liquid);
                Byte(tile.liquidType());
            }
        }
コード例 #26
0
 public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
 {
     if (!centerTile.active())
     {
         return;
     }
     ushort num = centerTile.type;
     Framing.BlockStyle blockStyle = Framing.FindBlockStyle(centerTile);
     int num1 = 0;
     Framing.BlockStyle blockStyle1 = new Framing.BlockStyle();
     if (blockStyle.top)
     {
         Tile tileSafely = Framing.GetTileSafely(i, j - 1);
         if (tileSafely.active() && tileSafely.type == num)
         {
             blockStyle1 = Framing.FindBlockStyle(tileSafely);
             if (!blockStyle1.bottom)
             {
                 blockStyle1.Clear();
             }
             else
             {
                 num1 = num1 | 1;
             }
         }
     }
     Framing.BlockStyle blockStyle2 = new Framing.BlockStyle();
     if (blockStyle.left)
     {
         Tile tile = Framing.GetTileSafely(i - 1, j);
         if (tile.active() && tile.type == num)
         {
             blockStyle2 = Framing.FindBlockStyle(tile);
             if (!blockStyle2.right)
             {
                 blockStyle2.Clear();
             }
             else
             {
                 num1 = num1 | 2;
             }
         }
     }
     Framing.BlockStyle blockStyle3 = new Framing.BlockStyle();
     if (blockStyle.right)
     {
         Tile tileSafely1 = Framing.GetTileSafely(i + 1, j);
         if (tileSafely1.active() && tileSafely1.type == num)
         {
             blockStyle3 = Framing.FindBlockStyle(tileSafely1);
             if (!blockStyle3.left)
             {
                 blockStyle3.Clear();
             }
             else
             {
                 num1 = num1 | 4;
             }
         }
     }
     Framing.BlockStyle blockStyle4 = new Framing.BlockStyle();
     if (blockStyle.bottom)
     {
         Tile tile1 = Framing.GetTileSafely(i, j + 1);
         if (tile1.active() && tile1.type == num)
         {
             blockStyle4 = Framing.FindBlockStyle(tile1);
             if (!blockStyle4.top)
             {
                 blockStyle4.Clear();
             }
             else
             {
                 num1 = num1 | 8;
             }
         }
     }
     if (blockStyle1.left && blockStyle2.top)
     {
         Tile tileSafely2 = Framing.GetTileSafely(i - 1, j - 1);
         if (tileSafely2.active() && tileSafely2.type == num)
         {
             Framing.BlockStyle blockStyle5 = Framing.FindBlockStyle(tileSafely2);
             if (blockStyle5.right && blockStyle5.bottom)
             {
                 num1 = num1 | 16;
             }
         }
     }
     if (blockStyle1.right && blockStyle3.top)
     {
         Tile tile2 = Framing.GetTileSafely(i + 1, j - 1);
         if (tile2.active() && tile2.type == num)
         {
             Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tile2);
             if (blockStyle6.left && blockStyle6.bottom)
             {
                 num1 = num1 | 32;
             }
         }
     }
     if (blockStyle4.left && blockStyle2.bottom)
     {
         Tile tileSafely3 = Framing.GetTileSafely(i - 1, j + 1);
         if (tileSafely3.active() && tileSafely3.type == num)
         {
             Framing.BlockStyle blockStyle7 = Framing.FindBlockStyle(tileSafely3);
             if (blockStyle7.right && blockStyle7.top)
             {
                 num1 = num1 | 64;
             }
         }
     }
     if (blockStyle4.right && blockStyle3.bottom)
     {
         Tile tile3 = Framing.GetTileSafely(i + 1, j + 1);
         if (tile3.active() && tile3.type == num)
         {
             Framing.BlockStyle blockStyle8 = Framing.FindBlockStyle(tile3);
             if (blockStyle8.left && blockStyle8.top)
             {
                 num1 = num1 | 128;
             }
         }
     }
     if (resetFrame)
     {
         centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3));
     }
     Point16 point16 = Framing.selfFrame8WayLookup[num1][centerTile.frameNumber()];
     centerTile.frameX = point16.X;
     centerTile.frameY = point16.Y;
 }
        //#if TEST_COMPRESSION
        private int TileSize(Tile tile)
        {
            int count = 1;

            var active = tile.active();
            var wall = tile.wall;
            var liquid = tile.liquid;

            if (active)
            {
                var type = tile.type;

                count += 1;

                if (Main.tileFrameImportant[type])
                {
                    count += 4;
                }
            }

            if (wall > 0)
            {
                count += 1;
            }

            if (liquid > 0)
            {
                count += 2;
            }

            return count;
        }
コード例 #28
0
        public static void Write(this BinaryWriter writer, Tile tile)
        {
            writer.Write(tile.sTileHeader);
            writer.Write(tile.bTileHeader);
            writer.Write(tile.bTileHeader2);

            if (tile.active())
            {
                writer.Write(tile.type);
                if (Main.tileFrameImportant[tile.type])
                {
                    writer.Write(tile.frameX);
                    writer.Write(tile.frameY);
                }
            }
            writer.Write(tile.wall);
            writer.Write(tile.liquid);
        }
コード例 #29
0
ファイル: PortalHelper.cs プロジェクト: EmuDevs/EDTerraria
 private static bool BlockPortals(Tile t)
 {
     return t.active() && !Main.tileCut[(int)t.type] && (!TileID.Sets.BreakableWhenPlacing[(int)t.type] && Main.tileSolid[(int)t.type]);
 }
コード例 #30
0
 private static bool BlockPortals(Tile t)
 {
     if (t.active() && !Main.tileCut[t.type] && !TileID.Sets.BreakableWhenPlacing[t.type] && Main.tileSolid[t.type])
     {
         return true;
     }
     return false;
 }
コード例 #31
0
ファイル: Tools.cs プロジェクト: Jewsus/Mazes
		public static Tile ReadTile(BinaryReader reader)
		{
			Tile tile = new Tile();
			byte flags = reader.ReadByte();
			if ((flags & 1) == 1)
			{
				byte type = reader.ReadByte();
                tile.active(true);
				tile.type = type;
				if (Main.tileFrameImportant[type])
				{
					tile.frameNumber(reader.ReadByte());
					tile.frameX = reader.ReadInt16();
					tile.frameY = reader.ReadInt16();
				}
				else
				{
					tile.frameX = -1;
					tile.frameY = -1;
				}
			}
			if ((flags & 2) == 2)
			{
				tile.wall = reader.ReadByte();
			}
			if ((flags & 4) == 4)
			{
				tile.liquid = reader.ReadByte();
			}
			if ((flags & 8) == 8)
			{
                tile.lava(true);
			}
			if ((flags & 16) == 16)
			{
				tile.wire(true);
			}
			return tile;
		}
コード例 #32
0
		public static bool SolidTile(Tile testTile)
		{
			try
			{
				if (testTile == null)
				{
					bool result = true;
					return result;
				}
				if (testTile.active() && Main.tileSolid[(int)testTile.type] && !Main.tileSolidTop[(int)testTile.type] && !testTile.halfBrick() && testTile.slope() == 0 && !testTile.inActive())
				{
					bool result = true;
					return result;
				}
			}
			catch
			{
			}
			return false;
		}
コード例 #33
0
        public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
        {
            if (!centerTile.active())
            {
                return;
            }
            ushort     type        = centerTile.type;
            BlockStyle blockStyle  = FindBlockStyle(centerTile);
            int        num         = 0;
            BlockStyle blockStyle2 = default(BlockStyle);

            if (blockStyle.top)
            {
                Tile tileSafely = GetTileSafely(i, j - 1);
                if (tileSafely.active() && tileSafely.type == type)
                {
                    blockStyle2 = FindBlockStyle(tileSafely);
                    if (blockStyle2.bottom)
                    {
                        num |= 1;
                    }
                    else
                    {
                        blockStyle2.Clear();
                    }
                }
            }
            BlockStyle blockStyle3 = default(BlockStyle);

            if (blockStyle.left)
            {
                Tile tileSafely2 = GetTileSafely(i - 1, j);
                if (tileSafely2.active() && tileSafely2.type == type)
                {
                    blockStyle3 = FindBlockStyle(tileSafely2);
                    if (blockStyle3.right)
                    {
                        num |= 2;
                    }
                    else
                    {
                        blockStyle3.Clear();
                    }
                }
            }
            BlockStyle blockStyle4 = default(BlockStyle);

            if (blockStyle.right)
            {
                Tile tileSafely3 = GetTileSafely(i + 1, j);
                if (tileSafely3.active() && tileSafely3.type == type)
                {
                    blockStyle4 = FindBlockStyle(tileSafely3);
                    if (blockStyle4.left)
                    {
                        num |= 4;
                    }
                    else
                    {
                        blockStyle4.Clear();
                    }
                }
            }
            BlockStyle blockStyle5 = default(BlockStyle);

            if (blockStyle.bottom)
            {
                Tile tileSafely4 = GetTileSafely(i, j + 1);
                if (tileSafely4.active() && tileSafely4.type == type)
                {
                    blockStyle5 = FindBlockStyle(tileSafely4);
                    if (blockStyle5.top)
                    {
                        num |= 8;
                    }
                    else
                    {
                        blockStyle5.Clear();
                    }
                }
            }
            if (blockStyle2.left && blockStyle3.top)
            {
                Tile tileSafely5 = GetTileSafely(i - 1, j - 1);
                if (tileSafely5.active() && tileSafely5.type == type)
                {
                    BlockStyle blockStyle6 = FindBlockStyle(tileSafely5);
                    if (blockStyle6.right && blockStyle6.bottom)
                    {
                        num |= 0x10;
                    }
                }
            }
            if (blockStyle2.right && blockStyle4.top)
            {
                Tile tileSafely6 = GetTileSafely(i + 1, j - 1);
                if (tileSafely6.active() && tileSafely6.type == type)
                {
                    BlockStyle blockStyle7 = FindBlockStyle(tileSafely6);
                    if (blockStyle7.left && blockStyle7.bottom)
                    {
                        num |= 0x20;
                    }
                }
            }
            if (blockStyle5.left && blockStyle3.bottom)
            {
                Tile tileSafely7 = GetTileSafely(i - 1, j + 1);
                if (tileSafely7.active() && tileSafely7.type == type)
                {
                    BlockStyle blockStyle8 = FindBlockStyle(tileSafely7);
                    if (blockStyle8.right && blockStyle8.top)
                    {
                        num |= 0x40;
                    }
                }
            }
            if (blockStyle5.right && blockStyle4.bottom)
            {
                Tile tileSafely8 = GetTileSafely(i + 1, j + 1);
                if (tileSafely8.active() && tileSafely8.type == type)
                {
                    BlockStyle blockStyle9 = FindBlockStyle(tileSafely8);
                    if (blockStyle9.left && blockStyle9.top)
                    {
                        num |= 0x80;
                    }
                }
            }
            if (resetFrame)
            {
                centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3));
            }
            Point16 point = selfFrame8WayLookup[num][centerTile.frameNumber()];

            centerTile.frameX = point.X;
            centerTile.frameY = point.Y;
        }