update to servicepoint v0.10.0
This commit is contained in:
		
							parent
							
								
									1ecd11a9e4
								
							
						
					
					
						commit
						252943be66
					
				
					 8 changed files with 13 additions and 13 deletions
				
			
		|  | @ -15,7 +15,7 @@ internal sealed class MapService | |||
|     public const ushort PixelsPerColumn = TilesPerColumn * TileSize; | ||||
| 
 | ||||
|     private readonly ConcurrentDictionary<string, MapPrototype> _mapPrototypes = new(); | ||||
|     private readonly ConcurrentDictionary<string, PixelGrid> _mapPreviews = new(); | ||||
|     private readonly ConcurrentDictionary<string, Bitmap> _mapPreviews = new(); | ||||
| 
 | ||||
|     public IEnumerable<string> MapNames => _mapPrototypes.Keys; | ||||
| 
 | ||||
|  | @ -35,14 +35,14 @@ internal sealed class MapService | |||
| 
 | ||||
|     public void SwitchTo(MapPrototype prototype) => Current = prototype.CreateInstance(); | ||||
| 
 | ||||
|     public bool TryGetPreview(string name, [MaybeNullWhen(false)] out PixelGrid pixelGrid) | ||||
|     public bool TryGetPreview(string name, [MaybeNullWhen(false)] out Bitmap pixelGrid) | ||||
|     { | ||||
|         if (_mapPreviews.TryGetValue(name, out pixelGrid)) | ||||
|             return true; // already generated | ||||
|         if (!_mapPrototypes.TryGetValue(name, out var prototype)) | ||||
|             return false; // name not found | ||||
| 
 | ||||
|         pixelGrid = PixelGrid.New(PixelsPerRow, PixelsPerColumn); | ||||
|         pixelGrid = Bitmap.New(PixelsPerRow, PixelsPerColumn); | ||||
|         DrawMapStep.Draw(pixelGrid, prototype.CreateInstance()); | ||||
| 
 | ||||
|         _mapPreviews.TryAdd(name, pixelGrid); // another thread may have added the map already | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ internal sealed class DrawMapStep(MapService map) : IDrawStep | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void Draw(PixelGrid pixels, Map map) | ||||
|     public static void Draw(Bitmap pixels, Map map) | ||||
|     { | ||||
|         for (ushort y = 0; y < MapService.PixelsPerColumn; y++) | ||||
|         for (ushort x = 0; x < MapService.PixelsPerRow; x++) | ||||
|  |  | |||
|  | @ -10,9 +10,9 @@ internal sealed class GeneratePixelsTickStep( | |||
| ) : ITickStep | ||||
| { | ||||
|     private GamePixelGrid _lastGamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private PixelGrid _lastObserverPixelGrid = PixelGrid.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _lastObserverPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private GamePixelGrid _gamePixelGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private PixelGrid _observerPixelGrid = PixelGrid.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
|     private Bitmap _observerPixelGrid = Bitmap.New(MapService.PixelsPerRow, MapService.PixelsPerColumn); | ||||
| 
 | ||||
|     private readonly List<IDrawStep> _drawSteps = drawSteps.ToList(); | ||||
|     private readonly List<IFrameConsumer> _consumers = consumers.ToList(); | ||||
|  | @ -30,7 +30,7 @@ internal sealed class GeneratePixelsTickStep( | |||
|         (_lastObserverPixelGrid, _observerPixelGrid) = (_observerPixelGrid, _lastObserverPixelGrid); | ||||
|     } | ||||
| 
 | ||||
|     private void Draw(GamePixelGrid gamePixelGrid, PixelGrid observerPixelGrid) | ||||
|     private void Draw(GamePixelGrid gamePixelGrid, Bitmap observerPixelGrid) | ||||
|     { | ||||
|         gamePixelGrid.Clear(); | ||||
|         foreach (var step in _drawSteps) | ||||
|  |  | |||
|  | @ -4,5 +4,5 @@ namespace TanksServer.Graphics; | |||
| 
 | ||||
| internal interface IFrameConsumer | ||||
| { | ||||
|     Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels); | ||||
|     Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels); | ||||
| } | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ internal sealed class ClientScreenServer( | |||
|         return base.HandleClientAsync(connection); | ||||
|     } | ||||
| 
 | ||||
|     public Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels) | ||||
|     public Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels) | ||||
|         => Connections.Select(c => c.OnGameTickAsync(observerPixels, gamePixelGrid)) | ||||
|             .WhenAll(); | ||||
| } | ||||
|  |  | |||
|  | @ -27,14 +27,14 @@ internal sealed class ClientScreenServerConnection | |||
|             : new PlayerScreenData(logger, player); | ||||
|     } | ||||
| 
 | ||||
|     public async Task OnGameTickAsync(PixelGrid pixels, GamePixelGrid gamePixelGrid) | ||||
|     public async Task OnGameTickAsync(Bitmap pixels, GamePixelGrid gamePixelGrid) | ||||
|     { | ||||
|         await Task.Yield(); | ||||
|         var next = BuildNextPackage(pixels, gamePixelGrid); | ||||
|         SetNextPackage(next); | ||||
|     } | ||||
| 
 | ||||
|     private Package BuildNextPackage(PixelGrid pixels, GamePixelGrid gamePixelGrid) | ||||
|     private Package BuildNextPackage(Bitmap pixels, GamePixelGrid gamePixelGrid) | ||||
|     { | ||||
|         var pixelsData = pixels.Data; | ||||
|         var nextPixels = _bufferPool.Rent(pixelsData.Length); | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer | |||
|         _scoresBuffer[19] = string.Join('.', localIp[2..]); | ||||
|     } | ||||
| 
 | ||||
|     public async Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels) | ||||
|     public async Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels) | ||||
|     { | ||||
|         if (!_options.CurrentValue.EnableServicePointDisplay) | ||||
|             return; | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Subproject commit c5cb6475b24fdcdcd073ea44457628daed4e21a6 | ||||
| Subproject commit 9193cfec10c72d99ad01b1ae09a935007588d7d9 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter