Merge pull request #5630 from pavlos256/map-helpers
Move map helpers from WorldUtils to Map
This commit is contained in:
@@ -345,7 +345,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
{
|
||||
for (var k = MaxBaseDistance; k >= 0; k--)
|
||||
{
|
||||
var tlist = world.FindTilesInCircle(center, k)
|
||||
var tlist = Map.FindTilesInCircle(center, k)
|
||||
.OrderBy(a => (a.CenterPosition - pos).LengthSquared);
|
||||
|
||||
foreach (var t in tlist)
|
||||
@@ -365,8 +365,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
return enemyBase != null ? findPos(enemyBase.CenterPosition, defenseCenter) : null;
|
||||
|
||||
case BuildingType.Refinery:
|
||||
var tilesPos = world.FindTilesInCircle(baseCenter, MaxBaseDistance)
|
||||
.Where(a => resourceTypeIndices.Contains(world.GetTerrainIndex(new CPos(a.X, a.Y))));
|
||||
var tilesPos = Map.FindTilesInCircle(baseCenter, MaxBaseDistance)
|
||||
.Where(a => resourceTypeIndices.Contains(Map.GetTerrainIndex(new CPos(a.X, a.Y))));
|
||||
if (tilesPos.Any())
|
||||
{
|
||||
var pos = tilesPos.MinBy(a => (a.CenterPosition - baseCenter.CenterPosition).LengthSquared);
|
||||
@@ -377,7 +377,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
case BuildingType.Building:
|
||||
for (var k = 0; k < maxBaseDistance; k++)
|
||||
{
|
||||
foreach (var t in world.FindTilesInCircle(baseCenter, k))
|
||||
foreach (var t in Map.FindTilesInCircle(baseCenter, k))
|
||||
{
|
||||
if (world.CanPlaceBuilding(actorType, bi, t, null))
|
||||
{
|
||||
@@ -696,7 +696,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
// Won't work for shipyards...
|
||||
CPos ChooseRallyLocationNear(CPos startPos)
|
||||
{
|
||||
var possibleRallyPoints = world.FindTilesInCircle(startPos, Info.RallyPointScanRadius)
|
||||
var possibleRallyPoints = Map.FindTilesInCircle(startPos, Info.RallyPointScanRadius)
|
||||
.Where(IsRallyPointValid);
|
||||
|
||||
if (!possibleRallyPoints.Any())
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
bool screenFlash;
|
||||
string sound;
|
||||
|
||||
const int maxCellSearchRange = WorldUtils.MaxRange;
|
||||
const int maxCellSearchRange = Map.MaxTilesInCircleRange;
|
||||
|
||||
public Teleport(Actor chronosphere, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
CPos? ChooseBestDestinationCell(Actor self, CPos destination)
|
||||
{
|
||||
var restrictTo = maximumDistance == null ? null : self.World.FindTilesInCircle(self.Location, maximumDistance.Value);
|
||||
var restrictTo = maximumDistance == null ? null : self.World.Map.FindTilesInCircle(self.Location, maximumDistance.Value);
|
||||
|
||||
if (maximumDistance != null)
|
||||
destination = restrictTo.MinBy(x => (x - destination).LengthSquared);
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var searched = new List<CPos>();
|
||||
for (int r = 1; r <= maxCellSearchRange || (maximumDistance != null && r <= maximumDistance); r++)
|
||||
{
|
||||
foreach (var tile in self.World.FindTilesInCircle(destination, r).Except(searched))
|
||||
foreach (var tile in self.World.Map.FindTilesInCircle(destination, r).Except(searched))
|
||||
{
|
||||
if (self.Owner.Shroud.IsExplored(tile)
|
||||
&& (restrictTo == null || (restrictTo != null && restrictTo.Contains(tile)))
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
if (self.World.ActorMap.AnyUnitsAt(cell))
|
||||
return false;
|
||||
|
||||
var type = self.World.GetTerrainInfo(cell).Type;
|
||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||
return info.LandableTerrainTypes.Contains(type);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
if (order.OrderString == "Move")
|
||||
{
|
||||
var cell = self.World.ClampToWorld(order.TargetLocation);
|
||||
var cell = self.World.Map.Clamp(order.TargetLocation);
|
||||
var t = Target.FromCell(cell);
|
||||
|
||||
self.SetTargetLine(t, Color.Green);
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
UnReserve();
|
||||
|
||||
var cell = self.World.ClampToWorld(order.TargetLocation);
|
||||
var cell = self.World.Map.Clamp(order.TargetLocation);
|
||||
var t = Target.FromCell(cell);
|
||||
self.SetTargetLine(t, Color.Green);
|
||||
self.CancelActivity();
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var centerOffset = FootprintUtils.CenterOffset(bi);
|
||||
var location = self.Location;
|
||||
var rows = info.HasMinibib ? 1 : 2;
|
||||
var map = self.World.Map;
|
||||
|
||||
for (var i = 0; i < rows * width; i++)
|
||||
{
|
||||
@@ -52,7 +53,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var cellOffset = new CVec(i % width, i / width + bibOffset);
|
||||
|
||||
// Some mods may define terrain-specific bibs
|
||||
var terrain = self.World.GetTerrainInfo(location + cellOffset).Type;
|
||||
var terrain = map.GetTerrainInfo(location + cellOffset).Type;
|
||||
var testSequence = info.Sequence + "-" + terrain;
|
||||
var sequence = anim.HasSequence(testSequence) ? testSequence : info.Sequence;
|
||||
anim.PlayFetchIndex(sequence, () => index);
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib))
|
||||
buildingMaxBounds += new CVec(0, 1);
|
||||
|
||||
var scanStart = world.ClampToWorld(topLeft - new CVec(Adjacent, Adjacent));
|
||||
var scanEnd = world.ClampToWorld(topLeft + buildingMaxBounds + new CVec(Adjacent, Adjacent));
|
||||
var scanStart = world.Map.Clamp(topLeft - new CVec(Adjacent, Adjacent));
|
||||
var scanEnd = world.Map.Clamp(topLeft + buildingMaxBounds + new CVec(Adjacent, Adjacent));
|
||||
|
||||
var nearnessCandidates = new List<CPos>();
|
||||
|
||||
|
||||
@@ -48,17 +48,19 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
var map = self.World.Map;
|
||||
|
||||
if (template.PickAny)
|
||||
{
|
||||
// Fill the footprint with random variants
|
||||
foreach (var c in FootprintUtils.Tiles(self))
|
||||
{
|
||||
// Only place on allowed terrain types
|
||||
if (!info.TerrainTypes.Contains(self.World.GetTerrainInfo(c).Type))
|
||||
if (!info.TerrainTypes.Contains(map.GetTerrainInfo(c).Type))
|
||||
continue;
|
||||
|
||||
// Don't place under other buildings or custom terrain
|
||||
if (bi.GetBuildingAt(c) != self || self.World.Map.CustomTerrain[c.X, c.Y] != -1)
|
||||
if (bi.GetBuildingAt(c) != self || map.CustomTerrain[c.X, c.Y] != -1)
|
||||
continue;
|
||||
|
||||
var index = Game.CosmeticRandom.Next(template.TilesCount);
|
||||
@@ -74,11 +76,11 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var c = origin + new CVec(i % template.Size.X, i / template.Size.X);
|
||||
|
||||
// Only place on allowed terrain types
|
||||
if (!info.TerrainTypes.Contains(self.World.GetTerrainInfo(c).Type))
|
||||
if (!info.TerrainTypes.Contains(map.GetTerrainInfo(c).Type))
|
||||
continue;
|
||||
|
||||
// Don't place under other buildings or custom terrain
|
||||
if (bi.GetBuildingAt(c) != self || self.World.Map.CustomTerrain[c.X, c.Y] != -1)
|
||||
if (bi.GetBuildingAt(c) != self || map.CustomTerrain[c.X, c.Y] != -1)
|
||||
continue;
|
||||
|
||||
layer.AddTile(c, new TileReference<ushort, byte>(template.Id, (byte)i));
|
||||
|
||||
@@ -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.GetTerrainInfo(a).Type);
|
||||
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type);
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!world.Map.IsInMap(targetTile))
|
||||
return;
|
||||
|
||||
var isWater = pos.Z <= 0 && world.GetTerrainInfo(targetTile).IsWater;
|
||||
var isWater = pos.Z <= 0 && world.Map.GetTerrainInfo(targetTile).IsWater;
|
||||
var explosionType = isWater ? warhead.WaterExplosion : warhead.Explosion;
|
||||
var explosionTypePalette = isWater ? warhead.WaterExplosionPalette : warhead.ExplosionPalette;
|
||||
|
||||
@@ -53,17 +53,17 @@ namespace OpenRA.Mods.RA
|
||||
if (warhead.Size[0] > 0)
|
||||
{
|
||||
var resLayer = world.WorldActor.Trait<ResourceLayer>();
|
||||
var allCells = world.FindTilesInCircle(targetTile, warhead.Size[0]).ToList();
|
||||
var allCells = world.Map.FindTilesInCircle(targetTile, warhead.Size[0]).ToList();
|
||||
|
||||
// `smudgeCells` might want to just be an outer shell of the cells:
|
||||
IEnumerable<CPos> smudgeCells = allCells;
|
||||
if (warhead.Size.Length == 2)
|
||||
smudgeCells = smudgeCells.Except(world.FindTilesInCircle(targetTile, warhead.Size[1]));
|
||||
smudgeCells = smudgeCells.Except(world.Map.FindTilesInCircle(targetTile, warhead.Size[1]));
|
||||
|
||||
// Draw the smudges:
|
||||
foreach (var sc in smudgeCells)
|
||||
{
|
||||
var smudgeType = world.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
|
||||
var smudgeType = world.Map.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
|
||||
if (smudgeType == null) continue;
|
||||
|
||||
SmudgeLayer smudgeLayer;
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
else
|
||||
{
|
||||
var smudgeType = world.GetTerrainInfo(targetTile).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
|
||||
var smudgeType = world.Map.GetTerrainInfo(targetTile).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
|
||||
if (smudgeType != null)
|
||||
{
|
||||
SmudgeLayer smudgeLayer;
|
||||
@@ -110,17 +110,21 @@ namespace OpenRA.Mods.RA
|
||||
var damage = (int)GetDamageToInflict(pos, victim, warhead, weapon, firepowerModifier, true);
|
||||
victim.InflictDamage(firedBy, damage, warhead);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DamageModel.PerCell:
|
||||
{
|
||||
foreach (var t in world.FindTilesInCircle(targetTile, warhead.Size[0]))
|
||||
foreach (var t in world.Map.FindTilesInCircle(targetTile, warhead.Size[0]))
|
||||
{
|
||||
foreach (var unit in world.ActorMap.GetUnitsAt(t))
|
||||
{
|
||||
var damage = (int)GetDamageToInflict(pos, unit, warhead, weapon, firepowerModifier, false);
|
||||
unit.InflictDamage(firedBy, damage, warhead);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DamageModel.HealthPercentage:
|
||||
{
|
||||
@@ -135,9 +139,11 @@ namespace OpenRA.Mods.RA
|
||||
var healthInfo = victim.Info.Traits.Get<HealthInfo>();
|
||||
damage = (float)(damage / 100 * healthInfo.HP);
|
||||
}
|
||||
|
||||
victim.InflictDamage(firedBy, (int)damage, warhead);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
|
||||
|
||||
var type = self.World.GetTerrainInfo(cell).Type;
|
||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||
if (!info.TerrainTypes.Contains(type))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace OpenRA.Mods.RA
|
||||
if (info.DeliveryAircraft != null)
|
||||
{
|
||||
var crate = w.CreateActor(false, crateActor, new TypeDictionary { new OwnerInit(w.WorldActor.Owner) });
|
||||
var startPos = w.ChooseRandomEdgeCell();
|
||||
var altitude = self.World.Map.Rules.Actors[info.DeliveryAircraft].Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var startPos = w.Map.ChooseRandomEdgeCell(w.SharedRandom);
|
||||
var altitude = w.Map.Rules.Actors[info.DeliveryAircraft].Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var plane = w.CreateActor(info.DeliveryAircraft, new TypeDictionary
|
||||
{
|
||||
new CenterPositionInit(startPos.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)),
|
||||
@@ -114,10 +114,10 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
for (var n = 0; n < maxTries; n++)
|
||||
{
|
||||
var p = self.World.ChooseRandomCell(self.World.SharedRandom);
|
||||
var p = self.World.Map.ChooseRandomCell(self.World.SharedRandom);
|
||||
|
||||
// Is this valid terrain?
|
||||
var terrainType = self.World.GetTerrainInfo(p).Type;
|
||||
var terrainType = self.World.Map.GetTerrainInfo(p).Type;
|
||||
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -160,9 +160,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
var shouldExplode = (pos.Z < 0) // Hit the ground
|
||||
|| (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
|
||||
|| (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.GetTerrainInfo(cell).Type != info.BoundToTerrainType); // Hit incompatible terrain
|
||||
|| (!info.High && world.ActorMap.GetUnitsAt(cell).Any(a => a.HasTrait<IBlocksBullets>())) // Hit a wall
|
||||
|| (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.Map.GetTerrainInfo(cell).Type != info.BoundToTerrainType); // Hit incompatible terrain
|
||||
|
||||
if (shouldExplode)
|
||||
Explode(world);
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!self.World.Map.IsInMap(cell.X, cell.Y))
|
||||
return false;
|
||||
|
||||
if (!info.AllowedTerrain.Contains(self.World.GetTerrainInfo(cell).Type))
|
||||
if (!info.AllowedTerrain.Contains(self.World.Map.GetTerrainInfo(cell).Type))
|
||||
return false;
|
||||
|
||||
if (!checkTransientActors)
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
if (!world.Map.IsInMap(cell.X, cell.Y))
|
||||
return int.MaxValue;
|
||||
|
||||
var index = world.GetTerrainIndex(cell);
|
||||
var index = world.Map.GetTerrainIndex(cell);
|
||||
if (index == -1)
|
||||
return int.MaxValue;
|
||||
|
||||
@@ -324,13 +324,15 @@ namespace OpenRA.Mods.RA.Move
|
||||
var searched = new List<CPos>();
|
||||
// Limit search to a radius of 10 tiles
|
||||
for (int r = minRange; r < maxRange; r++)
|
||||
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
if (CanEnterCell(tile))
|
||||
return tile;
|
||||
|
||||
searched.Add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find a cell
|
||||
return target;
|
||||
@@ -343,13 +345,15 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
var searched = new List<CPos>();
|
||||
for (int r = minRange; r < maxRange; r++)
|
||||
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
foreach (var tile in self.World.Map.FindTilesInCircle(target, r).Except(searched))
|
||||
{
|
||||
if (check(tile))
|
||||
return tile;
|
||||
|
||||
searched.Add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find a cell
|
||||
return target;
|
||||
@@ -385,7 +389,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Move")
|
||||
PerformMove(self, self.World.ClampToWorld(order.TargetLocation),
|
||||
PerformMove(self, self.World.Map.Clamp(order.TargetLocation),
|
||||
order.Queued && !self.IsIdle);
|
||||
|
||||
if (order.OrderString == "Stop")
|
||||
@@ -481,7 +485,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public int MovementSpeedForCell(Actor self, CPos cell)
|
||||
{
|
||||
var index = self.World.GetTerrainIndex(cell);
|
||||
var index = self.World.Map.GetTerrainIndex(cell);
|
||||
if (index == -1)
|
||||
return 0;
|
||||
|
||||
@@ -574,7 +578,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
cursor = "move";
|
||||
|
||||
if (self.Owner.Shroud.IsExplored(location))
|
||||
cursor = self.World.GetTerrainInfo(location).CustomCursor ?? cursor;
|
||||
cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor;
|
||||
|
||||
if (!self.World.Map.IsInMap(location) || (self.Owner.Shroud.IsExplored(location) &&
|
||||
unitType.MovementCostForCell(self.World, location) == int.MaxValue))
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
// Select only the tiles that are within range from the requested SubCell
|
||||
// This assumes that the SubCell does not change during the path traversal
|
||||
var tilesInRange = world.FindTilesInCircle(targetCell, range.Range / 1024 + 1)
|
||||
var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Range / 1024 + 1)
|
||||
.Where(t => (t.CenterPosition - target).LengthSquared <= rangeSquared
|
||||
&& mi.CanEnterCell(self.World, self, t, null, true, true));
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
|
||||
var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height;
|
||||
MapControl = world.Actors
|
||||
.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == player && a.HasTrait<RevealsShroud>())
|
||||
.SelectMany(a => world.FindTilesInCircle(a.Location, a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(50)).Range / 1024))
|
||||
.SelectMany(a => world.Map.FindTilesInCircle(a.Location, a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(50)).Range / 1024))
|
||||
.Distinct()
|
||||
.Count() / total;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace OpenRA.Mods.RA.Render
|
||||
if (self.CenterPosition.Z > 0 || move.IsMoving)
|
||||
return false;
|
||||
|
||||
return cargo.CurrentAdjacentCells
|
||||
.Any(c => self.World.Map.IsInMap(c) && info.OpenTerrainTypes.Contains(self.World.GetTerrainInfo(c).Type));
|
||||
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.IsInMap(c)
|
||||
&& info.OpenTerrainTypes.Contains(self.World.Map.GetTerrainInfo(c).Type));
|
||||
}
|
||||
|
||||
void Open()
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
public void OnLanded()
|
||||
{
|
||||
var seq = self.World.GetTerrainInfo(self.Location).IsWater ? "water" : "land";
|
||||
var seq = self.World.Map.GetTerrainInfo(self.Location).IsWater ? "water" : "land";
|
||||
anim.PlayRepeating(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Returns a random cell inside the visible region of the map.")]
|
||||
public CPos RandomCell()
|
||||
{
|
||||
return context.World.ChooseRandomCell(context.World.SharedRandom);
|
||||
return context.World.Map.ChooseRandomCell(context.World.SharedRandom);
|
||||
}
|
||||
|
||||
[Desc("Returns a random cell on the visible border of the map.")]
|
||||
public CPos RandomEdgeCell()
|
||||
{
|
||||
return context.World.ChooseRandomEdgeCell();
|
||||
return context.World.Map.ChooseRandomEdgeCell(context.World.SharedRandom);
|
||||
}
|
||||
|
||||
[Desc("Returns true if there is only one human player.")]
|
||||
|
||||
@@ -339,13 +339,13 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[LuaGlobal]
|
||||
public CPos GetRandomCell()
|
||||
{
|
||||
return world.ChooseRandomCell(world.SharedRandom);
|
||||
return world.Map.ChooseRandomCell(world.SharedRandom);
|
||||
}
|
||||
|
||||
[LuaGlobal]
|
||||
public CPos GetRandomEdgeCell()
|
||||
{
|
||||
return world.ChooseRandomEdgeCell();
|
||||
return world.Map.ChooseRandomEdgeCell(world.SharedRandom);
|
||||
}
|
||||
|
||||
[LuaGlobal]
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace OpenRA.Mods.RA
|
||||
return;
|
||||
|
||||
// Spawn support units in an annulus around the base actor
|
||||
var supportSpawnCells = w.FindTilesInCircle(sp, unitGroup.OuterSupportRadius)
|
||||
.Except(w.FindTilesInCircle(sp, unitGroup.InnerSupportRadius));
|
||||
var supportSpawnCells = w.Map.FindTilesInCircle(sp, unitGroup.OuterSupportRadius)
|
||||
.Except(w.Map.FindTilesInCircle(sp, unitGroup.InnerSupportRadius));
|
||||
|
||||
foreach (var s in unitGroup.SupportActors)
|
||||
{
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude.Range;
|
||||
var target = order.TargetLocation.CenterPosition + new WVec(0, 0, altitude);
|
||||
var startEdge = target - (self.World.DistanceToMapEdge(target, -delta) + info.Cordon).Range * delta / 1024;
|
||||
var finishEdge = target + (self.World.DistanceToMapEdge(target, delta) + info.Cordon).Range * delta / 1024;
|
||||
var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Range * delta / 1024;
|
||||
var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Range * delta / 1024;
|
||||
|
||||
Actor flare = null;
|
||||
Actor camera = null;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
|
||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||
{
|
||||
var range = ((ChronoshiftPowerInfo)Info).Range;
|
||||
var tiles = self.World.FindTilesInCircle(xy, range);
|
||||
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
||||
var units = new List<Actor>();
|
||||
foreach (var t in tiles)
|
||||
units.AddRange(self.World.ActorMap.GetUnitsAt(t));
|
||||
@@ -69,8 +69,8 @@ namespace OpenRA.Mods.RA
|
||||
return false;
|
||||
|
||||
var range = ((ChronoshiftPowerInfo)Info).Range;
|
||||
var sourceTiles = self.World.FindTilesInCircle(xy, range);
|
||||
var destTiles = self.World.FindTilesInCircle(sourceLocation, range);
|
||||
var sourceTiles = self.World.Map.FindTilesInCircle(xy, range);
|
||||
var destTiles = self.World.Map.FindTilesInCircle(sourceLocation, range);
|
||||
|
||||
using (var se = sourceTiles.GetEnumerator())
|
||||
using (var de = destTiles.GetEnumerator())
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!self.Owner.Shroud.IsExplored(a) || !self.Owner.Shroud.IsExplored(b))
|
||||
return false;
|
||||
|
||||
if (self.World.GetTerrainIndex(a) != self.World.GetTerrainIndex(b))
|
||||
if (self.World.Map.GetTerrainIndex(a) != self.World.Map.GetTerrainIndex(b))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
|
||||
{
|
||||
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
|
||||
var tiles = world.FindTilesInCircle(xy, range);
|
||||
var tiles = world.Map.FindTilesInCircle(xy, range);
|
||||
var pal = wr.Palette("terrain");
|
||||
foreach (var t in tiles)
|
||||
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
@@ -216,11 +216,11 @@ namespace OpenRA.Mods.RA
|
||||
var pal = wr.Palette("terrain");
|
||||
|
||||
// Source tiles
|
||||
foreach (var t in world.FindTilesInCircle(sourceLocation, range))
|
||||
foreach (var t in world.Map.FindTilesInCircle(sourceLocation, range))
|
||||
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
|
||||
// Destination tiles
|
||||
foreach (var t in world.FindTilesInCircle(xy, range))
|
||||
foreach (var t in world.Map.FindTilesInCircle(xy, range))
|
||||
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
|
||||
// Unit previews
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||
{
|
||||
int range = ((IronCurtainPowerInfo)Info).Range;
|
||||
var tiles = self.World.FindTilesInCircle(xy, range);
|
||||
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
||||
var units = new List<Actor>();
|
||||
foreach (var t in tiles)
|
||||
units.AddRange(self.World.ActorMap.GetUnitsAt(t));
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
|
||||
var pal = wr.Palette("terrain");
|
||||
foreach (var t in world.FindTilesInCircle(xy, range))
|
||||
foreach (var t in world.Map.FindTilesInCircle(xy, range))
|
||||
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var info = (ParatroopersPowerInfo)Info;
|
||||
var items = info.DropItems;
|
||||
var startPos = self.World.ChooseRandomEdgeCell();
|
||||
var startPos = self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom);
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
base.Activate(self, order, manager);
|
||||
|
||||
var enterCell = self.World.ChooseRandomEdgeCell();
|
||||
var enterCell = self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom);
|
||||
var altitude = self.World.Map.Rules.Actors["u2"].Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
var plane = self.World.CreateActor("u2", new TypeDictionary
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
bool CanTraverseTile(World world, CPos p)
|
||||
{
|
||||
var terrainOffset = world.GetTerrainIndex(p);
|
||||
var terrainOffset = world.Map.GetTerrainIndex(p);
|
||||
return (movementClass & (1 << terrainOffset)) > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user