#37 enemy actors can be selected under shroud

This commit is contained in:
Chris Forbes
2010-03-30 19:07:12 +13:00
parent d211056082
commit 20c4d3ef61
2 changed files with 10 additions and 2 deletions

View File

@@ -117,7 +117,7 @@ namespace OpenRA
public static IEnumerable<Actor> SelectActorsInBox(this World world, float2 a, float2 b)
{
return world.FindUnits(a, b)
.Where( x => x.traits.Contains<Selectable>() )
.Where( x => x.traits.Contains<Selectable>() && x.IsVisible() )
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
.OrderByDescending(g => g.Key)
.Select( g => g.AsEnumerable() )
@@ -138,6 +138,14 @@ namespace OpenRA
building.WaterBound, toIgnore));
}
public static bool IsVisible(this Actor a)
{
var shroud = a.World.WorldActor.traits.Get<Shroud>();
return a.traits.Contains<Unit>()
? Shroud.GetVisOrigins(a).Any(o => shroud.visibleCells[o.X, o.Y] > 0)
: Shroud.GetVisOrigins(a).Any(o => shroud.exploredCells[o.X, o.Y]);
}
public static bool IsCloseEnoughToBase(this World world, Player p, string buildingName, BuildingInfo bi, int2 topLeft)
{
var buildingMaxBounds = bi.Dimensions;