Esempio n. 1
0
        private static void MakeHouseSupports(Rectangle rect, int floorTileY)
        {
            var supportLeft  = new Rectangle(rect.X, floorTileY, 1, 256);
            var supportRight = new Rectangle(rect.X + rect.Width - 1, floorTileY, 1, 256);
            int floorLeft    = floorTileY + 256;
            int floorRight   = floorTileY + 256;

            var woodBeamDef = new TileDrawDefinition {
                TileType = TileID.WoodenBeam
            };

            //

            TileDrawDefinition getSupportLeftDef(int x, int y)
            {
                if (y >= floorLeft)
                {
                    return(null);
                }

                if (Main.tile[x, y].active())
                {
                    if (TileAttributeLibraries.IsBreakable(x, y))
                    {
                        WorldGen.KillTile(x, y, false, false, true);
                    }
                    else
                    {
                        floorLeft = y;
                        return(null);
                    }
                }
                return(new TileDrawDefinition {
                    TileType = TileID.WoodenBeam
                });
            }

            //

            TileDrawDefinition getSupportRightDef(int x, int y)
            {
                if (y >= floorRight)
                {
                    return(null);
                }

                if (Main.tile[x, y].active())
                {
                    if (TileAttributeLibraries.IsBreakable(x, y))
                    {
                        WorldGen.KillTile(x, y, false, false, true);
                    }
                    else
                    {
                        floorRight = y;
                        return(null);
                    }
                }
                return(new TileDrawDefinition {
                    TileType = TileID.WoodenBeam
                });
            }

            //

            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.Any,
                area: supportLeft,
                hollow: null,
                place: getSupportLeftDef
                );
            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.Any,
                area: supportRight,
                hollow: null,
                place: getSupportRightDef
                );

            if (Main.netMode == NetmodeID.Server)
            {
                Timers.SetTimer(2, false, () => {
//LogLibraries.Log( "!!!MakeHouseSupports 1 " + supportLeft.ToString() );
                    TileRectangleModPacketProtocol.Send(supportLeft);
                    return(false);
                });
                Timers.SetTimer(4, false, () => {
//LogLibraries.Log( "!!!MakeHouseSupports 2 " + supportRight.ToString() );
                    TileRectangleModPacketProtocol.Send(supportRight);
                    return(false);
                });
            }
        }
        public static void MakeScaffold(int leftTileX, int floorTileY)
        {
            int width  = ScaffoldingErectorKitItem.ScaffoldWidth;
            int height = ScaffoldingErectorKitItem.ScaffoldHeight;
            var rect   = new Rectangle(
                leftTileX,
                floorTileY - height,
                width,
                height
                );

            var postTileDef = new TileDrawDefinition {
                NotActive = true,
                WallType  = WallID.RichMahoganyFence
            };
            var platTileDef = new TileDrawDefinition {
                SkipWall = true,
                TileType = TileID.Platforms
            };

            //

            int findFloor(int myTileX, int myTileY)
            {
                int y;

                for (y = myTileY; !TileLibraries.IsSolid(Main.tile[myTileX, y], true, true); y++)
                {
                    if (y >= Main.maxTilesY - 1)
                    {
                        break;
                    }
                }
                return(y);
            }

            //

            int rightTileX  = rect.X + rect.Width - 1;
            int lPostFloorY = findFloor(leftTileX, rect.Bottom);
            int rPostFloorY = findFloor(rightTileX, rect.Bottom);

            // Posts
            if (Main.tile[leftTileX - 1, rect.Y].wall != WallID.RichMahoganyFence)
            {
                TileDrawPrimitivesLibraries.DrawRectangle(
                    filter: TilePattern.NonSolid,
                    area: new Rectangle(leftTileX, rect.Y, 1, lPostFloorY - rect.Y),
                    hollow: null,
                    place: (x, y) => postTileDef
                    );
            }
            if (Main.tile[rightTileX + 1, rect.Y].wall != WallID.RichMahoganyFence)
            {
                TileDrawPrimitivesLibraries.DrawRectangle(
                    filter: TilePattern.NonSolid,
                    area: new Rectangle(rightTileX, rect.Y, 1, rPostFloorY - rect.Y),
                    hollow: null,
                    place: (x, y) => postTileDef
                    );
            }

            // Platforms
            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.NonSolid,
                area: new Rectangle(rect.X, rect.Y, width, 1),
                hollow: null,
                place: (x, y) => platTileDef
                );

            //

            Main.PlaySound(SoundID.Item69, rect.Center.ToVector2() * 16);

            //

            if (Main.netMode == NetmodeID.Server)
            {
//LogLibraries.Log( "!!!MakeScaffold " + rect.ToString() );
                TileRectangleModPacketProtocol.Send(rect);
            }
        }
Esempio n. 3
0
        public static void MakeHouseFrame(int midTileX, int floorTileY)
        {
            int width     = HouseFramingKitItem.FrameWidth;
            int height    = HouseFramingKitItem.FrameHeight;
            var outerRect = new Rectangle(
                midTileX - (width / 2),
                floorTileY - height,
                width,
                height
                );
            var innerRect = outerRect;

            innerRect.X      += 1;
            innerRect.Y      += 1;
            innerRect.Width  -= 2;
            innerRect.Height -= 2;

            var frameTileDef = new TileDrawDefinition {
                TileType = TileID.WoodBlock
            };

            //

            bool isSolidFrame(int x, int y)
            => HouseFramingKitItem.IsHouseFrameTileSolid(x, y, width, height, outerRect);

            //

            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.NonActive,
                area: outerRect,
                hollow: innerRect,
                place: (x, y) => isSolidFrame(x, y) ? frameTileDef : null
                );
            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.NonActive,
                area: outerRect,
                hollow: null,
                place: (int x, int y) => HouseFramingKitItem.GetHouseFrameTileDefAt1(x, y, width, height, outerRect)
                );
            TileDrawPrimitivesLibraries.DrawRectangle(
                filter: TilePattern.NonActive,
                area: outerRect,
                hollow: null,
                place: (int x, int y) => HouseFramingKitItem.GetHouseFrameTileDefAt2(x, y, width, height, outerRect)
                );

            /*int ceiling = floorTileY - height;
             *
             * Tile tile1 = Main.tile[ midTileX-3, ceiling+1 ];
             * tile1.slope( 1 );
             * Tile tile2 = Main.tile[ midTileX+2, ceiling+1 ];
             * tile2.slope( 2 );*/

            if (Main.netMode == NetmodeID.Server)
            {
//LogLibraries.Log( "!!!MakeHouseFrame "+outerRect.ToString() );
                TileRectangleModPacketProtocol.Send(outerRect);
            }

            //

            HouseFramingKitItem.MakeHouseSupports(outerRect, floorTileY);

            Main.PlaySound(SoundID.Item108, new Vector2(midTileX * 16, floorTileY * 16));
        }