Rename ActorMap *UnitsAt* occurences to *ActorsAt*
These enumerate actors in general, not just mobile actors (which the term 'unit' usually refers to).
This commit is contained in:
@@ -119,7 +119,7 @@ namespace OpenRA.Orders
|
|||||||
.Select(x => new { Trait = trait, Order = x }))
|
.Select(x => new { Trait = trait, Order = x }))
|
||||||
.OrderByDescending(x => x.Order.OrderPriority))
|
.OrderByDescending(x => x.Order.OrderPriority))
|
||||||
{
|
{
|
||||||
var actorsAt = self.World.ActorMap.GetUnitsAt(self.World.Map.CellContaining(target.CenterPosition)).ToList();
|
var actorsAt = self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(target.CenterPosition)).ToList();
|
||||||
|
|
||||||
var modifiers = TargetModifiers.None;
|
var modifiers = TargetModifiers.None;
|
||||||
if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
|
if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var oldActors = currentActors;
|
var oldActors = currentActors;
|
||||||
currentActors = Footprint.SelectMany(actorMap.GetUnitsAt).ToList();
|
currentActors = Footprint.SelectMany(actorMap.GetActorsAt).ToList();
|
||||||
|
|
||||||
var entered = currentActors.Except(oldActors);
|
var entered = currentActors.Except(oldActors);
|
||||||
var exited = oldActors.Except(currentActors);
|
var exited = oldActors.Except(currentActors);
|
||||||
@@ -187,10 +187,10 @@ namespace OpenRA.Traits
|
|||||||
actorShouldBeRemoved = removeActorPosition.Contains;
|
actorShouldBeRemoved = removeActorPosition.Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class UnitsAtEnumerator : IEnumerator<Actor>
|
sealed class ActorsAtEnumerator : IEnumerator<Actor>
|
||||||
{
|
{
|
||||||
InfluenceNode node;
|
InfluenceNode node;
|
||||||
public UnitsAtEnumerator(InfluenceNode node) { this.node = node; }
|
public ActorsAtEnumerator(InfluenceNode node) { this.node = node; }
|
||||||
public void Reset() { throw new NotSupportedException(); }
|
public void Reset() { throw new NotSupportedException(); }
|
||||||
public Actor Current { get; private set; }
|
public Actor Current { get; private set; }
|
||||||
object IEnumerator.Current { get { return Current; } }
|
object IEnumerator.Current { get { return Current; } }
|
||||||
@@ -209,23 +209,23 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class UnitsAtEnumerable : IEnumerable<Actor>
|
sealed class ActorsAtEnumerable : IEnumerable<Actor>
|
||||||
{
|
{
|
||||||
readonly InfluenceNode node;
|
readonly InfluenceNode node;
|
||||||
public UnitsAtEnumerable(InfluenceNode node) { this.node = node; }
|
public ActorsAtEnumerable(InfluenceNode node) { this.node = node; }
|
||||||
public IEnumerator<Actor> GetEnumerator() { return new UnitsAtEnumerator(node); }
|
public IEnumerator<Actor> GetEnumerator() { return new ActorsAtEnumerator(node); }
|
||||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> GetUnitsAt(CPos a)
|
public IEnumerable<Actor> GetActorsAt(CPos a)
|
||||||
{
|
{
|
||||||
var uv = a.ToMPos(map);
|
var uv = a.ToMPos(map);
|
||||||
if (!influence.Contains(uv))
|
if (!influence.Contains(uv))
|
||||||
return Enumerable.Empty<Actor>();
|
return Enumerable.Empty<Actor>();
|
||||||
return new UnitsAtEnumerable(influence[uv]);
|
return new ActorsAtEnumerable(influence[uv]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> GetUnitsAt(CPos a, SubCell sub)
|
public IEnumerable<Actor> GetActorsAt(CPos a, SubCell sub)
|
||||||
{
|
{
|
||||||
var uv = a.ToMPos(map);
|
var uv = a.ToMPos(map);
|
||||||
if (!influence.Contains(uv))
|
if (!influence.Contains(uv))
|
||||||
@@ -243,14 +243,14 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, bool checkTransient = true)
|
public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, bool checkTransient = true)
|
||||||
{
|
{
|
||||||
if (preferredSubCell > SubCell.Any && !AnyUnitsAt(cell, preferredSubCell, checkTransient))
|
if (preferredSubCell > SubCell.Any && !AnyActorsAt(cell, preferredSubCell, checkTransient))
|
||||||
return preferredSubCell;
|
return preferredSubCell;
|
||||||
|
|
||||||
if (!AnyUnitsAt(cell))
|
if (!AnyActorsAt(cell))
|
||||||
return map.DefaultSubCell;
|
return map.DefaultSubCell;
|
||||||
|
|
||||||
for (var i = (int)SubCell.First; i < map.SubCellOffsets.Length; i++)
|
for (var i = (int)SubCell.First; i < map.SubCellOffsets.Length; i++)
|
||||||
if (i != (int)preferredSubCell && !AnyUnitsAt(cell, (SubCell)i, checkTransient))
|
if (i != (int)preferredSubCell && !AnyActorsAt(cell, (SubCell)i, checkTransient))
|
||||||
return (SubCell)i;
|
return (SubCell)i;
|
||||||
|
|
||||||
return SubCell.Invalid;
|
return SubCell.Invalid;
|
||||||
@@ -258,20 +258,20 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell, Func<Actor, bool> checkIfBlocker)
|
public SubCell FreeSubCell(CPos cell, SubCell preferredSubCell, Func<Actor, bool> checkIfBlocker)
|
||||||
{
|
{
|
||||||
if (preferredSubCell > SubCell.Any && !AnyUnitsAt(cell, preferredSubCell, checkIfBlocker))
|
if (preferredSubCell > SubCell.Any && !AnyActorsAt(cell, preferredSubCell, checkIfBlocker))
|
||||||
return preferredSubCell;
|
return preferredSubCell;
|
||||||
|
|
||||||
if (!AnyUnitsAt(cell))
|
if (!AnyActorsAt(cell))
|
||||||
return map.DefaultSubCell;
|
return map.DefaultSubCell;
|
||||||
|
|
||||||
for (var i = (int)SubCell.First; i < map.SubCellOffsets.Length; i++)
|
for (var i = (int)SubCell.First; i < map.SubCellOffsets.Length; i++)
|
||||||
if (i != (int)preferredSubCell && !AnyUnitsAt(cell, (SubCell)i, checkIfBlocker))
|
if (i != (int)preferredSubCell && !AnyActorsAt(cell, (SubCell)i, checkIfBlocker))
|
||||||
return (SubCell)i;
|
return (SubCell)i;
|
||||||
return SubCell.Invalid;
|
return SubCell.Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: always includes transients with influence
|
// NOTE: always includes transients with influence
|
||||||
public bool AnyUnitsAt(CPos a)
|
public bool AnyActorsAt(CPos a)
|
||||||
{
|
{
|
||||||
var uv = a.ToMPos(map);
|
var uv = a.ToMPos(map);
|
||||||
if (!influence.Contains(uv))
|
if (!influence.Contains(uv))
|
||||||
@@ -281,7 +281,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: can not check aircraft
|
// NOTE: can not check aircraft
|
||||||
public bool AnyUnitsAt(CPos a, SubCell sub, bool checkTransient = true)
|
public bool AnyActorsAt(CPos a, SubCell sub, bool checkTransient = true)
|
||||||
{
|
{
|
||||||
var uv = a.ToMPos(map);
|
var uv = a.ToMPos(map);
|
||||||
if (!influence.Contains(uv))
|
if (!influence.Contains(uv))
|
||||||
@@ -305,7 +305,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: can not check aircraft
|
// NOTE: can not check aircraft
|
||||||
public bool AnyUnitsAt(CPos a, SubCell sub, Func<Actor, bool> withCondition)
|
public bool AnyActorsAt(CPos a, SubCell sub, Func<Actor, bool> withCondition)
|
||||||
{
|
{
|
||||||
var uv = a.ToMPos(map);
|
var uv = a.ToMPos(map);
|
||||||
if (!influence.Contains(uv))
|
if (!influence.Contains(uv))
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// HACK to check if we are on the helipad/airfield/etc.
|
// 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>());
|
.FirstOrDefault(a => a.Info.HasTraitInfo<BuildingInfo>());
|
||||||
|
|
||||||
if (hostBuilding == null || !hostBuilding.IsInWorld)
|
if (hostBuilding == null || !hostBuilding.IsInWorld)
|
||||||
|
|||||||
@@ -110,12 +110,12 @@ namespace OpenRA.Mods.Common
|
|||||||
|
|
||||||
public static void NotifyBlocker(this Actor self, CPos position)
|
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)
|
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,
|
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)
|
var neightborTiles = Util.ExpandFootprint(allTiles, true).Except(allTiles)
|
||||||
.Where(world.Map.Contains).ToList();
|
.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)
|
.Where(a => a.Owner == producer.Owner && a.IsIdle)
|
||||||
.Select(a => new TraitPair<Mobile> { Actor = a, Trait = a.TraitOrDefault<Mobile>() });
|
.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)
|
if (self.World.Map.DistanceAboveTerrain(CenterPosition).Length != 0)
|
||||||
return null; // not on the ground.
|
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>());
|
.FirstOrDefault(a => a.Info.HasTraitInfo<ReservableInfo>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!self.World.Map.Contains(cell))
|
if (!self.World.Map.Contains(cell))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (self.World.ActorMap.AnyUnitsAt(cell))
|
if (self.World.ActorMap.AnyActorsAt(cell))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||||
@@ -445,7 +445,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public bool CanEnterTargetNow(Actor self, Target target)
|
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;
|
return false;
|
||||||
|
|
||||||
var res = target.Actor.TraitOrDefault<Reservable>();
|
var res = target.Actor.TraitOrDefault<Reservable>();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public static bool AnyBlockingActorAt(World world, WPos pos)
|
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));
|
.Any(a => a.TraitsImplementing<BlocksProjectiles>().Any(Exts.IsTraitEnabled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void KillUnitsOnBridge()
|
void KillUnitsOnBridge()
|
||||||
{
|
{
|
||||||
foreach (var c in footprint.Keys)
|
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))
|
if (a.Info.HasTraitInfo<IPositionableInfo>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||||
a.Kill(self);
|
a.Kill(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (buildingAtPos == null)
|
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.Owner == p || (allyBuildRadius && a.Owner.Stances[p] == Stance.Ally))
|
||||||
&& a.Info.HasTraitInfo<GivesBuildableAreaInfo>());
|
&& a.Info.HasTraitInfo<GivesBuildableAreaInfo>());
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
|
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
|
||||||
return false;
|
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;
|
return false;
|
||||||
|
|
||||||
var tile = world.Map.MapTiles.Value[cell];
|
var tile = world.Map.MapTiles.Value[cell];
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public void OnLanded()
|
public void OnLanded()
|
||||||
{
|
{
|
||||||
// Check whether the crate landed on anything
|
// 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);
|
.Where(a => a != self);
|
||||||
|
|
||||||
if (!landedOn.Any())
|
if (!landedOn.Any())
|
||||||
@@ -177,7 +177,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!checkTransientActors)
|
if (!checkTransientActors)
|
||||||
return SubCell.FullCell;
|
return SubCell.FullCell;
|
||||||
|
|
||||||
return !self.World.ActorMap.GetUnitsAt(cell)
|
return !self.World.ActorMap.GetActorsAt(cell)
|
||||||
.Where(x => x != ignoreActor)
|
.Where(x => x != ignoreActor)
|
||||||
.Any() ? SubCell.FullCell : SubCell.Invalid;
|
.Any() ? SubCell.FullCell : SubCell.Invalid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!checkTransientActors)
|
if (!checkTransientActors)
|
||||||
return SubCell.FullCell;
|
return SubCell.FullCell;
|
||||||
|
|
||||||
return self.World.ActorMap.GetUnitsAt(cell)
|
return self.World.ActorMap.GetActorsAt(cell)
|
||||||
.All(x => x == ignoreActor) ? SubCell.FullCell : SubCell.Invalid;
|
.All(x => x == ignoreActor) ? SubCell.FullCell : SubCell.Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (SharesCell && world.ActorMap.HasFreeSubCell(cell))
|
if (SharesCell && world.ActorMap.HasFreeSubCell(cell))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
foreach (var otherActor in world.ActorMap.GetUnitsAt(cell))
|
foreach (var otherActor in world.ActorMap.GetActorsAt(cell))
|
||||||
if (IsBlockedBy(self, otherActor, ignoreActor, check))
|
if (IsBlockedBy(self, otherActor, ignoreActor, check))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -283,13 +283,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, check);
|
Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, check);
|
||||||
|
|
||||||
if (!SharesCell)
|
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);
|
return world.ActorMap.FreeSubCell(cell, preferredSubCell, checkTransient);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SharesCell)
|
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);
|
return world.ActorMap.FreeSubCell(cell, preferredSubCell);
|
||||||
}
|
}
|
||||||
@@ -581,7 +581,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (self.CenterPosition.Z != 0)
|
if (self.CenterPosition.Z != 0)
|
||||||
return;
|
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)));
|
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner)));
|
||||||
foreach (var crushable in crushables)
|
foreach (var crushable in crushables)
|
||||||
crushable.WarnCrush(self);
|
crushable.WarnCrush(self);
|
||||||
@@ -593,7 +593,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!self.IsAtGroundLevel())
|
if (!self.IsAtGroundLevel())
|
||||||
return;
|
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)));
|
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(c => c.CrushableBy(Info.Crushes, self.Owner)));
|
||||||
foreach (var crushable in crushables)
|
foreach (var crushable in crushables)
|
||||||
crushable.OnCrush(self);
|
crushable.OnCrush(self);
|
||||||
@@ -664,7 +664,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cellInfo = notStupidCells
|
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>()),
|
.Where(a => a.IsIdle && a.Info.HasTraitInfo<MobileInfo>()),
|
||||||
(c, a) => new { Cell = c, Actor = a })
|
(c, a) => new { Cell = c, Actor = a })
|
||||||
.RandomOrDefault(self.World.SharedRandom);
|
.RandomOrDefault(self.World.SharedRandom);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
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;
|
desiredFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// Update connection to neighbours
|
// Update connection to neighbours
|
||||||
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
||||||
self.World.ActorMap.GetUnitsAt(self.Location + dir));
|
self.World.ActorMap.GetActorsAt(self.Location + dir));
|
||||||
|
|
||||||
adjacent = 0;
|
adjacent = 0;
|
||||||
foreach (var a in adjacentActors)
|
foreach (var a in adjacentActors)
|
||||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
static void UpdateNeighbours(Actor self)
|
static void UpdateNeighbours(Actor self)
|
||||||
{
|
{
|
||||||
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
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>())
|
.Select(a => a.TraitOrDefault<WithWallSpriteBody>())
|
||||||
.Where(a => a != null);
|
.Where(a => a != null);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.AddRange(Self.World.ActorMap.GetUnitsAt(t));
|
units.AddRange(Self.World.ActorMap.GetActorsAt(t));
|
||||||
|
|
||||||
return units.Distinct().Where(a =>
|
return units.Distinct().Where(a =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// Don't drop on any actors
|
// Don't drop on any actors
|
||||||
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(p) != null
|
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(p) != null
|
||||||
|| self.World.ActorMap.GetUnitsAt(p).Any())
|
|| self.World.ActorMap.GetActorsAt(p).Any())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type))
|
if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyUnitsAt(cell))
|
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyActorsAt(cell))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
|
if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
|
|
||||||
public static bool GetDirectHit(World world, CPos cell, WPos pos)
|
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>();
|
var healthInfo = unit.Info.TraitInfoOrDefault<HealthInfo>();
|
||||||
if (healthInfo == null)
|
if (healthInfo == null)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
if ((location - targetLocation).Length > NearEnough)
|
if ((location - targetLocation).Length > NearEnough)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var lunch = worm.World.ActorMap.GetUnitsAt(targetLocation)
|
var lunch = worm.World.ActorMap.GetActorsAt(targetLocation)
|
||||||
.Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm));
|
.Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm));
|
||||||
|
|
||||||
if (!lunch.Any())
|
if (!lunch.Any())
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
static bool ShouldLayMine(Actor self, CPos p)
|
static bool ShouldLayMine(Actor self, CPos p)
|
||||||
{
|
{
|
||||||
// If there is no unit (other than me) here, we want to place a mine here
|
// If there is no unit (other than me) here, we want to place a mine here
|
||||||
return self.World.ActorMap.GetUnitsAt(p).All(a => a == self);
|
return self.World.ActorMap.GetActorsAt(p).All(a => a == self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayMine(Actor self)
|
void LayMine(Actor self)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
mobile.FinishedMoving(self);
|
mobile.FinishedMoving(self);
|
||||||
mobile.IsMoving = false;
|
mobile.IsMoving = false;
|
||||||
|
|
||||||
self.World.ActorMap.GetUnitsAt(mobile.ToCell, mobile.ToSubCell)
|
self.World.ActorMap.GetActorsAt(mobile.ToCell, mobile.ToSubCell)
|
||||||
.Except(new[] { self }).Where(t => weapon.IsValidAgainst(t, self))
|
.Except(new[] { self }).Where(t => weapon.IsValidAgainst(t, self))
|
||||||
.Do(t => t.Kill(self));
|
.Do(t => t.Kill(self));
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var units = new HashSet<Actor>();
|
var units = new HashSet<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.UnionWith(Self.World.ActorMap.GetUnitsAt(t));
|
units.UnionWith(Self.World.ActorMap.GetActorsAt(t));
|
||||||
|
|
||||||
return units.Where(a => a.Info.HasTraitInfo<ChronoshiftableInfo>() &&
|
return units.Where(a => a.Info.HasTraitInfo<ChronoshiftableInfo>() &&
|
||||||
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
||||||
|
|||||||
Reference in New Issue
Block a user