Map renderer rework (#37306)
* Update TilePainter.cs * Add support for custom offsets, grid files, and markers * Dynamic file category handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
@@ -32,7 +33,7 @@ public sealed class EntityPainter
|
||||
_errorImage = Image.Load<Rgba32>(_resManager.ContentFileRead("/Textures/error.rsi/error.png"));
|
||||
}
|
||||
|
||||
public void Run(Image canvas, List<EntityData> entities)
|
||||
public void Run(Image canvas, List<EntityData> entities, Vector2 customOffset = default)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
@@ -43,13 +44,13 @@ public sealed class EntityPainter
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
Run(canvas, entity, xformSystem);
|
||||
Run(canvas, entity, xformSystem, customOffset);;
|
||||
}
|
||||
|
||||
Console.WriteLine($"{nameof(EntityPainter)} painted {entities.Count} entities in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
|
||||
public void Run(Image canvas, EntityData entity, SharedTransformSystem xformSystem)
|
||||
public void Run(Image canvas, EntityData entity, SharedTransformSystem xformSystem, Vector2 customOffset = default)
|
||||
{
|
||||
if (!entity.Sprite.Visible || entity.Sprite.ContainerOccluded)
|
||||
{
|
||||
@@ -135,8 +136,8 @@ public sealed class EntityPainter
|
||||
coloredImage.Mutate(o => o.BackgroundColor(imageColor));
|
||||
|
||||
var (imgX, imgY) = rsi?.Size ?? (EyeManager.PixelsPerMeter, EyeManager.PixelsPerMeter);
|
||||
var offsetX = (int) (entity.Sprite.Offset.X * EyeManager.PixelsPerMeter);
|
||||
var offsetY = (int) (entity.Sprite.Offset.Y * EyeManager.PixelsPerMeter);
|
||||
var offsetX = (int) (entity.Sprite.Offset.X + customOffset.X) * EyeManager.PixelsPerMeter;
|
||||
var offsetY = (int) (entity.Sprite.Offset.Y + customOffset.X) * EyeManager.PixelsPerMeter;
|
||||
image.Mutate(o => o
|
||||
.DrawImage(coloredImage, PixelColorBlendingMode.Multiply, PixelAlphaCompositionMode.SrcAtop, 1)
|
||||
.Resize(imgX, imgY)
|
||||
|
||||
Reference in New Issue
Block a user