Map: Rename IsInMap -> Contains.
This commit is contained in:
@@ -38,7 +38,7 @@ namespace OpenRA.Editor
|
||||
for (var v = 0; v < template.Size.Y; v++)
|
||||
{
|
||||
var cell = pos + new CVec(u, v);
|
||||
if (surface.Map.IsInMap(cell))
|
||||
if (surface.Map.Contains(cell))
|
||||
{
|
||||
var z = u + v * template.Size.X;
|
||||
if (tile[z].Length > 0)
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Editor
|
||||
Action<int, int> maybeEnqueue = (x, y) =>
|
||||
{
|
||||
var c = new CPos(x, y);
|
||||
if (s.Map.IsInMap(c) && !touched[x, y])
|
||||
if (s.Map.Contains(c) && !touched[x, y])
|
||||
{
|
||||
queue.Enqueue(c);
|
||||
touched[x, y] = true;
|
||||
@@ -112,7 +112,7 @@ namespace OpenRA.Editor
|
||||
for (;;)
|
||||
{
|
||||
var q = p + d;
|
||||
if (!s.Map.IsInMap(q)) return p;
|
||||
if (!s.Map.Contains(q)) return p;
|
||||
if (s.Map.MapTiles.Value[q].Type != replace.Type) return p;
|
||||
p = q;
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ namespace OpenRA.Editor
|
||||
{
|
||||
var cell = new CPos(x + u, y + v);
|
||||
|
||||
if (!surface1.Map.IsInMap(cell))
|
||||
if (!surface1.Map.Contains(cell))
|
||||
continue;
|
||||
|
||||
if (surface1.Map.MapResources.Value[cell].Type == resourceType)
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace OpenRA.GameRules
|
||||
if (target.Type == TargetType.Terrain)
|
||||
{
|
||||
var cell = target.CenterPosition.ToCPos();
|
||||
if (!world.Map.IsInMap(cell))
|
||||
if (!world.Map.Contains(cell))
|
||||
return false;
|
||||
|
||||
var cellInfo = world.Map.GetTerrainInfo(cell);
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
var color = t.Trait.RadarSignatureColor(t.Actor);
|
||||
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
||||
if (world.Map.IsInMap(cell))
|
||||
if (world.Map.Contains(cell))
|
||||
*(c + ((cell.Y - world.Map.Bounds.Top) * bitmapData.Stride >> 2) + cell.X - world.Map.Bounds.Left) = color.ToArgb();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace OpenRA
|
||||
return dataStream.ToArray();
|
||||
}
|
||||
|
||||
public bool IsInMap(CPos xy) { return Bounds.Contains(xy.X, xy.Y); }
|
||||
public bool Contains(CPos xy) { return Bounds.Contains(xy.X, xy.Y); }
|
||||
|
||||
public void Resize(int width, int height) // editor magic.
|
||||
{
|
||||
@@ -638,7 +638,7 @@ namespace OpenRA
|
||||
foreach (var offset in TilesByDistance[i])
|
||||
{
|
||||
var t = offset + center;
|
||||
if (IsInMap(t))
|
||||
if (Contains(t))
|
||||
yield return t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Orders
|
||||
|
||||
IEnumerable<Order> OrderInner(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == expectedButton && world.Map.IsInMap(xy))
|
||||
if (mi.Button == expectedButton && world.Map.Contains(xy))
|
||||
{
|
||||
world.CancelInputMode();
|
||||
foreach (var subject in subjects)
|
||||
@@ -66,6 +66,6 @@ namespace OpenRA.Orders
|
||||
public virtual void Tick(World world) { }
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.Contains(xy) ? cursor : "generic-blocked"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public IEnumerable<Actor> GetUnitsAt(CPos a)
|
||||
{
|
||||
if (!map.IsInMap(a))
|
||||
if (!map.Contains(a))
|
||||
yield break;
|
||||
|
||||
for (var i = influence[a]; i != null; i = i.Next)
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public IEnumerable<Actor> GetUnitsAt(CPos a, SubCell sub)
|
||||
{
|
||||
if (!map.IsInMap(a))
|
||||
if (!map.Contains(a))
|
||||
yield break;
|
||||
|
||||
for (var i = influence[a]; i != null; i = i.Next)
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public bool AllowResourceAt(ResourceType rt, CPos cell)
|
||||
{
|
||||
if (!world.Map.IsInMap(cell))
|
||||
if (!world.Map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type))
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public bool IsExplored(CPos cell)
|
||||
{
|
||||
if (!map.IsInMap(cell))
|
||||
if (!map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (Disabled || !self.World.LobbyInfo.GlobalSettings.Shroud)
|
||||
@@ -233,7 +233,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public bool IsVisible(CPos cell)
|
||||
{
|
||||
if (!map.IsInMap(cell))
|
||||
if (!map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (Disabled || !self.World.LobbyInfo.GlobalSettings.Fog)
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
TooltipType = WorldTooltipType.None;
|
||||
var cell = worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
|
||||
if (!world.Map.IsInMap(cell))
|
||||
if (!world.Map.Contains(cell))
|
||||
return;
|
||||
|
||||
if (world.ShroudObscures(cell))
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public bool CanLand(CPos cell)
|
||||
{
|
||||
if (!self.World.Map.IsInMap(cell))
|
||||
if (!self.World.Map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (self.World.ActorMap.AnyUnitsAt(cell))
|
||||
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
return false;
|
||||
|
||||
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
|
||||
cursor = self.World.Map.IsInMap(target.CenterPosition.ToCPos()) ? "move" : "move-blocked";
|
||||
cursor = self.World.Map.Contains(target.CenterPosition.ToCPos()) ? "move" : "move-blocked";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !self.World.Map.IsInMap(self.Location))
|
||||
if (IsCanceled || !self.World.Map.Contains(self.Location))
|
||||
return NextActivity;
|
||||
|
||||
var plane = self.Trait<Plane>();
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!self.World.Map.IsInMap(location))
|
||||
if (!self.World.Map.Contains(location))
|
||||
return false;
|
||||
|
||||
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA
|
||||
var subtile = new CPos(ni + ind % template.Size.X, nj + ind / template.Size.X);
|
||||
|
||||
// This isn't the bridge you're looking for
|
||||
if (!w.Map.IsInMap(subtile) || w.Map.MapTiles.Value[subtile].Type != tile ||
|
||||
if (!w.Map.Contains(subtile) || w.Map.MapTiles.Value[subtile].Type != tile ||
|
||||
w.Map.MapTiles.Value[subtile].Index != ind)
|
||||
continue;
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.RA
|
||||
// Used to check for neighbouring bridges
|
||||
public Bridge GetBridge(CPos cell)
|
||||
{
|
||||
if (!world.Map.IsInMap(cell))
|
||||
if (!world.Map.Contains(cell))
|
||||
return null;
|
||||
|
||||
return bridges[cell];
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
if (map.IsInMap(u) && influence[u] == null)
|
||||
if (map.Contains(u) && influence[u] == null)
|
||||
influence[u] = a;
|
||||
};
|
||||
|
||||
@@ -46,14 +46,14 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
if (map.IsInMap(u) && influence[u] == a)
|
||||
if (map.Contains(u) && influence[u] == a)
|
||||
influence[u] = null;
|
||||
};
|
||||
}
|
||||
|
||||
public Actor GetBuildingAt(CPos cell)
|
||||
{
|
||||
if (!map.IsInMap(cell))
|
||||
if (!map.Contains(cell))
|
||||
return null;
|
||||
|
||||
return influence[cell];
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
||||
if (world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||
|
||||
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type);
|
||||
return world.Map.Contains(a) && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type);
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)
|
||||
@@ -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) && res.GetResource(t) == null &&
|
||||
t => world.Map.Contains(t) && res.GetResource(t) == null &&
|
||||
world.IsCellBuildable(t, building, toIgnore));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
|
||||
var world = firedBy.World;
|
||||
var targetTile = pos.ToCPos();
|
||||
|
||||
if (!world.Map.IsInMap(targetTile))
|
||||
if (!world.Map.Contains(targetTile))
|
||||
return;
|
||||
|
||||
var isWater = pos.Z <= 0 && world.Map.GetTerrainInfo(targetTile).IsWater;
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public bool CanEnterCell(CPos cell, Actor ignoreActor, bool checkTransientActors)
|
||||
{
|
||||
if (!self.World.Map.IsInMap(cell)) return false;
|
||||
if (!self.World.Map.Contains(cell)) return false;
|
||||
|
||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||
if (!info.TerrainTypes.Contains(type))
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|| (dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range) // Within range
|
||||
|| (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
|
||||
|| (!info.High && world.ActorMap.GetUnitsAt(cell).Any(a => a.HasTrait<IBlocksBullets>())) // Hit a wall
|
||||
|| !world.Map.IsInMap(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below.
|
||||
|| !world.Map.Contains(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below.
|
||||
|| (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.Map.GetTerrainInfo(cell).Type != info.BoundToTerrainType); // Hit incompatible terrain
|
||||
|
||||
if (shouldExplode)
|
||||
|
||||
@@ -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))
|
||||
if (!self.World.Map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (!info.AllowedTerrain.Contains(self.World.Map.GetTerrainInfo(cell).Type))
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace OpenRA.Mods.RA
|
||||
return false;
|
||||
|
||||
var location = target.CenterPosition.ToCPos();
|
||||
if (!self.World.Map.IsInMap(location))
|
||||
if (!self.World.Map.Contains(location))
|
||||
return false;
|
||||
|
||||
cursor = "ability";
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public int MovementCostForCell(World world, CPos cell)
|
||||
{
|
||||
if (!world.Map.IsInMap(cell))
|
||||
if (!world.Map.Contains(cell))
|
||||
return int.MaxValue;
|
||||
|
||||
var index = world.Map.GetTerrainIndex(cell);
|
||||
@@ -580,7 +580,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
if (self.Owner.Shroud.IsExplored(location))
|
||||
cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor;
|
||||
|
||||
if (!self.World.Map.IsInMap(location) || (self.Owner.Shroud.IsExplored(location) &&
|
||||
if (!self.World.Map.Contains(location) || (self.Owner.Shroud.IsExplored(location) &&
|
||||
unitType.MovementCostForCell(self.World, location) == int.MaxValue))
|
||||
cursor = "move-blocked";
|
||||
|
||||
|
||||
@@ -178,7 +178,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))
|
||||
if (!world.Map.Contains(newHere))
|
||||
continue;
|
||||
|
||||
if (CellInfo[newHere].Seen)
|
||||
@@ -255,7 +255,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public void AddInitialCell(CPos location)
|
||||
{
|
||||
if (!self.World.Map.IsInMap(location))
|
||||
if (!self.World.Map.Contains(location))
|
||||
return;
|
||||
|
||||
CellInfo[location] = new CellInfo(0, location, false);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA
|
||||
return false;
|
||||
|
||||
var location = target.CenterPosition.ToCPos();
|
||||
if (self.World.Map.IsInMap(location))
|
||||
if (self.World.Map.Contains(location))
|
||||
{
|
||||
cursor = "ability";
|
||||
return true;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
if (self.CenterPosition.Z > 0 || move.IsMoving)
|
||||
return false;
|
||||
|
||||
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.IsInMap(c)
|
||||
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c)
|
||||
&& info.OpenTerrainTypes.Contains(self.World.Map.GetTerrainInfo(c).Type));
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace OpenRA.Mods.RA
|
||||
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
world.CancelInputMode();
|
||||
if (mi.Button == expectedButton && world.Map.IsInMap(xy))
|
||||
if (mi.Button == expectedButton && world.Map.Contains(xy))
|
||||
yield return new Order(order, manager.self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
|
||||
}
|
||||
|
||||
@@ -258,6 +258,6 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.Contains(xy) ? cursor : "generic-blocked"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public bool IsPassable(CPos p1, CPos p2)
|
||||
{
|
||||
if (!map.IsInMap(p1) || !map.IsInMap(p2))
|
||||
if (!map.Contains(p1) || !map.Contains(p2))
|
||||
return false;
|
||||
|
||||
if (domains[p1] == domains[p2])
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
// Select all neighbors inside the map boundries
|
||||
var neighbors = CVec.directions.Select(d => d + cell)
|
||||
.Where(c => map.IsInMap(c));
|
||||
.Where(c => map.Contains(c));
|
||||
|
||||
var found = false;
|
||||
foreach (var n in neighbors)
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
// Don't crawl off the map, or add already-visited cells
|
||||
var neighbors = CVec.directions.Select(d => n + d)
|
||||
.Where(p => map.IsInMap(p) && !visited[p]);
|
||||
.Where(p => map.Contains(p) && !visited[p]);
|
||||
|
||||
foreach (var neighbor in neighbors)
|
||||
domainQueue.Enqueue(neighbor);
|
||||
|
||||
Reference in New Issue
Block a user