#37 enemy actors can be selected under shroud
This commit is contained in:
@@ -84,7 +84,7 @@ namespace OpenRA.Traits
|
|||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static IEnumerable<int2> GetVisOrigins(Actor a)
|
public static IEnumerable<int2> GetVisOrigins(Actor a)
|
||||||
{
|
{
|
||||||
if (a.Info.Traits.Contains<BuildingInfo>())
|
if (a.Info.Traits.Contains<BuildingInfo>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace OpenRA
|
|||||||
public static IEnumerable<Actor> SelectActorsInBox(this World world, float2 a, float2 b)
|
public static IEnumerable<Actor> SelectActorsInBox(this World world, float2 a, float2 b)
|
||||||
{
|
{
|
||||||
return world.FindUnits(a, 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)
|
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
|
||||||
.OrderByDescending(g => g.Key)
|
.OrderByDescending(g => g.Key)
|
||||||
.Select( g => g.AsEnumerable() )
|
.Select( g => g.AsEnumerable() )
|
||||||
@@ -138,6 +138,14 @@ namespace OpenRA
|
|||||||
building.WaterBound, toIgnore));
|
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)
|
public static bool IsCloseEnoughToBase(this World world, Player p, string buildingName, BuildingInfo bi, int2 topLeft)
|
||||||
{
|
{
|
||||||
var buildingMaxBounds = bi.Dimensions;
|
var buildingMaxBounds = bi.Dimensions;
|
||||||
|
|||||||
Reference in New Issue
Block a user