示例#1
0
        private List <Line> CreateMerlon(string[] commandArgs, Position position, List <SavedPosition> savedPositions, List <Line> lines)
        {
            IGenerator     generator;
            ISquareOptions walls = new Options();

            walls.Fill   = false;
            walls.Merlon = true;
            switch (commandArgs.Length)
            {
            // width height block [postition]
            case 4:
                walls.Width   = commandArgs[1].ToInt();
                walls.Length  = commandArgs[2].ToInt();
                walls.Height  = 1;
                walls.Block   = commandArgs[3];
                walls.CenterX = position.X;
                walls.CenterY = position.Y;
                walls.CenterZ = position.Z;
                break;

            case 5:

                walls.Width  = commandArgs[1].ToInt();
                walls.Length = commandArgs[2].ToInt();
                walls.Height = 1;
                walls.Block  = commandArgs[3];
                var center = savedPositions.Single(a => a.Name.Equals(commandArgs[4])).Position;
                walls.CenterX = center.X;
                walls.CenterY = center.Y;
                walls.CenterZ = center.Z;
                break;

            case 7:

                walls.Width   = commandArgs[1].ToInt();
                walls.Length  = commandArgs[2].ToInt();
                walls.Height  = 1;
                walls.Block   = commandArgs[3];
                walls.CenterX = commandArgs[4].ToInt();
                walls.CenterY = commandArgs[5].ToInt();
                walls.CenterZ = commandArgs[6].ToInt();
                break;

            default:
                var help = "create merlon length width block - center at current position\n" +
                           "create merlon length width block [named position]\n" +
                           "create merlon length width block x y z";
                _minecraft.Status(help);
                return(new List <Line>());
            }
            generator = new MerlonGenerator();
            lines     = generator.Run((Options)walls);
            return(lines);
        }
        private static List <Line> CreateMerlon(IMinecraftCommandService commandService, string[] commandArgs,
                                                Position position, List <SavedPosition> savedPositions)
        {
            ISquareOptions merlon = new Options {
                Fill = false, Merlon = true
            };

            commandArgs = ProcessFillArgument(commandArgs, (Options)merlon);
            var location = position;

            switch (commandArgs.Length)
            {
            case 4:     // width(X) length(Z) block @ current position
                merlon.Width  = commandArgs[1].ToInt();
                merlon.Length = commandArgs[2].ToInt();
                merlon.Height = 1;
                merlon.Block  = commandArgs[3];
                break;

            case 5:     // width(X) length(Z) block savedposition
            case 7:     // width(X) length(Z) block x y z
                merlon.Width  = commandArgs[1].ToInt();
                merlon.Length = commandArgs[2].ToInt();
                merlon.Height = 1;
                merlon.Block  = commandArgs[3];
                location      = location.GetAbsolutePosition(commandArgs.Skip(4).Take(3), savedPositions);
                break;

            default:
                var help = "\nCREATE MERLON\n" +
                           "create merlon [fill] width(X) length(Z) block - center at current position\n" +
                           "create merlon [fill] width(X) length(Z) block [named position]\n" +
                           "create merlon [fill] width(X) length(Z) block [x y z]";
                commandService.Status(help);
                return(new List <Line>());
            }

            merlon.Start = location.ToPoint();
            IGenerator generator = new MerlonGenerator();

            return(generator.Run((Options)merlon));
        }
        public void merlon_test()
        {
            var gen     = new MerlonGenerator();
            var results = gen.Run(new Options()
            {
                Block   = "wool",
                CenterX = 0,
                CenterY = 4,
                CenterZ = 0,
                Fill    = false,
                Height  = 1,
                Merlon  = true,
                Width   = 40,
                Length  = 1
            });

            foreach (var a in results)
            {
                Trace.WriteLine($"{a.X} {a.Y} {a.Z}");
            }
        }