示例#1
0
        private static bool HandleMassWireOperation(GetDataHandlerArgs args)
        {
            var startX = args.Data.ReadInt16();
            var startY = args.Data.ReadInt16();
            var endX   = args.Data.ReadInt16();
            var endY   = args.Data.ReadInt16();

            args.Data.ReadByte();             // Ignore toolmode

            var data = PlayerInfo.GetInfo(args.Player);

            if (data.Status != PlayerInfo.PointStatus.None)
            {
                if (startX >= 0 && startY >= 0 && endX >= 0 && endY >= 0 && startX < Main.maxTilesX && startY < Main.maxTilesY && endX < Main.maxTilesX && endY < Main.maxTilesY)
                {
                    if (startX == endX && startY == endY)
                    {
                        switch (data.Status)
                        {
                        case PlayerInfo.PointStatus.Point1:
                            data.X = startX;
                            data.Y = startY;
                            args.Player.SendInfoMessage("设定点 1 完毕.");
                            break;

                        case PlayerInfo.PointStatus.Point2:
                            data.X2 = startX;
                            data.Y2 = startY;
                            args.Player.SendInfoMessage("设定点 2 完毕.");
                            break;

                        case PlayerInfo.PointStatus.Delegate:
                            data.OnGetPoint?.Invoke(startX, startY, args.Player);
                            break;
                        }
                    }
                    else
                    {
                        switch (data.Status)
                        {
                        case PlayerInfo.PointStatus.Point1:
                        case PlayerInfo.PointStatus.Point2:
                            data.X  = startX;
                            data.Y  = startY;
                            data.X2 = endX;
                            data.Y2 = endY;
                            args.Player.SendInfoMessage("设定区域完毕.");
                            break;

                        case PlayerInfo.PointStatus.Delegate:
                            data.OnGetPoint?.Invoke(startX, startY, args.Player);
                            break;
                        }
                    }
                    data.Status = PlayerInfo.PointStatus.None;
                    return(true);
                }
            }

            var points = TShock.Utils.GetMassWireOperationRange(
                new Point(startX, startY),
                new Point(endX, endY),
                args.Player.TPlayer.direction == 1
                );

            return(points.Any(p => PlotMarker.BlockModify(args.Player, p.X, p.Y)));
        }