Add ISpriteSequence.Bounds and Animation(WithOffset).ScreenBounds.

The bounds define the smallest Rectangle that covers all frames within a sequence.
This commit is contained in:
Paul Chote
2017-12-05 16:26:44 +00:00
committed by reaperrr
parent 85c5259361
commit 041431d966
4 changed files with 53 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Support;
@@ -66,6 +67,17 @@ namespace OpenRA.Graphics
return new IRenderable[] { imageRenderable };
}
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, WVec offset, float scale)
{
var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset);
var cb = CurrentSequence.Bounds;
return Rectangle.FromLTRB(
xy.X + (int)(cb.Left * scale),
xy.Y + (int)(cb.Top * scale),
xy.X + (int)(cb.Right * scale),
xy.Y + (int)(cb.Bottom * scale));
}
public IEnumerable<IRenderable> Render(WPos pos, PaletteReference palette)
{
return Render(pos, WVec.Zero, 0, palette, 1f);