public void Run() { var stopWatch = new Stopwatch(); stopWatch.Start(); PositionComponent cameraPosition = LoadMapEntitiesAndReturnPlayer(); var gameConsole = new ConsoleWindow(ConsoleHeigth, ConsoleWidth, "RogueLike"); var camera = new Camera(cameraPosition, 31, visionSystem); worldSystem.InitializeLocalMap(new PositionComponent(0, 0)); stopWatch.Stop(); Console.WriteLine("setup"); Console.WriteLine($"ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}"); stopWatch.Reset(); while (gameConsole.WindowUpdate()) { if (gameConsole.KeyPressed) { PositionComponent newPos = camera.Position.GetCopy(); MovementDirection?moveDirection = null; //Input switch (gameConsole.GetKey()) { case Key.Down: moveDirection = MovementDirection.South; break; case Key.Up: moveDirection = MovementDirection.North; break; case Key.Left: moveDirection = MovementDirection.West; break; case Key.Right: moveDirection = MovementDirection.East; break; } stopWatch.Start(); if (moveDirection.HasValue) { if (movementSystem.CanBeMovedTo(camera.Position, moveDirection.Value)) { movementSystem.Move(camera.Position, moveDirection.Value, 100); } } stopWatch.Stop(); Console.Write("CanMove:"); Console.WriteLine($"ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}"); stopWatch.Reset(); stopWatch.Start(); worldSystem.CheckAndMoveChunks(camera.Position); visionSystem.ClearMask(); visionSystem.SetVisiblePositions(camera.Position, 13); timeTrackingSystem.AdvanceTime(100); var view = camera.GetCurrentViewWithLight(worldSystem); drawingSystem.Render(gameConsole, view); stopWatch.Stop(); Console.Write("ViewMask:"); Console.WriteLine($" ms:{stopWatch.ElapsedMilliseconds} ticks:{stopWatch.ElapsedTicks}"); stopWatch.Reset(); gameConsole.Write(0, 40, $"CameraPos Y:{camera.Position.YCoord},X:{camera.Position.XCoord}", Color4.White); gameConsole.Write(1, 40, $"TopLeftChunk Y:{worldSystem.TopLeftCorner.YCoord},X:{worldSystem.TopLeftCorner.XCoord}".PadRight(30), Color4.White); gameConsole.Write(2, 40, $"Current Chunk Y:{worldSystem.PositionInChunk(cameraPosition).ToString()}".PadRight(30), Color4.White); gameConsole.Write(3, 40, $"Current World Time: {timeTrackingSystem.CurrentTime}.".PadRight(30), Color4.White); } } }