From 94e30503a73b5fa56f451f4c44fb50e51a8ef01e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 20 Mar 2014 22:12:13 +1300 Subject: [PATCH] Allow support powers to define a poster image for beacons. --- OpenRA.Mods.RA/Effects/Beacon.cs | 23 +++++++++++++++++--- OpenRA.Mods.RA/Player/PlaceBeacon.cs | 2 +- OpenRA.Mods.RA/SupportPowers/SupportPower.cs | 6 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.RA/Effects/Beacon.cs b/OpenRA.Mods.RA/Effects/Beacon.cs index 8ae5a4a4e9..90abc83f7d 100644 --- a/OpenRA.Mods.RA/Effects/Beacon.cs +++ b/OpenRA.Mods.RA/Effects/Beacon.cs @@ -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 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; } } } diff --git a/OpenRA.Mods.RA/Player/PlaceBeacon.cs b/OpenRA.Mods.RA/Player/PlaceBeacon.cs index 8e7464744f..7cc382b769 100644 --- a/OpenRA.Mods.RA/Player/PlaceBeacon.cs +++ b/OpenRA.Mods.RA/Player/PlaceBeacon.cs @@ -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)) diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs index 6817ab41de..19d17eef9f 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs @@ -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); }