remove VisualDest crap from bullets & combat code

This commit is contained in:
Chris Forbes
2010-04-30 12:20:22 +12:00
parent 66b1974237
commit 2d0f30a341
7 changed files with 15 additions and 18 deletions

View File

@@ -40,7 +40,7 @@ namespace OpenRA
return null; return null;
} }
public static void DoImpact(WarheadInfo warhead, ProjectileArgs args, int2 visualLocation) public static void DoImpact(WarheadInfo warhead, ProjectileArgs args)
{ {
var world = args.firedBy.World; var world = args.firedBy.World;
var targetTile = ((1f / Game.CellSize) * args.dest.ToFloat2()).ToInt2(); var targetTile = ((1f / Game.CellSize) * args.dest.ToFloat2()).ToInt2();
@@ -48,7 +48,7 @@ namespace OpenRA
if (warhead.Explosion != 0) if (warhead.Explosion != 0)
world.AddFrameEndTask( world.AddFrameEndTask(
w => w.Add(new Explosion(w, visualLocation, warhead.Explosion, isWater))); w => w.Add(new Explosion(w, args.dest, warhead.Explosion, isWater)));
Sound.Play(GetImpactSound(warhead, isWater)); Sound.Play(GetImpactSound(warhead, isWater));
@@ -92,11 +92,11 @@ namespace OpenRA
} }
} }
public static void DoImpacts(ProjectileArgs args, int2 visualLocation) public static void DoImpacts(ProjectileArgs args)
{ {
foreach (var warhead in args.weapon.Warheads) foreach (var warhead in args.weapon.Warheads)
{ {
Action a = () => DoImpact(warhead, args, visualLocation); Action a = () => DoImpact(warhead, args);
if (warhead.Delay > 0) if (warhead.Delay > 0)
args.firedBy.World.AddFrameEndTask( args.firedBy.World.AddFrameEndTask(
w => w.Add(new DelayedAction(warhead.Delay, a))); w => w.Add(new DelayedAction(warhead.Delay, a)));
@@ -119,7 +119,7 @@ namespace OpenRA
facing = 0 facing = 0
}; };
DoImpacts(args, location); DoImpacts(args);
} }
static float GetDamageToInflict(Actor target, ProjectileArgs args, WarheadInfo warhead, float modifier) static float GetDamageToInflict(Actor target, ProjectileArgs args, WarheadInfo warhead, float modifier)

View File

@@ -45,7 +45,6 @@ namespace OpenRA.Effects
{ {
readonly BulletInfo Info; readonly BulletInfo Info;
readonly ProjectileArgs Args; readonly ProjectileArgs Args;
readonly int2 VisualDest;
int t = 0; int t = 0;
Animation anim; Animation anim;
@@ -63,8 +62,6 @@ namespace OpenRA.Effects
Args.dest += (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); Args.dest += (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
} }
VisualDest = Args.dest + (10 * Game.CosmeticRandom.Gauss2D(1)).ToInt2();
if (Info.Image != null) if (Info.Image != null)
{ {
anim = new Animation(Info.Image, () => Traits.Util.GetFacing(Args.dest - Args.src, 0)); anim = new Animation(Info.Image, () => Traits.Util.GetFacing(Args.dest - Args.src, 0));
@@ -84,11 +81,11 @@ namespace OpenRA.Effects
{ {
var at = (float)t / TotalTime(); var at = (float)t / TotalTime();
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at); var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, VisualDest, at) var pos = float2.Lerp(Args.src, Args.dest, at)
- 0.5f * anim.Image.size - new float2(0, altitude); - 0.5f * anim.Image.size - new float2(0, altitude);
var highPos = (Info.High || Info.Arcing) var highPos = (Info.High || Info.Arcing)
? (pos - new float2(0, (VisualDest - Args.src).Length * height * 4 * at * (1 - at))) ? (pos - new float2(0, (Args.dest - Args.src).Length * height * 4 * at * (1 - at)))
: pos; : pos;
world.AddFrameEndTask(w => w.Add( world.AddFrameEndTask(w => w.Add(
@@ -105,7 +102,7 @@ namespace OpenRA.Effects
var at = (float)t / TotalTime(); var at = (float)t / TotalTime();
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at); var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp( Args.src, VisualDest, at) var pos = float2.Lerp( Args.src, Args.dest, at)
- 0.5f * anim.Image.size - new float2( 0, altitude ); - 0.5f * anim.Image.size - new float2( 0, altitude );
if (Info.High || Info.Arcing) if (Info.High || Info.Arcing)
@@ -113,7 +110,7 @@ namespace OpenRA.Effects
if (Info.Shadow) if (Info.Shadow)
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow"); yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow");
var highPos = pos - new float2(0, (VisualDest - Args.src).Length * height * 4 * at * (1 - at)); var highPos = pos - new float2(0, (Args.dest - Args.src).Length * height * 4 * at * (1 - at));
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette); yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette);
} }
@@ -126,7 +123,7 @@ namespace OpenRA.Effects
void Explode( World world ) void Explode( World world )
{ {
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
Combat.DoImpacts(Args, VisualDest - new int2(0, Args.destAltitude)); Combat.DoImpacts(Args);
} }
} }
} }

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Effects
if (--altitude <= Args.destAltitude) if (--altitude <= Args.destAltitude)
{ {
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
Combat.DoImpacts(Args, Args.dest); Combat.DoImpacts(Args);
} }
anim.Tick(); anim.Tick();

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Effects
if (!doneDamage) if (!doneDamage)
{ {
Combat.DoImpacts(args, args.dest); Combat.DoImpacts(args);
doneDamage = true; doneDamage = true;
} }
} }

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Effects
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
Args.dest = Pos.ToInt2(); Args.dest = Pos.ToInt2();
if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */ if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */
Combat.DoImpacts(Args, Pos.ToInt2()); Combat.DoImpacts(Args);
} }
public IEnumerable<Renderable> Render() public IEnumerable<Renderable> Render()

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Effects
if (!doneDamage) if (!doneDamage)
{ {
Combat.DoImpacts(Args, Args.dest); Combat.DoImpacts(Args);
doneDamage = true; doneDamage = true;
} }
} }

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc
firedBy = self, firedBy = self,
target = self, target = self,
weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()] weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]
}, self.CenterLocation.ToInt2()); });
poisonTicks = Rules.Weapons[info.Weapon.ToLowerInvariant()].ROF; poisonTicks = Rules.Weapons[info.Weapon.ToLowerInvariant()].ROF;
} }