Fix visibility queries when fog is disabled.

This commit is contained in:
Paul Chote
2015-08-14 19:26:01 +01:00
parent 9dabf9019f
commit 738a500876
2 changed files with 15 additions and 1 deletions

View File

@@ -60,13 +60,23 @@ namespace OpenRA.Mods.Common.Traits
visible = init.World.Players.ToDictionary(p => p, p => false); visible = init.World.Players.ToDictionary(p => p, p => false);
} }
bool IsVisibleInner(Actor self, Player byPlayer)
{
// If fog is disabled visibility is determined by shroud
if (!byPlayer.Shroud.FogEnabled)
return self.OccupiesSpace.OccupiedCells()
.Any(o => byPlayer.Shroud.IsExplored(o.First));
return visible[byPlayer];
}
public bool IsVisible(Actor self, Player byPlayer) public bool IsVisible(Actor self, Player byPlayer)
{ {
if (byPlayer == null) if (byPlayer == null)
return true; return true;
var stance = self.Owner.Stances[byPlayer]; var stance = self.Owner.Stances[byPlayer];
return info.AlwaysVisibleStances.HasStance(stance) || visible[byPlayer]; return info.AlwaysVisibleStances.HasStance(stance) || IsVisibleInner(self, byPlayer);
} }
public void Tick(Actor self) public void Tick(Actor self)

View File

@@ -28,6 +28,10 @@ namespace OpenRA.Mods.Common.Traits
protected override bool IsVisibleInner(Actor self, Player byPlayer) protected override bool IsVisibleInner(Actor self, Player byPlayer)
{ {
// If fog is disabled visibility is determined by shroud
if (!byPlayer.Shroud.FogEnabled)
return base.IsVisibleInner(self, byPlayer);
if (Info.Type == VisibilityType.Footprint) if (Info.Type == VisibilityType.Footprint)
return self.OccupiesSpace.OccupiedCells() return self.OccupiesSpace.OccupiedCells()
.Any(o => byPlayer.Shroud.IsVisible(o.First)); .Any(o => byPlayer.Shroud.IsVisible(o.First));