Refactor per-player shrouds & fix shellmap shroud.
This commit is contained in:
@@ -54,7 +54,8 @@ namespace OpenRA.Traits
|
||||
|
||||
void DrawPips(WorldRenderer wr, Actor self, float2 basePosition)
|
||||
{
|
||||
if (self.Owner != self.World.RenderedPlayer) return;
|
||||
if (self.Owner != self.World.RenderPlayer)
|
||||
return;
|
||||
|
||||
var pipSources = self.TraitsImplementing<IPips>();
|
||||
if (pipSources.Count() == 0)
|
||||
@@ -95,7 +96,8 @@ namespace OpenRA.Traits
|
||||
|
||||
void DrawTags(WorldRenderer wr, Actor self, float2 basePosition)
|
||||
{
|
||||
if (self.Owner != self.World.RenderedPlayer) return;
|
||||
if (self.Owner != self.World.RenderPlayer)
|
||||
return;
|
||||
|
||||
// If a mod wants to implement a unit with multiple tags, then they are placed on multiple rows
|
||||
var tagxyBase = basePosition + new float2(-16, 2); // Correct for the offset in the shp file
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Traits
|
||||
Color RadarSignatureColor(Actor self);
|
||||
}
|
||||
|
||||
public interface IVisibilityModifier { bool IsVisible(Shroud s, Actor self); }
|
||||
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
||||
public interface IHasLocation { PPos PxPosition { get; } }
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Traits
|
||||
for (int x = clip.Left; x < clip.Right; x++)
|
||||
for (int y = clip.Top; y < clip.Bottom; y++)
|
||||
{
|
||||
if (!world.RenderedShroud.IsExplored(new CPos(x, y)))
|
||||
if (world.ShroudObscures(new CPos(x, y)))
|
||||
continue;
|
||||
|
||||
var c = content[x, y];
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace OpenRA.Traits
|
||||
public class Shroud : ISync
|
||||
{
|
||||
Map map;
|
||||
World world;
|
||||
|
||||
[Sync] public Player Owner;
|
||||
public int[,] visibleCells;
|
||||
@@ -38,11 +37,6 @@ namespace OpenRA.Traits
|
||||
set { disabled = value; Dirty(); }
|
||||
}
|
||||
|
||||
public bool Observing
|
||||
{
|
||||
get { return world.IsShellmap || (world.LocalPlayer == null && Owner == null);; }
|
||||
}
|
||||
|
||||
public Rectangle? Bounds
|
||||
{
|
||||
get { return Disabled ? null : exploredBounds; }
|
||||
@@ -52,7 +46,6 @@ namespace OpenRA.Traits
|
||||
|
||||
public Shroud(World world)
|
||||
{
|
||||
this.world = world;
|
||||
map = world.Map;
|
||||
visibleCells = new int[map.MapSize.X, map.MapSize.Y];
|
||||
exploredCells = new bool[map.MapSize.X, map.MapSize.Y];
|
||||
@@ -274,16 +267,24 @@ namespace OpenRA.Traits
|
||||
if (!map.IsInMap(x, y))
|
||||
return false;
|
||||
|
||||
if (Disabled || Observing)
|
||||
if (Disabled)
|
||||
return true;
|
||||
|
||||
return foggedCells[x,y];
|
||||
}
|
||||
|
||||
public bool IsExplored(Actor a)
|
||||
{
|
||||
if (Owner == null)
|
||||
return true;
|
||||
|
||||
return GetVisOrigins(a).Any(o => IsExplored(o));
|
||||
}
|
||||
|
||||
public bool IsVisible(CPos xy) { return IsVisible(xy.X, xy.Y); }
|
||||
public bool IsVisible(int x, int y)
|
||||
{
|
||||
if (Disabled || Observing)
|
||||
if (Disabled)
|
||||
return true;
|
||||
|
||||
// Visibility is allowed to extend beyond the map cordon so that
|
||||
@@ -298,16 +299,14 @@ namespace OpenRA.Traits
|
||||
public bool IsVisible(Actor a)
|
||||
{
|
||||
// I need to pass in the current shroud, otherwise we're just checking that true==true
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(this, a)))
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, Owner)))
|
||||
return false;
|
||||
|
||||
if(Owner == null) return true;
|
||||
|
||||
return Disabled || Observing || a.Owner.Stances[Owner] == Stance.Ally || GetVisOrigins(a).Any(o => IsExplored(o));
|
||||
return Disabled || a.Owner.Stances[Owner] == Stance.Ally || IsExplored(a);
|
||||
}
|
||||
|
||||
public bool IsTargetable(Actor a) {
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(this, a)))
|
||||
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, Owner)))
|
||||
return false;
|
||||
|
||||
return GetVisOrigins(a).Any(o => IsVisible(o));
|
||||
|
||||
Reference in New Issue
Block a user