move backend to subfolder
This commit is contained in:
parent
d4d1f2f981
commit
8d09663eff
80 changed files with 98 additions and 88 deletions
34
tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs
Normal file
34
tanks-backend/TanksServer/Graphics/GeneratePixelsTickStep.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using DisplayCommands;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class GeneratePixelsTickStep(
|
||||
IEnumerable<IDrawStep> drawSteps,
|
||||
IEnumerable<IFrameConsumer> consumers
|
||||
) : ITickStep
|
||||
{
|
||||
private readonly List<IDrawStep> _drawSteps = drawSteps.ToList();
|
||||
private readonly List<IFrameConsumer> _consumers = consumers.ToList();
|
||||
|
||||
private readonly PixelGrid _observerPixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn);
|
||||
private readonly GamePixelGrid _gamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn);
|
||||
|
||||
public async Task TickAsync(TimeSpan _)
|
||||
{
|
||||
_gamePixelGrid.Clear();
|
||||
foreach (var step in _drawSteps)
|
||||
step.Draw(_gamePixelGrid);
|
||||
|
||||
_observerPixelGrid.Clear();
|
||||
for (var y = 0; y < MapService.PixelsPerColumn; y++)
|
||||
for (var x = 0; x < MapService.PixelsPerRow; x++)
|
||||
{
|
||||
if (_gamePixelGrid[x, y].EntityType.HasValue)
|
||||
_observerPixelGrid[(ushort)x, (ushort)y] = true;
|
||||
}
|
||||
|
||||
foreach (var consumer in _consumers)
|
||||
await consumer.OnFrameDoneAsync(_gamePixelGrid, _observerPixelGrid);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue