Allow support powers to define a poster image for beacons.

This commit is contained in:
Paul Chote
2014-03-20 22:12:13 +13:00
parent 1f9dd53b4d
commit 94e30503a7
3 changed files with 26 additions and 5 deletions

View File

@@ -20,21 +20,30 @@ namespace OpenRA.Mods.RA.Effects
readonly Player owner; readonly Player owner;
readonly WPos position; readonly WPos position;
readonly string palettePrefix; readonly string palettePrefix;
readonly string posterPalette;
readonly Animation arrow = new Animation("beacon"); readonly Animation arrow = new Animation("beacon");
readonly Animation circles = new Animation("beacon"); readonly Animation circles = new Animation("beacon");
readonly Animation poster;
static readonly int maxArrowHeight = 512; static readonly int maxArrowHeight = 512;
int arrowHeight = maxArrowHeight; int arrowHeight = maxArrowHeight;
int arrowSpeed = 50; int arrowSpeed = 50;
public Beacon(Player owner, WPos position, int duration, string palettePrefix) public Beacon(Player owner, WPos position, int duration, string palettePrefix, string posterType, string posterPalette)
{ {
this.owner = owner; this.owner = owner;
this.position = position; this.position = position;
this.palettePrefix = palettePrefix; this.palettePrefix = palettePrefix;
this.posterPalette = posterPalette;
arrow.Play("arrow"); arrow.Play("arrow");
circles.Play("circles"); circles.Play("circles");
if (posterType != null)
{
poster = new Animation("beacon");
poster.Play(posterType);
}
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this))); owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
} }
@@ -55,10 +64,18 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer r) public IEnumerable<IRenderable> Render(WorldRenderer r)
{ {
if (!owner.IsAlliedWith(owner.World.RenderPlayer)) if (!owner.IsAlliedWith(owner.World.RenderPlayer))
return SpriteRenderable.None; yield break;
var palette = r.Palette(palettePrefix + owner.InternalName); var palette = r.Palette(palettePrefix + owner.InternalName);
return circles.Render(position, palette).Concat(arrow.Render(position + new WVec(0, 0, arrowHeight), palette)); foreach (var a in circles.Render(position, palette))
yield return a;
foreach (var a in arrow.Render(position + new WVec(0, 0, arrowHeight), palette))
yield return a;
if (poster != null)
foreach (var a in poster.Render(position, r.Palette(posterPalette)))
yield return a;
} }
} }
} }

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
if (playerBeacon != null) if (playerBeacon != null)
self.World.Remove(playerBeacon); self.World.Remove(playerBeacon);
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix); playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix, null, null);
self.World.Add(playerBeacon); self.World.Add(playerBeacon);
if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) if (self.Owner.IsAlliedWith(self.World.RenderPlayer))

View File

@@ -34,6 +34,8 @@ namespace OpenRA.Mods.RA
public readonly bool DisplayBeacon = false; public readonly bool DisplayBeacon = false;
public readonly int BeaconDuration = 10 * 25; public readonly int BeaconDuration = 10 * 25;
public readonly string BeaconPalettePrefix = "player"; public readonly string BeaconPalettePrefix = "player";
public readonly string BeaconPoster = null;
public readonly string BeaconPosterPalette = "chrome";
public readonly bool DisplayRadarPing = false; public readonly bool DisplayRadarPing = false;
public readonly string OrderName; public readonly string OrderName;
@@ -72,7 +74,9 @@ namespace OpenRA.Mods.RA
order.Player, order.Player,
order.TargetLocation.CenterPosition, order.TargetLocation.CenterPosition,
Info.BeaconDuration, Info.BeaconDuration,
Info.BeaconPalettePrefix); Info.BeaconPalettePrefix,
Info.BeaconPoster,
Info.BeaconPosterPalette);
self.World.Add(beacon); self.World.Add(beacon);
} }