From 338fb38bd3ab39d7bdd90bedb6b11f9251059d29 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Sat, 22 Feb 2014 00:00:15 +1300 Subject: [PATCH] Add beacon/radar ping placements for nukes/ion cannons/chronospheres/iron curtains. --- OpenRA.Mods.RA/SupportPowers/SupportPower.cs | 5 ++++ .../SupportPowers/SupportPowerManager.cs | 27 ++++++++++++++++--- mods/cnc/rules/structures.yaml | 4 +++ mods/d2k/rules/harkonnen.yaml | 2 ++ mods/ra/rules/structures.yaml | 4 +++ 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs index da5deaae1d..f55b13c043 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs @@ -30,6 +30,11 @@ namespace OpenRA.Mods.RA public readonly bool DisplayTimer = false; + public readonly bool DisplayBeacon = false; + public readonly int BeaconDuration = 10 * 25; + public readonly string BeaconPalettePrefix = "player"; + public readonly bool DisplayRadarPing = false; + public readonly string OrderName; public abstract object Create(ActorInitializer init); diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs index 2e3437e499..9a09541944 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs @@ -10,7 +10,9 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.FileFormats; using OpenRA.Graphics; +using OpenRA.Mods.RA.Effects; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -23,13 +25,16 @@ namespace OpenRA.Mods.RA public class SupportPowerManager : ITick, IResolveOrder { public readonly Actor self; - public Dictionary Powers = new Dictionary(); + public readonly Dictionary Powers = new Dictionary(); + + public readonly DeveloperMode DevMode; + public readonly Lazy RadarPings; - public readonly DeveloperMode devMode; public SupportPowerManager(ActorInitializer init) { self = init.self; - devMode = init.self.Trait(); + DevMode = init.self.Trait(); + RadarPings = Lazy.New(() => init.world.WorldActor.TraitOrDefault()); init.world.ActorAdded += ActorAdded; init.world.ActorRemoved += ActorRemoved; @@ -148,7 +153,7 @@ namespace OpenRA.Mods.RA if (Active) { var power = Instances.First(); - if (Manager.devMode.FastCharge && RemainingTime > 25) + if (Manager.DevMode.FastCharge && RemainingTime > 25) RemainingTime = 25; if (RemainingTime > 0) --RemainingTime; @@ -187,6 +192,20 @@ namespace OpenRA.Mods.RA RemainingTime = TotalTime; notifiedCharging = notifiedReady = false; + if (power.Info.DisplayBeacon) + power.self.World.Add(new Beacon( + order.Player, + order.TargetLocation.CenterPosition, + power.Info.BeaconDuration, + power.Info.BeaconPalettePrefix)); + + if (power.Info.DisplayRadarPing && Manager.RadarPings != null) + Manager.RadarPings.Value.Add( + () => order.Player.IsAlliedWith(power.self.World.RenderPlayer), + order.TargetLocation.CenterPosition, + order.Player.Color.RGB, + power.Info.BeaconDuration); + if (Info.OneShot) Disabled = true; } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 0df2bee7b7..56289c78eb 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -445,6 +445,8 @@ EYE: LaunchSound: ion1.aud SelectTargetSound: select1.aud InsufficientPowerSound: nopower1.aud + DisplayBeacon: True + DisplayRadarPing: True SupportPowerChargeBar: TMPL: @@ -483,6 +485,8 @@ TMPL: LaunchSound: nuklnch1.aud IncomingSound: nuke1.aud MissileWeapon: atomic + DisplayBeacon: True + DisplayRadarPing: True SupportPowerChargeBar: GUN: diff --git a/mods/d2k/rules/harkonnen.yaml b/mods/d2k/rules/harkonnen.yaml index 7b95b5c44d..507055f77d 100644 --- a/mods/d2k/rules/harkonnen.yaml +++ b/mods/d2k/rules/harkonnen.yaml @@ -96,6 +96,8 @@ PALACEH: IncomingSound: MissileWeapon: atomic SpawnOffset: -512,1c171,0 + DisplayBeacon: True + DisplayRadarPing: True CanPowerDown: RequiresPower: SupportPowerChargeBar: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 5825d961d1..50e94cbd72 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -37,6 +37,8 @@ MSLO: MissileWeapon: atomic SpawnOffset: 0,427,0 DisplayTimer: True + DisplayBeacon: True + DisplayRadarPing: True CanPowerDown: RequiresPower: SupportPowerChargeBar: @@ -224,6 +226,7 @@ IRON: InsufficientPowerSound: nopowr1.aud BeginChargeSound: ironchg1.aud EndChargeSound: ironrdy1.aud + DisplayRadarPing: True SupportPowerChargeBar: PDOX: @@ -264,6 +267,7 @@ PDOX: EndChargeSound: chrordy1.aud Duration: 20 KillCargo: yes + DisplayRadarPing: True SupportPowerChargeBar: -AcceptsSupplies: