update to servicepoint v0.10.0

This commit is contained in:
Vinzenz Schroeter 2024-10-16 20:15:32 +02:00
parent 1ecd11a9e4
commit 252943be66
8 changed files with 13 additions and 13 deletions

View file

@ -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