Convert ProjectileArgs to world coords.

This commit is contained in:
Paul Chote
2013-07-07 17:30:06 +12:00
parent 6d52af4553
commit df46ffeb84
9 changed files with 134 additions and 150 deletions

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
@@ -25,13 +25,16 @@ namespace OpenRA.Mods.RA.Effects
public class GravityBomb : IEffect
{
Animation anim;
int altitude;
int2 dest;
int altitude, destAltitude;
ProjectileArgs Args;
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
{
Args = args;
altitude = args.srcAltitude;
altitude = args.source.Z * Game.CellSize / 1024;
destAltitude = args.passiveTarget.Z * Game.CellSize / 1024;
dest = PPos.FromWPos(args.passiveTarget).ToInt2();
anim = new Animation(info.Image);
if (anim.HasSequence("open"))
@@ -42,10 +45,10 @@ namespace OpenRA.Mods.RA.Effects
public void Tick(World world)
{
if (--altitude <= Args.destAltitude)
if (--altitude <= destAltitude)
{
world.AddFrameEndTask(w => w.Remove(this));
Combat.DoImpacts(Args);
Combat.DoImpacts(Args.passiveTarget, Args.sourceActor, Args.weapon, Args.firepowerModifier);
}
anim.Tick();
@@ -53,8 +56,8 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
var pos = Args.dest.ToInt2() - new int2(0, altitude) - .5f * anim.Image.size;
yield return new SpriteRenderable(anim.Image, pos, wr.Palette("effect"), Args.dest.Y);
var pos = dest - new int2(0, altitude) - .5f * anim.Image.size;
yield return new SpriteRenderable(anim.Image, pos, wr.Palette("effect"), dest.Y);
}
}
}