diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index a20247c541..d146541c6b 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -122,7 +122,7 @@ namespace OpenRA.Graphics foreach (var t in world.Queries.WithTraitMultiple()) { - if (!t.Actor.IsVisible()) + if (!t.Actor.IsVisible(world.LocalPlayer)) continue; var color = t.Trait.RadarSignatureColor(t.Actor); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index ca19fc01d7..833aa255fb 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -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 { diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 7f15a0e553..2bbdebe7f5 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -174,7 +174,7 @@ namespace OpenRA.Widgets IEnumerable SelectActorsInBox(World world, float2 a, float2 b) { return world.FindUnits(a, b) - .Where( x => x.HasTrait() && x.IsVisible() ) + .Where( x => x.HasTrait() && x.IsVisible(world.LocalPlayer) ) .GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get().Priority : 0) .OrderByDescending(g => g.Key) .Select( g => g.AsEnumerable() ) diff --git a/OpenRA.Game/Widgets/WorldTooltipWidget.cs b/OpenRA.Game/Widgets/WorldTooltipWidget.cs index f1a6bc535b..ccf6353dc3 100644 --- a/OpenRA.Game/Widgets/WorldTooltipWidget.cs +++ b/OpenRA.Game/Widgets/WorldTooltipWidget.cs @@ -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() diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 3c7db25eec..1cfc018262 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -40,7 +40,7 @@ namespace OpenRA public static IEnumerable 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 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().Any(t => !t.IsVisible(a))) + if (a.TraitsImplementing().Any(t => !t.IsVisible(a, byPlayer))) return false; return true; diff --git a/OpenRA.Mods.RA/InvisibleToOthers.cs b/OpenRA.Mods.RA/InvisibleToOthers.cs index b2895bdbd5..b1ccf2273a 100644 --- a/OpenRA.Mods.RA/InvisibleToOthers.cs +++ b/OpenRA.Mods.RA/InvisibleToOthers.cs @@ -18,9 +18,9 @@ namespace OpenRA.Mods.RA class InvisibleToOthers : IRenderModifier, IVisibilityModifier, IRadarColorModifier { - public bool IsVisible(Actor self) + public bool IsVisible(Actor self, Player byPlayer) { - return self.Owner == self.World.LocalPlayer; + return self.Owner == byPlayer; } public Color RadarColorOverride(Actor self) diff --git a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs index c74bce105f..026eee64da 100644 --- a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs @@ -29,17 +29,17 @@ namespace OpenRA.Mods.RA shroud = self.World.WorldActor.Trait(); } - public bool IsVisible(Actor self) + public bool IsVisible(Actor self, Player byPlayer) { return self.World.LocalPlayer == null - || self.Owner == self.World.LocalPlayer + || self.Owner == byPlayer || self.World.LocalPlayer.Shroud.Disabled || Shroud.GetVisOrigins(self).Any(o => self.World.Map.IsInMap(o) && shroud.visibleCells[o.X, o.Y] != 0); } public IEnumerable ModifyRender(Actor self, IEnumerable r) { - if (IsVisible(self)) + if (IsVisible(self, self.World.LocalPlayer)) cache = r.ToArray(); return cache; diff --git a/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs b/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs index e99f929a91..f43751d565 100644 --- a/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs +++ b/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs @@ -27,10 +27,10 @@ namespace OpenRA.Mods.RA shroud = self.World.WorldActor.Trait(); } - public bool IsVisible(Actor self) + public bool IsVisible(Actor self, Player byPlayer) { return self.World.LocalPlayer == null - || self.Owner == self.World.LocalPlayer + || self.Owner == byPlayer || self.World.LocalPlayer.Shroud.Disabled || shroud.visibleCells[self.Location.X, self.Location.Y] > 0; } @@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA static Renderable[] Nothing = { }; public IEnumerable ModifyRender(Actor self, IEnumerable r) { - return IsVisible(self) ? r : Nothing; + return IsVisible(self, self.World.LocalPlayer) ? r : Nothing; } } }