#394 nuke without a launch site crashes -- fixed

This commit is contained in:
Chris Forbes
2011-01-01 21:52:43 +13:00
parent a4bbce32b8
commit 7b5a8cf089
2 changed files with 13 additions and 11 deletions

View File

@@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA.Effects
{ {
public class NukeLaunch : IEffect public class NukeLaunch : IEffect
{ {
readonly Player firedBy;
readonly Actor silo; readonly Actor silo;
Animation anim; Animation anim;
float2 pos; float2 pos;
@@ -25,8 +26,9 @@ namespace OpenRA.Mods.RA.Effects
bool goingUp = true; bool goingUp = true;
string weapon; string weapon;
public NukeLaunch(Actor silo, string weapon, int2 spawnOffset, int2 targetLocation) public NukeLaunch(Player firedBy, Actor silo, string weapon, int2 spawnOffset, int2 targetLocation)
{ {
this.firedBy = firedBy;
this.silo = silo; this.silo = silo;
this.targetLocation = targetLocation; this.targetLocation = targetLocation;
this.weapon = weapon; this.weapon = weapon;
@@ -35,8 +37,8 @@ namespace OpenRA.Mods.RA.Effects
if (silo == null) if (silo == null)
{ {
altitude = silo.World.Map.Bounds.Height*Game.CellSize; altitude = firedBy.World.Map.Bounds.Height*Game.CellSize;
StartDescent(silo.World); StartDescent(firedBy.World);
} }
else else
pos = silo.CenterLocation + spawnOffset; pos = silo.CenterLocation + spawnOffset;
@@ -76,13 +78,14 @@ 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(silo.Owner.PlayerActor, weapon, pos, 0); Combat.DoExplosion(firedBy.PlayerActor, weapon, pos, 0);
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5); world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
} }
public IEnumerable<Renderable> Render() public IEnumerable<Renderable> Render()
{ {
yield return new Renderable(anim.Image, pos - 0.5f * anim.Image.size - new float2(0, altitude), "effect", (int)pos.Y); yield return new Renderable(anim.Image, pos - 0.5f * anim.Image.size - new float2(0, altitude),
"effect", (int)pos.Y);
} }
} }
} }

View File

@@ -8,10 +8,8 @@
*/ */
#endregion #endregion
using System.Linq;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Render; using OpenRA.Mods.RA.Render;
using OpenRA.Orders;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
@@ -40,11 +38,12 @@ namespace OpenRA.Mods.RA
if (self.Owner != self.World.LocalPlayer) if (self.Owner != self.World.LocalPlayer)
Sound.Play(Info.LaunchSound); Sound.Play(Info.LaunchSound);
var npi = Info as NukePowerInfo;
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active"); self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w => w.Add(
{ new NukeLaunch(self.Owner, self, npi.MissileWeapon, npi.SpawnOffset,
w.Add(new NukeLaunch(self, (Info as NukePowerInfo).MissileWeapon, (Info as NukePowerInfo).SpawnOffset, order.TargetLocation)); order.TargetLocation)));
});
} }
} }
} }