Replace CPos.CenterPosition -> Map.CenterOfCell.

This commit is contained in:
Paul Chote
2013-09-17 22:27:19 +12:00
parent b6d1d26eeb
commit 7b52fa52b6
48 changed files with 105 additions and 90 deletions

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Traits
int generation;
public static Target FromPos(WPos p) { return new Target { pos = p, type = TargetType.Terrain }; }
public static Target FromCell(World w, CPos c) { return new Target { pos = c.CenterPosition, type = TargetType.Terrain }; }
public static Target FromCell(World w, CPos c) { return new Target { pos = w.Map.CenterOfCell(c), type = TargetType.Terrain }; }
public static Target FromOrder(World w, Order o)
{
return o.TargetActor != null

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Traits
public static WPos BetweenCells(World w, CPos from, CPos to)
{
return WPos.Lerp(from.CenterPosition, to.CenterPosition, 1, 2);
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);
}
public static Activity SequenceActivities(params Activity[] acts)

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Traits
var c = render[cell];
if (c.Sprite != null)
new SpriteRenderable(c.Sprite, cell.CenterPosition,
new SpriteRenderable(c.Sprite, wr.world.Map.CenterOfCell(cell),
WVec.Zero, -511, c.Type.Palette, 1f, true).Render(wr);
}
}

View File

@@ -65,12 +65,13 @@ namespace OpenRA.Traits
static IEnumerable<CPos> FindVisibleTiles(World world, CPos position, WRange radius)
{
var map = world.Map;
var r = (radius.Range + 1023) / 1024;
var limit = radius.Range * radius.Range;
var pos = position.CenterPosition;
var pos = map.CenterOfCell(position);
foreach (var cell in world.Map.FindTilesInCircle(position, r))
if ((cell.CenterPosition - pos).HorizontalLengthSquared <= limit)
foreach (var cell in map.FindTilesInCircle(position, r))
if ((map.CenterOfCell(cell) - pos).HorizontalLengthSquared <= limit)
yield return cell;
}