Merge pull request #5329 from reaperrr/nuke-ion-fix

Closes #5239
This commit is contained in:
Matthias Mailänder
2014-05-16 20:35:41 +02:00
4 changed files with 19 additions and 11 deletions

View File

@@ -20,13 +20,17 @@ namespace OpenRA.Mods.Cnc.Effects
{ {
Target target; Target target;
Animation anim; Animation anim;
Actor firedBy; Player firedBy;
string palette;
string weapon;
public IonCannon(Actor firedBy, World world, CPos location) public IonCannon(Player firedBy, string weapon, World world, CPos location, string effect, string palette)
{ {
this.firedBy = firedBy; this.firedBy = firedBy;
this.weapon = weapon;
this.palette = palette;
target = Target.FromCell(location); target = Target.FromCell(location);
anim = new Animation("ionsfx"); anim = new Animation(effect);
anim.PlayThen("idle", () => Finish(world)); anim.PlayThen("idle", () => Finish(world));
} }
@@ -34,13 +38,13 @@ namespace OpenRA.Mods.Cnc.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr) public IEnumerable<IRenderable> Render(WorldRenderer wr)
{ {
return anim.Render(target.CenterPosition, wr.Palette("effect")); return anim.Render(target.CenterPosition, wr.Palette(palette));
} }
void Finish(World world) void Finish(World world)
{ {
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
Combat.DoExplosion(firedBy, "IonCannon", target.CenterPosition); Combat.DoExplosion(firedBy.PlayerActor, weapon, target.CenterPosition);
} }
} }
} }

View File

@@ -21,9 +21,13 @@ namespace OpenRA.Mods.Cnc
[ActorReference] [ActorReference]
[Desc("Actor to spawn when the attack starts")] [Desc("Actor to spawn when the attack starts")]
public readonly string CameraActor = null; public readonly string CameraActor = null;
[Desc("Amount of time to keep the camera alive")] [Desc("Amount of time to keep the camera alive")]
public readonly int CameraRemoveDelay = 25; public readonly int CameraRemoveDelay = 25;
[Desc("Effect sequence to display")]
public readonly string Effect = "ionsfx";
public readonly string EffectPalette = "effect";
[Desc("Which weapon to fire")]
public readonly string Weapon = "IonCannon";
public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); } public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); }
} }
@@ -46,7 +50,7 @@ namespace OpenRA.Mods.Cnc
{ {
var info = Info as IonCannonPowerInfo; var info = Info as IonCannonPowerInfo;
Sound.Play(Info.LaunchSound, order.TargetLocation.CenterPosition); Sound.Play(Info.LaunchSound, order.TargetLocation.CenterPosition);
w.Add(new IonCannon(self, w, order.TargetLocation)); w.Add(new IonCannon(self.Owner, info.Weapon, w, order.TargetLocation, info.Effect, info.EffectPalette));
if (info.CameraActor == null) if (info.CameraActor == null)
return; return;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Effects
{ {
public class NukeLaunch : IEffect public class NukeLaunch : IEffect
{ {
readonly Actor firedBy; readonly Player firedBy;
readonly Animation anim; readonly Animation anim;
readonly string weapon; readonly string weapon;
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Effects
WPos pos; WPos pos;
int ticks; int ticks;
public NukeLaunch(Actor firedBy, string weapon, WPos launchPos, WPos targetPos, WRange velocity, int delay, bool skipAscent) public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WRange velocity, int delay, bool skipAscent)
{ {
this.firedBy = firedBy; this.firedBy = firedBy;
this.weapon = weapon; this.weapon = weapon;
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.RA.Effects
void Explode(World world) void Explode(World world)
{ {
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
Combat.DoExplosion(firedBy, weapon, pos); Combat.DoExplosion(firedBy.PlayerActor, weapon, pos);
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5); world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
foreach (var a in world.ActorsWithTrait<NukePaletteEffect>()) foreach (var a in world.ActorsWithTrait<NukePaletteEffect>())

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA
var rb = self.Trait<RenderSimple>(); var rb = self.Trait<RenderSimple>();
rb.PlayCustomAnim(self, "active"); rb.PlayCustomAnim(self, "active");
self.World.AddFrameEndTask(w => w.Add(new NukeLaunch(self, npi.MissileWeapon, self.World.AddFrameEndTask(w => w.Add(new NukeLaunch(self.Owner, npi.MissileWeapon,
self.CenterPosition + body.LocalToWorld(npi.SpawnOffset), self.CenterPosition + body.LocalToWorld(npi.SpawnOffset),
order.TargetLocation.CenterPosition, order.TargetLocation.CenterPosition,
npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent))); npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent)));