Merge pull request #9709 from reaperrr/unitsat-actorsat
Rename ActorMap *UnitsAt* occurences to *ActorsAt*
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
continue;
|
||||
|
||||
// HACK to check if we are on the helipad/airfield/etc.
|
||||
var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
|
||||
var hostBuilding = self.World.ActorMap.GetActorsAt(self.Location)
|
||||
.FirstOrDefault(a => a.Info.HasTraitInfo<BuildingInfo>());
|
||||
|
||||
if (hostBuilding == null || !hostBuilding.IsInWorld)
|
||||
|
||||
@@ -110,12 +110,12 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
public static void NotifyBlocker(this Actor self, CPos position)
|
||||
{
|
||||
NotifyBlocker(self, self.World.ActorMap.GetUnitsAt(position));
|
||||
NotifyBlocker(self, self.World.ActorMap.GetActorsAt(position));
|
||||
}
|
||||
|
||||
public static void NotifyBlocker(this Actor self, IEnumerable<CPos> positions)
|
||||
{
|
||||
NotifyBlocker(self, positions.SelectMany(p => self.World.ActorMap.GetUnitsAt(p)));
|
||||
NotifyBlocker(self, positions.SelectMany(p => self.World.ActorMap.GetActorsAt(p)));
|
||||
}
|
||||
|
||||
public static bool CanHarvestAt(this Actor self, CPos pos, ResourceLayer resLayer, HarvesterInfo harvInfo,
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
var neightborTiles = Util.ExpandFootprint(allTiles, true).Except(allTiles)
|
||||
.Where(world.Map.Contains).ToList();
|
||||
|
||||
var blockers = allTiles.SelectMany(world.ActorMap.GetUnitsAt)
|
||||
var blockers = allTiles.SelectMany(world.ActorMap.GetActorsAt)
|
||||
.Where(a => a.Owner == producer.Owner && a.IsIdle)
|
||||
.Select(a => new TraitPair<Mobile> { Actor = a, Trait = a.TraitOrDefault<Mobile>() });
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.World.Map.DistanceAboveTerrain(CenterPosition).Length != 0)
|
||||
return null; // not on the ground.
|
||||
|
||||
return self.World.ActorMap.GetUnitsAt(self.Location)
|
||||
return self.World.ActorMap.GetActorsAt(self.Location)
|
||||
.FirstOrDefault(a => a.Info.HasTraitInfo<ReservableInfo>());
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!self.World.Map.Contains(cell))
|
||||
return false;
|
||||
|
||||
if (self.World.ActorMap.AnyUnitsAt(cell))
|
||||
if (self.World.ActorMap.AnyActorsAt(cell))
|
||||
return false;
|
||||
|
||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||
@@ -445,7 +445,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool CanEnterTargetNow(Actor self, Target target)
|
||||
{
|
||||
if (target.Positions.Any(p => self.World.ActorMap.GetUnitsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
|
||||
if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
|
||||
return false;
|
||||
|
||||
var res = target.Actor.TraitOrDefault<Reservable>();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public static bool AnyBlockingActorAt(World world, WPos pos)
|
||||
{
|
||||
return world.ActorMap.GetUnitsAt(world.Map.CellContaining(pos))
|
||||
return world.ActorMap.GetActorsAt(world.Map.CellContaining(pos))
|
||||
.Any(a => a.TraitsImplementing<BlocksProjectiles>().Any(Exts.IsTraitEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void KillUnitsOnBridge()
|
||||
{
|
||||
foreach (var c in footprint.Keys)
|
||||
foreach (var a in self.World.ActorMap.GetUnitsAt(c))
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(c))
|
||||
if (a.Info.HasTraitInfo<IPositionableInfo>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||
a.Kill(self);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (buildingAtPos == null)
|
||||
{
|
||||
var unitsAtPos = world.ActorMap.GetUnitsAt(pos).Where(a => a.IsInWorld
|
||||
var unitsAtPos = world.ActorMap.GetActorsAt(pos).Where(a => a.IsInWorld
|
||||
&& (a.Owner == p || (allyBuildRadius && a.Owner.Stances[p] == Stance.Ally))
|
||||
&& a.Info.HasTraitInfo<GivesBuildableAreaInfo>());
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
|
||||
return false;
|
||||
|
||||
if (!bi.AllowInvalidPlacement && world.ActorMap.GetUnitsAt(cell).Any(a => a != toIgnore))
|
||||
if (!bi.AllowInvalidPlacement && world.ActorMap.GetActorsAt(cell).Any(a => a != toIgnore))
|
||||
return false;
|
||||
|
||||
var tile = world.Map.MapTiles.Value[cell];
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void OnLanded()
|
||||
{
|
||||
// Check whether the crate landed on anything
|
||||
var landedOn = self.World.ActorMap.GetUnitsAt(self.Location)
|
||||
var landedOn = self.World.ActorMap.GetActorsAt(self.Location)
|
||||
.Where(a => a != self);
|
||||
|
||||
if (!landedOn.Any())
|
||||
@@ -177,7 +177,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!checkTransientActors)
|
||||
return SubCell.FullCell;
|
||||
|
||||
return !self.World.ActorMap.GetUnitsAt(cell)
|
||||
return !self.World.ActorMap.GetActorsAt(cell)
|
||||
.Where(x => x != ignoreActor)
|
||||
.Any() ? SubCell.FullCell : SubCell.Invalid;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!checkTransientActors)
|
||||
return SubCell.FullCell;
|
||||
|
||||
return self.World.ActorMap.GetUnitsAt(cell)
|
||||
return self.World.ActorMap.GetActorsAt(cell)
|
||||
.All(x => x == ignoreActor) ? SubCell.FullCell : SubCell.Invalid;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (SharesCell && world.ActorMap.HasFreeSubCell(cell))
|
||||
return true;
|
||||
|
||||
foreach (var otherActor in world.ActorMap.GetUnitsAt(cell))
|
||||
foreach (var otherActor in world.ActorMap.GetActorsAt(cell))
|
||||
if (IsBlockedBy(self, otherActor, ignoreActor, check))
|
||||
return false;
|
||||
|
||||
@@ -283,13 +283,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, check);
|
||||
|
||||
if (!SharesCell)
|
||||
return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell, checkTransient) ? SubCell.Invalid : SubCell.FullCell;
|
||||
return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell, checkTransient) ? SubCell.Invalid : SubCell.FullCell;
|
||||
|
||||
return world.ActorMap.FreeSubCell(cell, preferredSubCell, checkTransient);
|
||||
}
|
||||
|
||||
if (!SharesCell)
|
||||
return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell) ? SubCell.Invalid : SubCell.FullCell;
|
||||
return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell) ? SubCell.Invalid : SubCell.FullCell;
|
||||
|
||||
return world.ActorMap.FreeSubCell(cell, preferredSubCell);
|
||||
}
|
||||
@@ -581,7 +581,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.CenterPosition.Z != 0)
|
||||
return;
|
||||
|
||||
var crushables = self.World.ActorMap.GetUnitsAt(ToCell).Where(a => a != self)
|
||||
var crushables = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self)
|
||||
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner)));
|
||||
foreach (var crushable in crushables)
|
||||
crushable.WarnCrush(self);
|
||||
@@ -593,7 +593,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!self.IsAtGroundLevel())
|
||||
return;
|
||||
|
||||
var crushables = self.World.ActorMap.GetUnitsAt(ToCell).Where(a => a != self)
|
||||
var crushables = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self)
|
||||
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(c => c.CrushableBy(Info.Crushes, self.Owner)));
|
||||
foreach (var crushable in crushables)
|
||||
crushable.OnCrush(self);
|
||||
@@ -664,7 +664,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
{
|
||||
var cellInfo = notStupidCells
|
||||
.SelectMany(c => self.World.ActorMap.GetUnitsAt(c)
|
||||
.SelectMany(c => self.World.ActorMap.GetActorsAt(c)
|
||||
.Where(a => a.IsIdle && a.Info.HasTraitInfo<MobileInfo>()),
|
||||
(c, a) => new { Cell = c, Actor = a })
|
||||
.RandomOrDefault(self.World.SharedRandom);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (desiredFrame > 0 && !self.World.ActorMap.GetUnitsAt(openExit).Any(a => a != self))
|
||||
if (desiredFrame > 0 && !self.World.ActorMap.GetActorsAt(openExit).Any(a => a != self))
|
||||
desiredFrame = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Update connection to neighbours
|
||||
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
||||
self.World.ActorMap.GetUnitsAt(self.Location + dir));
|
||||
self.World.ActorMap.GetActorsAt(self.Location + dir));
|
||||
|
||||
adjacent = 0;
|
||||
foreach (var a in adjacentActors)
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
static void UpdateNeighbours(Actor self)
|
||||
{
|
||||
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
||||
self.World.ActorMap.GetUnitsAt(self.Location + dir))
|
||||
self.World.ActorMap.GetActorsAt(self.Location + dir))
|
||||
.Select(a => a.TraitOrDefault<WithWallSpriteBody>())
|
||||
.Where(a => a != null);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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));
|
||||
units.AddRange(Self.World.ActorMap.GetActorsAt(t));
|
||||
|
||||
return units.Distinct().Where(a =>
|
||||
{
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Don't drop on any actors
|
||||
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(p) != null
|
||||
|| self.World.ActorMap.GetUnitsAt(p).Any())
|
||||
|| self.World.ActorMap.GetActorsAt(p).Any())
|
||||
continue;
|
||||
|
||||
return p;
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyUnitsAt(cell))
|
||||
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyActorsAt(cell))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
public static bool GetDirectHit(World world, CPos cell, WPos pos)
|
||||
{
|
||||
foreach (var unit in world.ActorMap.GetUnitsAt(cell))
|
||||
foreach (var unit in world.ActorMap.GetActorsAt(cell))
|
||||
{
|
||||
var healthInfo = unit.Info.TraitInfoOrDefault<HealthInfo>();
|
||||
if (healthInfo == null)
|
||||
|
||||
Reference in New Issue
Block a user