remove a bunch of locks

This commit is contained in:
Vinzenz Schroeter 2024-05-03 14:45:41 +02:00 committed by RobbersDaughter
parent b3bf62b391
commit d7b8664062
13 changed files with 126 additions and 143 deletions

View file

@ -9,8 +9,7 @@ internal sealed class DrawMapStep(MapService map) : IDrawStep
for (ushort y = 0; y < MapService.PixelsPerColumn; y++)
for (ushort x = 0; x < MapService.PixelsPerRow; x++)
{
var pixel = new PixelPosition(x, y);
if (!map.Current.IsWall(pixel))
if (!map.Current.IsWall(x, y))
continue;
pixels[x, y].EntityType = GamePixelEntityType.Wall;

View file

@ -1,5 +1,6 @@
using DisplayCommands;
using TanksServer.GameLogic;
using TanksServer.Interactivity;
namespace TanksServer.Graphics;
@ -22,7 +23,8 @@ internal sealed class GeneratePixelsTickStep(
if (_observerPixelGrid.Data.Span.SequenceEqual(_lastObserverPixelGrid.Data.Span))
return;
await Task.WhenAll(_consumers.Select(c => c.OnFrameDoneAsync(_gamePixelGrid, _observerPixelGrid)));
await _consumers.Select(c => c.OnFrameDoneAsync(_gamePixelGrid, _observerPixelGrid))
.WhenAll();
(_lastGamePixelGrid, _gamePixelGrid) = (_gamePixelGrid, _lastGamePixelGrid);
(_lastObserverPixelGrid, _observerPixelGrid) = (_observerPixelGrid, _lastObserverPixelGrid);