Terraria.Tile.blockType C# (CSharp) Method

blockType() public method

public blockType ( ) : int
return int
        public int blockType()
        {
            if (this.halfBrick())
                return 1;
            int num = (int)this.slope();
            if (num > 0)
                ++num;
            return num;
        }

Usage Example

Example #1
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, toBePlaced.alternate) == 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 * tileData.StyleLineSkip;
                    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() && tileSafely.type != (ushort)484 && (Main.tileCut[(int)tileSafely.type] || TileID.Sets.BreakableWhenPlacing[(int)tileSafely.type]))
                        {
                            WorldGen.KillTile(xCoord + index1, yCoord + index2, false, false, false);
                            if (!Main.tile[xCoord + index1, yCoord + index2].active() && Main.netMode == 1)
                            {
                                NetMessage.SendData(17, -1, -1, (NetworkText)null, 0, (float)(yCoord + index1), (float)(yCoord + index2), 0.0f, 0, 0, 0);
                            }
                        }
                    }
                }
                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 anchorBottom = tileData.AnchorBottom;
                if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int num = toBePlaced.xCoord + anchorBottom.checkStart;
                    int j   = toBePlaced.yCoord + tileData.Height;
                    for (int index = 0; index < anchorBottom.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, false);
                        }
                    }
                }
                AnchorData anchorTop = tileData.AnchorTop;
                if (anchorTop.tileCount != 0 && (anchorTop.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int num = toBePlaced.xCoord + anchorTop.checkStart;
                    int j   = toBePlaced.yCoord - 1;
                    for (int index = 0; index < anchorTop.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, false);
                        }
                    }
                }
                AnchorData anchorRight = tileData.AnchorRight;
                if (anchorRight.tileCount != 0 && (anchorRight.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int i   = toBePlaced.xCoord + tileData.Width;
                    int num = toBePlaced.yCoord + anchorRight.checkStart;
                    for (int index = 0; index < anchorRight.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, false);
                        }
                    }
                }
                AnchorData anchorLeft = tileData.AnchorLeft;
                if (anchorLeft.tileCount != 0 && (anchorLeft.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    int i   = toBePlaced.xCoord - 1;
                    int num = toBePlaced.yCoord + anchorLeft.checkStart;
                    for (int index = 0; index < anchorLeft.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, false);
                        }
                    }
                }
            }
            return(true);
        }
All Usage Examples Of Terraria.Tile::blockType