Fix sprite overlap outside the map border.

This commit is contained in:
Paul Chote
2014-07-01 00:24:26 +12:00
parent 96c9de2b96
commit 0d625b6af6
3 changed files with 22 additions and 5 deletions

View File

@@ -40,6 +40,16 @@ namespace OpenRA
mapBottomRight = Map.CellToMap(shape, BottomRight);
}
/// <summary>Expand the specified region with an additional cordon. This may expand the region outside the map borders.</summary>
public static CellRegion Expand(CellRegion region, int cordon)
{
var offset = new CVec(cordon, cordon);
var tl = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.TopLeft) - offset);
var br = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.BottomRight) + offset);
return new CellRegion(region.shape, tl, br);
}
public bool Contains(CPos cell)
{
var uv = Map.CellToMap(shape, cell);