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 WPos position;
readonly string palettePrefix;
readonly string posterPalette;
readonly Animation arrow = new Animation("beacon");
readonly Animation circles = new Animation("beacon");
readonly Animation poster;
static readonly int maxArrowHeight = 512;
int arrowHeight = maxArrowHeight;
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.position = position;
this.palettePrefix = palettePrefix;
this.posterPalette = posterPalette;
arrow.Play("arrow");
circles.Play("circles");
if (posterType != null)
{
poster = new Animation("beacon");
poster.Play(posterType);
}
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)
{
if (!owner.IsAlliedWith(owner.World.RenderPlayer))
return SpriteRenderable.None;
yield break;
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)
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);
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))

View File

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