Tweak visibility; hopefully allows targeting of detected units
This commit is contained in:
@@ -122,7 +122,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
foreach (var t in world.Queries.WithTraitMultiple<IRadarSignature>())
|
||||
{
|
||||
if (!t.Actor.IsVisible())
|
||||
if (!t.Actor.IsVisible(world.LocalPlayer))
|
||||
continue;
|
||||
|
||||
var color = t.Trait.RadarSignatureColor(t.Actor);
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Traits
|
||||
Color RadarSignatureColor(Actor self);
|
||||
}
|
||||
|
||||
public interface IVisibilityModifier { bool IsVisible(Actor self); }
|
||||
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
||||
public interface IOccupySpace
|
||||
{
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace OpenRA.Widgets
|
||||
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
|
||||
{
|
||||
return world.FindUnits(a, b)
|
||||
.Where( x => x.HasTrait<Selectable>() && x.IsVisible() )
|
||||
.Where( x => x.HasTrait<Selectable>() && x.IsVisible(world.LocalPlayer) )
|
||||
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
|
||||
.OrderByDescending(g => g.Key)
|
||||
.Select( g => g.AsEnumerable() )
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault();
|
||||
if (actor == null || !actor.IsVisible())
|
||||
if (actor == null || !actor.IsVisible(world.LocalPlayer))
|
||||
return;
|
||||
|
||||
var text = actor.Info.Traits.Contains<ValuedInfo>()
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA
|
||||
public static IEnumerable<Actor> FindUnitsAtMouse(this World world, int2 mouseLocation)
|
||||
{
|
||||
var loc = mouseLocation + Game.viewport.Location;
|
||||
return FindUnits(world, loc, loc).Where(a => a.IsVisible());
|
||||
return FindUnits(world, loc, loc).Where(a => a.IsVisible(world.LocalPlayer));
|
||||
}
|
||||
|
||||
public static IEnumerable<Actor> FindUnits(this World world, float2 a, float2 b)
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA
|
||||
world.IsCellBuildable(t, building.WaterBound, toIgnore));
|
||||
}
|
||||
|
||||
public static bool IsVisible(this Actor a) /* must never be relied on in synced code! */
|
||||
public static bool IsVisible(this Actor a, Player byPlayer) /* must never be relied on in synced code! */
|
||||
{
|
||||
if (a.World.LocalPlayer != null && a.World.LocalPlayer.Shroud.Disabled)
|
||||
return true;
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA
|
||||
if (!Shroud.GetVisOrigins(a).Any(o => a.World.Map.IsInMap(o) && shroud.exploredCells[o.X, o.Y])) // covered by shroud
|
||||
return false;
|
||||
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a)))
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, byPlayer)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user