Example #1
0
        ////

        public static bool Validate(int tileX, int tileY, int offsetY, out Rectangle area)
        {
            tileY += offsetY;

            int width      = ScaffoldingErectorKitItem.ScaffoldWidth;
            int height     = ScaffoldingErectorKitItem.ScaffoldHeight - offsetY;
            int leftTileX  = Math.Max(tileX - (width / 2), 1);
            int floorTileY = ScaffoldingErectorKitItem.FindScaffoldFloorY(leftTileX, tileY, width, height);

            if ((floorTileY - tileY) > height)
            {
                area = new Rectangle();
                return(false);
            }

            // Ensure minimum ground prereq
            if (!ScaffoldingErectorKitItem.ValidateBeneathFloor(leftTileX, floorTileY))
            {
                area = new Rectangle();
                return(false);
            }

            area = new Rectangle(
                Math.Min(leftTileX, Main.maxTilesX - width - 1),
                Math.Max(floorTileY - height, 1),
                width,
                height
                );

            // Ensure clear space
            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    int x = i + area.X;
                    int y = j + area.Y;
                    if (!WorldGen.InWorld(x, y))
                    {
                        return(false);
                    }

                    Tile tile = Main.tile[x, y];
                    if (tile?.active() == true)
                    {
                        switch (tile.type)
                        {
                        case TileID.Grass:
                        case TileID.CorruptGrass:
                        case TileID.FleshGrass:
                        case TileID.HallowedGrass:
                        case TileID.JungleGrass:
                        case TileID.MushroomGrass:
                            //tile.active( false );
                            break;

                        default:
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }