Skip to content

Commit

Permalink
Add entity rotation to map view
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0maks committed Aug 7, 2023
1 parent 9ab100a commit ceeea53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Content.MapRenderer/Painters/EntityData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Content.MapRenderer.Painters;

public readonly record struct EntityData(EntityUid Owner, SpriteComponent Sprite, float X, float Y)
public readonly record struct EntityData(EntityUid Owner, SpriteComponent Sprite, float X, float Y, Angle Rotation)
{
public readonly EntityUid Owner = Owner;

Expand All @@ -12,4 +12,6 @@ public readonly record struct EntityData(EntityUid Owner, SpriteComponent Sprite
public readonly float X = X;

public readonly float Y = Y;

public readonly Angle Rotation = Rotation;
}
1 change: 1 addition & 0 deletions Content.MapRenderer/Painters/EntityPainter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void Run(Image canvas, EntityData entity, SharedTransformSystem xformSyst

var pointX = (int) entity.X - (imgX / 2) + EyeManager.PixelsPerMeter / 2;
var pointY = (int) entity.Y - (imgY / 2) + EyeManager.PixelsPerMeter / 2;
image.Mutate(o => o.Rotate((float) -entity.Rotation.Degrees));
canvas.Mutate(o => o.DrawImage(image, new Point(pointX, pointY), 1));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Content.MapRenderer/Painters/GridPainter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private ConcurrentDictionary<EntityUid, List<EntityData>> GetEntities()
var position = transform.LocalPosition;

var (x, y) = TransformLocalPosition(position, grid);
var data = new EntityData(entity, sprite, x, y);
var data = new EntityData(entity, sprite, x, y, transform.LocalRotation);

components.GetOrAdd(transform.GridUid.Value, _ => new List<EntityData>()).Add(data);
}
Expand Down

0 comments on commit ceeea53

Please sign in to comment.