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