Introduce World.LocalShroud. Breaks targeting stealth tanks. Probably breaks FrozenUnderFog.

This commit is contained in:
Paul Chote
2010-11-26 16:56:33 +13:00
parent 41fd19c766
commit 7c5c989eb2
25 changed files with 88 additions and 161 deletions

View File

@@ -24,7 +24,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(world.LocalPlayer));
return FindUnits(world, loc, loc).Where(a => world.LocalShroud.IsVisible(a));
}
public static IEnumerable<Actor> FindUnits(this World world, float2 a, float2 b)
@@ -72,22 +72,6 @@ namespace OpenRA
return world.TileSet.Terrain[world.GetTerrainType(cell)];
}
public static bool IsVisible(this Actor a, Player byPlayer) /* must never be relied on in synced code! */
{
if (byPlayer == null) return true; // Observer
if (a.World.LocalPlayer != null && a.World.LocalPlayer.Shroud.Disabled)
return true;
var shroud = a.World.WorldActor.Trait<Shroud>();
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, byPlayer)))
return false;
return true;
}
public static int2 ClampToWorld( this World world, int2 xy )
{
return xy.Clamp(world.Map.Bounds);