Пример #1
0
        private void CheckScaffoldArea()
        {
            int tileX = (int)this.player.Center.X / 16;
            int tileY = (int)this.player.position.Y / 16;

            Rectangle area;
            bool      canErect = ScaffoldingErectorKitItem.Validate(
                tileX: tileX,
                tileY: tileY,
                offsetY: ScaffoldingErectorKitItem.PlacementVerticalOffset,
                area: out area
                );

            ScaffoldingErectorKitItem.ExpectedPlacementArea = area;

            for (int x = area.Left; x < area.Right; x++)
            {
                for (int y = area.Top; y < area.Bottom; y++)
                {
                    Dust dust = Dust.NewDustPerfect(
                        Position: new Vector2((x * 16) + 8, (y * 16) + 8),
                        Velocity: default(Vector2),
                        Type: 59,
                        Alpha: 0,
                        newColor: canErect ? Color.Lime : Color.Red,
                        Scale: 1.25f
                        );
                    dust.noGravity = true;
                    dust.noLight   = true;
                }
            }
        }
Пример #2
0
        ////

        public override void ReceiveOnServer(int fromWho)
        {
            Rectangle area;
            bool      isValid = ScaffoldingErectorKitItem.Validate(
                tileX: this.PlaceAtTileX,
                tileY: this.PlaceAtTileY,
                offsetY: this.OffsetTileY,
                area: out area
                );

            if (isValid)
            {
                ScaffoldingErectorKitItem.MakeScaffold(area.Left, area.Bottom);
            }
            else
            {
                LogLibraries.Alert("Could not place house frame");
            }
        }
        ////////////////

        private static void DrawScaffoldPlacementGuidesIf()
        {
            if (!ScaffoldingErectorKitItem.ExpectedPlacementArea.HasValue)
            {
                return;
            }

            if (Main.mouseRight)
            {
                if (!TilesInterfaceLogic.WasRightClickWhileScaffoldPlacing)
                {
                    TilesInterfaceLogic.WasRightClickWhileScaffoldPlacing = true;

                    ScaffoldingErectorKitItem.PlacementVerticalOffset += 1;
                    ScaffoldingErectorKitItem.PlacementVerticalOffset %= 4;
                }
            }
            else
            {
                TilesInterfaceLogic.WasRightClickWhileScaffoldPlacing = false;
            }

            Rectangle val     = ScaffoldingErectorKitItem.ExpectedPlacementArea.Value;
            int       maxY    = ScaffoldingErectorKitItem.GetFurthestAllowedGroundTileY(val.Bottom);
            var       scrArea = new Rectangle(
                x: (val.X * 16) - (int)Main.screenPosition.X - 2,
                y: (maxY * 16) - (int)Main.screenPosition.Y - 2,
                width: (val.Width * 16) + 4,
                height: 4
                );

            float pulse = (float)Main.mouseTextColor / 255f;
            var   color = new Color(pulse, pulse, pulse, pulse);

            color *= pulse * pulse * pulse;

            Main.spriteBatch.Draw(
                texture: Main.magicPixel,
                destinationRectangle: scrArea,
                color: color
                );
        }