Fix warnings in MapRenderer module (#17865)
This commit is contained in:
@@ -101,7 +101,7 @@ Options:
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandLineArgumentException : Exception
|
||||
public sealed class CommandLineArgumentException : Exception
|
||||
{
|
||||
public CommandLineArgumentException(string? message) : base(message)
|
||||
{
|
||||
|
||||
@@ -133,8 +133,8 @@ public sealed class EntityPainter
|
||||
.Resize(imgX, imgY)
|
||||
.Flip(FlipMode.Vertical));
|
||||
|
||||
var pointX = (int) entity.X - (imgX / 2) + EyeManager.PixelsPerMeter / 2;
|
||||
var pointY = (int) entity.Y - (imgY / 2) + EyeManager.PixelsPerMeter / 2;
|
||||
var pointX = (int) entity.X - imgX / 2 + EyeManager.PixelsPerMeter / 2;
|
||||
var pointY = (int) entity.Y - imgY / 2 + EyeManager.PixelsPerMeter / 2;
|
||||
canvas.Mutate(o => o.DrawImage(image, new Point(pointX, pointY), 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace Content.MapRenderer.Painters
|
||||
return decals;
|
||||
}
|
||||
|
||||
private (float x, float y) TransformLocalPosition(Vector2 position, MapGridComponent grid)
|
||||
private static (float x, float y) TransformLocalPosition(Vector2 position, MapGridComponent grid)
|
||||
{
|
||||
var xOffset = (int) -grid.LocalAABB.Left;
|
||||
var yOffset = (int) -grid.LocalAABB.Bottom;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.MapRenderer.Painters
|
||||
{
|
||||
public sealed class MapPainter
|
||||
{
|
||||
public async IAsyncEnumerable<RenderedGridImage<Rgba32>> Paint(string map)
|
||||
public static async IAsyncEnumerable<RenderedGridImage<Rgba32>> Paint(string map)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
@@ -78,9 +78,9 @@ namespace Content.MapRenderer.Painters
|
||||
var mapId = sMapManager.GetAllMapIds().Last();
|
||||
grids = sMapManager.GetAllMapGrids(mapId).Select(o => (o.Owner, o)).ToArray();
|
||||
|
||||
foreach (var grid in grids)
|
||||
foreach (var (uid, _) in grids)
|
||||
{
|
||||
var gridXform = xformQuery.GetComponent(grid.Uid);
|
||||
var gridXform = xformQuery.GetComponent(uid);
|
||||
xformSystem.SetWorldRotation(gridXform, Angle.Zero);
|
||||
}
|
||||
});
|
||||
@@ -88,19 +88,19 @@ namespace Content.MapRenderer.Painters
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
foreach (var grid in grids)
|
||||
foreach (var (uid, grid) in grids)
|
||||
{
|
||||
// Skip empty grids
|
||||
if (grid.Grid.LocalAABB.IsEmpty())
|
||||
if (grid.LocalAABB.IsEmpty())
|
||||
{
|
||||
Console.WriteLine($"Warning: Grid {grid.Uid} was empty. Skipping image rendering.");
|
||||
Console.WriteLine($"Warning: Grid {uid} was empty. Skipping image rendering.");
|
||||
continue;
|
||||
}
|
||||
|
||||
var tileXSize = grid.Grid.TileSize * TilePainter.TileImageSize;
|
||||
var tileYSize = grid.Grid.TileSize * TilePainter.TileImageSize;
|
||||
var tileXSize = grid.TileSize * TilePainter.TileImageSize;
|
||||
var tileYSize = grid.TileSize * TilePainter.TileImageSize;
|
||||
|
||||
var bounds = grid.Grid.LocalAABB;
|
||||
var bounds = grid.LocalAABB;
|
||||
|
||||
var left = bounds.Left;
|
||||
var right = bounds.Right;
|
||||
@@ -114,16 +114,16 @@ namespace Content.MapRenderer.Painters
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
tilePainter.Run(gridCanvas, grid.Uid, grid.Grid);
|
||||
entityPainter.Run(gridCanvas, grid.Uid, grid.Grid);
|
||||
tilePainter.Run(gridCanvas, uid, grid);
|
||||
entityPainter.Run(gridCanvas, uid, grid);
|
||||
|
||||
gridCanvas.Mutate(e => e.Flip(FlipMode.Vertical));
|
||||
});
|
||||
|
||||
var renderedImage = new RenderedGridImage<Rgba32>(gridCanvas)
|
||||
{
|
||||
GridUid = grid.Uid,
|
||||
Offset = xformSystem.GetWorldPosition(grid.Uid),
|
||||
GridUid = uid,
|
||||
Offset = xformSystem.GetWorldPosition(uid),
|
||||
};
|
||||
|
||||
yield return renderedImage;
|
||||
|
||||
@@ -15,7 +15,7 @@ using SixLabors.ImageSharp.Formats.Webp;
|
||||
|
||||
namespace Content.MapRenderer
|
||||
{
|
||||
internal class Program
|
||||
internal sealed class Program
|
||||
{
|
||||
private const string NoMapsChosenMessage = "No maps were chosen";
|
||||
private static readonly Func<string, string> ChosenMapIdNotIntMessage = id => $"The chosen id is not a valid integer: {id}";
|
||||
@@ -166,7 +166,7 @@ namespace Content.MapRenderer
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
var fileName = Path.GetFileNameWithoutExtension(map);
|
||||
var savePath = $"{directory}{Path.DirectorySeparatorChar}{fileName}-{i}.{arguments.Format.ToString()}";
|
||||
var savePath = $"{directory}{Path.DirectorySeparatorChar}{fileName}-{i}.{arguments.Format}";
|
||||
|
||||
Console.WriteLine($"Writing grid of size {grid.Width}x{grid.Height} to {savePath}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user