diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index b7c9af5e59..0eedfc3af1 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -35,23 +35,17 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Apply the weapon impact this many ticks into the effect")] public readonly int WeaponDelay = 7; - public readonly string Cursor = "ioncannon"; public override object Create(ActorInitializer init) { return new IonCannonPower(init.Self, this); } } class IonCannonPower : SupportPower { - public IonCannonPower(Actor self, IonCannonPowerInfo info) : base(self, info) { } + readonly IonCannonPowerInfo info; - public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) + public IonCannonPower(Actor self, IonCannonPowerInfo info) + : base(self, info) { - // Clear selection if using Left-Click Orders - if (Game.Settings.Game.UseClassicMouseStyle) - manager.Self.World.Selection.Clear(); - - Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); - var info = Info as IonCannonPowerInfo; - return new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); + this.info = info; } public override void Activate(Actor self, Order order, SupportPowerManager manager) @@ -60,7 +54,6 @@ namespace OpenRA.Mods.Cnc.Traits self.World.AddFrameEndTask(w => { - var info = Info as IonCannonPowerInfo; Sound.Play(Info.LaunchSound, self.World.Map.CenterOfCell(order.TargetLocation)); w.Add(new IonCannon(self.Owner, info.Weapon, w, order.TargetLocation, info.Effect, info.EffectPalette, info.WeaponDelay)); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index 7c0d0cc6ce..63cd0042ba 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -45,26 +45,19 @@ namespace OpenRA.Mods.Common.Traits [Desc("Amount of time after detonation to remove the camera")] public readonly int CameraRemoveDelay = 25; - public readonly string Cursor = "nuke"; - public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); } } class NukePower : SupportPower { + readonly NukePowerInfo info; IBodyOrientation body; public NukePower(Actor self, NukePowerInfo info) : base(self, info) { body = self.Trait(); - } - - public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) - { - Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); - var info = Info as NukePowerInfo; - return new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); + this.info = info; } public override void Activate(Actor self, Order order, SupportPowerManager manager) @@ -76,31 +69,30 @@ namespace OpenRA.Mods.Common.Traits else Sound.Play(Info.IncomingSound); - var npi = Info as NukePowerInfo; var rb = self.Trait(); rb.PlayCustomAnim(self, "active"); var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); - var missile = new NukeLaunch(self.Owner, npi.MissileWeapon, - self.CenterPosition + body.LocalToWorld(npi.SpawnOffset), + var missile = new NukeLaunch(self.Owner, info.MissileWeapon, + self.CenterPosition + body.LocalToWorld(info.SpawnOffset), targetPosition, - npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent); + info.FlightVelocity, info.FlightDelay, info.SkipAscent); self.World.AddFrameEndTask(w => w.Add(missile)); - if (npi.CameraActor != null) + if (info.CameraActor != null) { - var camera = self.World.CreateActor(false, npi.CameraActor, new TypeDictionary + var camera = self.World.CreateActor(false, info.CameraActor, new TypeDictionary { new LocationInit(order.TargetLocation), new OwnerInit(self.Owner), }); - camera.QueueActivity(new Wait(npi.CameraSpawnAdvance + npi.CameraRemoveDelay)); + camera.QueueActivity(new Wait(info.CameraSpawnAdvance + info.CameraRemoveDelay)); camera.QueueActivity(new RemoveSelf()); Action addCamera = () => self.World.AddFrameEndTask(w => w.Add(camera)); - self.World.AddFrameEndTask(w => w.Add(new DelayedAction(npi.FlightDelay - npi.CameraSpawnAdvance, addCamera))); + self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.FlightDelay - info.CameraSpawnAdvance, addCamera))); } if (Info.DisplayBeacon) @@ -122,7 +114,7 @@ namespace OpenRA.Mods.Common.Traits self.World.AddFrameEndTask(w => { w.Add(beacon); - w.Add(new DelayedAction(npi.FlightDelay - npi.BeaconRemoveAdvance, removeBeacon)); + w.Add(new DelayedAction(info.FlightDelay - info.BeaconRemoveAdvance, removeBeacon)); }); } } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index a1fb516512..f7eef8729f 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -22,6 +22,9 @@ namespace OpenRA.Mods.Common.Traits public readonly bool AllowMultiple = false; public readonly bool OneShot = false; + [Desc("Cursor to display for using this support power.")] + public readonly string Cursor = "ability"; + [Desc("If set to true, the support power will be fully charged when it becomes available. " + "Normal rules apply for subsequent charges.")] public readonly bool StartFullyCharged = false; @@ -56,12 +59,14 @@ namespace OpenRA.Mods.Common.Traits public class SupportPower : UpgradableTrait { public readonly Actor Self; + readonly SupportPowerInfo info; protected RadarPing ping; public SupportPower(Actor self, SupportPowerInfo info) : base(info) { Self = self; + this.info = info; } public virtual void Charging(Actor self, string key) @@ -89,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) { Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); - return new SelectGenericPowerTarget(order, manager, "ability", MouseButton.Left); + return new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); } } }