Move Cursor field to SupportPower.
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -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<IBodyOrientation>();
|
||||
}
|
||||
|
||||
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<RenderSimple>();
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SupportPowerInfo>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user