Use Map.IsInMap(CPos) for things that are checking CPos.

This commit is contained in:
Paul Chote
2014-03-10 00:07:08 +13:00
parent e825205542
commit 2026747f2a
6 changed files with 9 additions and 8 deletions

View File

@@ -75,9 +75,10 @@ namespace OpenRA.Editor
Action<int, int> maybeEnqueue = (x, y) =>
{
if (s.Map.IsInMap(x, y) && !touched[x, y])
var c = new CPos(x, y);
if (s.Map.IsInMap(c) && !touched[x, y])
{
queue.Enqueue(new CPos(x, y));
queue.Enqueue(c);
touched[x, y] = true;
}
};

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Buildings
var res = world.WorldActor.Trait<ResourceLayer>();
return FootprintUtils.Tiles(world.Map.Rules, name, building, topLeft).All(
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
t => world.Map.IsInMap(t) && res.GetResource(t) == null &&
world.IsCellBuildable(t, building, toIgnore));
}

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA
public bool CanEnterCell(CPos cell, Actor ignoreActor, bool checkTransientActors)
{
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
if (!self.World.Map.IsInMap(cell)) return false;
var type = self.World.Map.GetTerrainInfo(cell).Type;
if (!info.TerrainTypes.Contains(type))

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
public bool CanEnterCell(CPos cell, Actor ignoreActor, bool checkTransientActors)
{
if (!self.World.Map.IsInMap(cell.X, cell.Y))
if (!self.World.Map.IsInMap(cell))
return false;
if (!info.AllowedTerrain.Contains(self.World.Map.GetTerrainInfo(cell).Type))

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Move
public int MovementCostForCell(World world, CPos cell)
{
if (!world.Map.IsInMap(cell.X, cell.Y))
if (!world.Map.IsInMap(cell))
return int.MaxValue;
var index = world.Map.GetTerrainIndex(cell);

View File

@@ -124,7 +124,7 @@ namespace OpenRA.Mods.RA.Move
var newHere = p.Location + d;
// Is this direction flat-out unusable or already seen?
if (!world.Map.IsInMap(newHere.X, newHere.Y))
if (!world.Map.IsInMap(newHere))
continue;
if (cellInfo[newHere.X, newHere.Y].Seen)
continue;
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.RA.Move
public void AddInitialCell(CPos location)
{
if (!world.Map.IsInMap(location.X, location.Y))
if (!world.Map.IsInMap(location))
return;
cellInfo[location.X, location.Y] = new CellInfo(0, location, false);