Terraria.TileObject.Place C# (CSharp) Метод

Place() публичный статический Метод

public static Place ( TileObject toBePlaced ) : bool
toBePlaced TileObject
Результат bool
        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 num1 = (ushort)toBePlaced.type;
                int num2 = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random);
                int num3 = 0;
                if (tileData.StyleWrapLimit > 0)
                {
                    num3 = num2 / tileData.StyleWrapLimit;
                    num2 %= tileData.StyleWrapLimit;
                }
                int num4;
                int num5;
                if (tileData.StyleHorizontal)
                {
                    num4 = tileData.CoordinateFullWidth * num2;
                    num5 = tileData.CoordinateFullHeight * num3;
                }
                else
                {
                    num4 = tileData.CoordinateFullWidth * num3;
                    num5 = tileData.CoordinateFullHeight * num2;
                }
                int num6 = toBePlaced.xCoord;
                int num7 = toBePlaced.yCoord;
                for (int index1 = 0; index1 < tileData.Width; ++index1)
                {
                    for (int index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        Tile tileSafely = Framing.GetTileSafely(num6 + index1, num7 + index2);
                        if (tileSafely.active() && Main.tileCut[(int)tileSafely.type])
                            WorldGen.KillTile(num6 + index1, num7 + index2, false, false, false);
                    }
                }
                for (int index1 = 0; index1 < tileData.Width; ++index1)
                {
                    int num8 = num4 + index1 * (tileData.CoordinateWidth + tileData.CoordinatePadding);
                    int num9 = num5;
                    for (int index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        Tile tileSafely = Framing.GetTileSafely(num6 + index1, num7 + index2);
                        if (!tileSafely.active())
                        {
                            tileSafely.active(true);
                            tileSafely.frameX = (short)num8;
                            tileSafely.frameY = (short)num9;
                            tileSafely.type = num1;
                        }
                        num9 += 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;
        }