Radar takes into account visibility under fog
This commit is contained in:
@@ -164,14 +164,17 @@ namespace OpenRA.Traits
|
||||
|
||||
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
||||
{
|
||||
foreach (var mod in self.World.Queries.WithTraitMultiple<IRadarVisibilityModifier>())
|
||||
if (!mod.Trait.VisibleOnRadar(self))
|
||||
return new int2[] {};
|
||||
|
||||
return Footprint.Tiles(self);
|
||||
}
|
||||
|
||||
public Color RadarSignatureColor(Actor self)
|
||||
{
|
||||
var mod = self.traits.WithInterface<IRadarSignatureModifier>().FirstOrDefault();
|
||||
if (mod != null)
|
||||
return mod.RadarColorOverride(self);
|
||||
foreach (var mod in self.World.Queries.WithTraitMultiple<IRadarColorModifier>())
|
||||
return mod.Trait.RadarColorOverride(self);
|
||||
|
||||
return self.Owner.Color;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
||||
public object Create(ActorInitializer init) { return new FrozenUnderFog(init.self); }
|
||||
}
|
||||
|
||||
class FrozenUnderFog : IRenderModifier
|
||||
class FrozenUnderFog : IRenderModifier, IRadarVisibilityModifier
|
||||
{
|
||||
Shroud shroud;
|
||||
Renderable[] cache = { };
|
||||
@@ -35,6 +35,11 @@ namespace OpenRA.Traits
|
||||
|| self.World.LocalPlayer.Shroud.Disabled
|
||||
|| Shroud.GetVisOrigins(self).Any(o => self.World.Map.IsInMap(o) && shroud.visibleCells[o.X, o.Y] != 0);
|
||||
}
|
||||
|
||||
public bool VisibleOnRadar(Actor self)
|
||||
{
|
||||
return IsVisible(self);
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Traits
|
||||
public object Create(ActorInitializer init) { return new HiddenUnderFog(init.self); }
|
||||
}
|
||||
|
||||
class HiddenUnderFog : IRenderModifier
|
||||
class HiddenUnderFog : IRenderModifier, IRadarVisibilityModifier
|
||||
{
|
||||
Shroud shroud;
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace OpenRA.Traits
|
||||
|| self.World.LocalPlayer.Shroud.Disabled
|
||||
|| shroud.visibleCells[self.Location.X, self.Location.Y] > 0;
|
||||
}
|
||||
|
||||
public bool VisibleOnRadar(Actor self)
|
||||
{
|
||||
return IsVisible(self);
|
||||
}
|
||||
|
||||
static Renderable[] Nothing = { };
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
|
||||
@@ -61,10 +61,8 @@ namespace OpenRA.Traits
|
||||
Color RadarSignatureColor(Actor self);
|
||||
}
|
||||
|
||||
public interface IRadarSignatureModifier
|
||||
{
|
||||
Color RadarColorOverride(Actor self);
|
||||
}
|
||||
public interface IRadarVisibilityModifier { bool VisibleOnRadar(Actor self); }
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
||||
|
||||
public interface IOccupySpace
|
||||
{
|
||||
|
||||
@@ -39,14 +39,17 @@ namespace OpenRA.Traits
|
||||
|
||||
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
||||
{
|
||||
foreach (var mod in self.World.Queries.WithTraitMultiple<IRadarVisibilityModifier>())
|
||||
if (!mod.Trait.VisibleOnRadar(self))
|
||||
yield break;
|
||||
|
||||
yield return self.Location;
|
||||
}
|
||||
|
||||
public Color RadarSignatureColor(Actor self)
|
||||
{
|
||||
var mod = self.traits.WithInterface<IRadarSignatureModifier>().FirstOrDefault();
|
||||
if (mod != null)
|
||||
return mod.RadarColorOverride(self);
|
||||
foreach (var mod in self.World.Queries.WithTraitMultiple<IRadarColorModifier>())
|
||||
return mod.Trait.RadarColorOverride(self);
|
||||
|
||||
return self.Owner.Color;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Traits
|
||||
public object Create( ActorInitializer init ) { return new RadarColorFromTerrain(init.self,Terrain); }
|
||||
}
|
||||
|
||||
public class RadarColorFromTerrain : IRadarSignatureModifier
|
||||
public class RadarColorFromTerrain : IRadarColorModifier
|
||||
{
|
||||
Color c;
|
||||
public RadarColorFromTerrain(Actor self, string terrain)
|
||||
@@ -29,6 +29,7 @@ namespace OpenRA.Traits
|
||||
c = self.World.TileSet.Terrain[terrain].Color;
|
||||
}
|
||||
|
||||
public bool VisibleOnRadar(Actor self) { return true; }
|
||||
public Color RadarColorOverride(Actor self)
|
||||
{
|
||||
return c;
|
||||
|
||||
Reference in New Issue
Block a user