Adjust IRadarSignature to support per-cell colors.
This commit is contained in:
@@ -147,12 +147,11 @@ namespace OpenRA.Graphics
|
|||||||
if (!t.Actor.IsInWorld || world.FogObscures(t.Actor))
|
if (!t.Actor.IsInWorld || world.FogObscures(t.Actor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var color = t.Trait.RadarSignatureColor(t.Actor);
|
|
||||||
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
||||||
{
|
{
|
||||||
var uv = cell.ToMPos(map);
|
var uv = cell.First.ToMPos(map);
|
||||||
if (b.Contains(uv.U, uv.V))
|
if (b.Contains(uv.U, uv.V))
|
||||||
colors[(uv.V - b.Top) * stride + uv.U - b.Left] = color.ToArgb();
|
colors[(uv.V - b.Top) * stride + uv.U - b.Left] = cell.Second.ToArgb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface IRadarSignature
|
public interface IRadarSignature
|
||||||
{
|
{
|
||||||
IEnumerable<CPos> RadarSignatureCells(Actor self);
|
IEnumerable<Pair<CPos, Color>> RadarSignatureCells(Actor self);
|
||||||
Color RadarSignatureColor(Actor self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -28,21 +29,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public AppearsOnRadar(AppearsOnRadarInfo info) { this.info = info; }
|
public AppearsOnRadar(AppearsOnRadarInfo info) { this.info = info; }
|
||||||
|
|
||||||
public IEnumerable<CPos> RadarSignatureCells(Actor self)
|
public IEnumerable<Pair<CPos, Color>> RadarSignatureCells(Actor self)
|
||||||
{
|
|
||||||
if (info.UseLocation)
|
|
||||||
return new CPos[] { self.Location };
|
|
||||||
else
|
|
||||||
return self.OccupiesSpace.OccupiedCells().Select(c => c.First);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color RadarSignatureColor(Actor self)
|
|
||||||
{
|
{
|
||||||
var mod = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
var mod = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
||||||
if (mod != null)
|
var color = mod != null ? mod.RadarColorOverride(self) : self.Owner.Color.RGB;
|
||||||
return mod.RadarColorOverride(self);
|
|
||||||
|
|
||||||
return self.Owner.Color.RGB;
|
if (info.UseLocation)
|
||||||
|
return new[] { Pair.New(self.Location, color) };
|
||||||
|
else
|
||||||
|
return self.OccupiesSpace.OccupiedCells().Select(c => Pair.New(c.First, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,13 +305,12 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
if (!t.Actor.IsInWorld || world.FogObscures(t.Actor))
|
if (!t.Actor.IsInWorld || world.FogObscures(t.Actor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var color = t.Trait.RadarSignatureColor(t.Actor);
|
|
||||||
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
||||||
{
|
{
|
||||||
var uv = cell.ToMPos(world.Map);
|
var uv = cell.First.ToMPos(world.Map);
|
||||||
|
|
||||||
if (world.Map.Bounds.Contains(uv.U, uv.V))
|
if (world.Map.Bounds.Contains(uv.U, uv.V))
|
||||||
colors[(uv.V + dy) * stride + uv.U + dx] = color.ToArgb();
|
colors[(uv.V + dy) * stride + uv.U + dx] = cell.Second.ToArgb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user