public override Task <int> ExecuteCommand(GeneratorArguments args)
        {
            var stopWatch = new Stopwatch();

            if (args.Seed.HasValue)
            {
                _random.SetSeed(args.Seed.Value);
            }
            else
            {
                args.Seed = _random.Seed;
            }

            _console.Out.WriteLine(args.ToString());

            _console.Out.WriteLine($"Generating {args.Points} points");

            var worldLimit = new Vector2(args.Width, args.Height);

            stopWatch.Restart();
            var points = _worldGenerator.GeneratePoints()
                         .Select(p => new Vector2(p.X * worldLimit.X, p.Y * worldLimit.Y))
                         .Take(args.Points)
                         .ToArray();

            _console.Out.WriteLine($"Elapsed: {stopWatch.Elapsed}");

            _console.Out.WriteLine($"Constructing world...");
            stopWatch.Restart();
            var world = _worldGenerator.InitializeWorld(points, Vector2.Zero, worldLimit);

            _console.Out.WriteLine($"Elapsed: {stopWatch.Elapsed}");


            _console.Out.WriteLine($"Starting Relaxation process {args.Relax} iterations");
            for (var i = 0; i < args.Relax; i++)
            {
                _console.Out.WriteLine($"Relaxing {i + 1} of {args.Relax}");
                stopWatch.Restart();
                points = world.Cells.Select(x => x.GetCentroid()).ToArray();
                world  = _worldGenerator.RelaxCells(world);
                _console.Out.WriteLine($"Elapsed: {stopWatch.Elapsed}");
            }

            SetHeights(world);

            _console.Out.WriteLine("Starting draw");

            var drawing = _drawingFactory.GetNewRenderer();

            DrawVoronoi(drawing, world);
            drawing.Draw();

            var path = Path.GetFullPath("./Temp.svg");

            _console.Out.WriteLine($"Resulting file: {path}");
            return(Task.FromResult(0));
        }
示例#2
0
 protected override void Awake()
 {
     enemyRandom = Dungeon.Random;
     enemyRandom.SetSeed(name.GetHashCode());
     base.Awake();
 }