From 2d0f30a3413c230d3ed7f0993a94740ae29a7a74 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 30 Apr 2010 12:20:22 +1200 Subject: [PATCH] remove VisualDest crap from bullets & combat code --- OpenRA.Game/Combat.cs | 10 +++++----- OpenRA.Game/Effects/Bullet.cs | 13 +++++-------- OpenRA.Game/Effects/GravityBomb.cs | 2 +- OpenRA.Game/Effects/LaserZap.cs | 2 +- OpenRA.Game/Effects/Missile.cs | 2 +- OpenRA.Game/Effects/TeslaZap.cs | 2 +- OpenRA.Mods.Cnc/PoisonedByTiberium.cs | 2 +- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 612d79c2d7..5858659930 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -40,7 +40,7 @@ namespace OpenRA 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 targetTile = ((1f / Game.CellSize) * args.dest.ToFloat2()).ToInt2(); @@ -48,7 +48,7 @@ namespace OpenRA if (warhead.Explosion != 0) 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)); @@ -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) { - Action a = () => DoImpact(warhead, args, visualLocation); + Action a = () => DoImpact(warhead, args); if (warhead.Delay > 0) args.firedBy.World.AddFrameEndTask( w => w.Add(new DelayedAction(warhead.Delay, a))); @@ -119,7 +119,7 @@ namespace OpenRA facing = 0 }; - DoImpacts(args, location); + DoImpacts(args); } static float GetDamageToInflict(Actor target, ProjectileArgs args, WarheadInfo warhead, float modifier) diff --git a/OpenRA.Game/Effects/Bullet.cs b/OpenRA.Game/Effects/Bullet.cs index 74274a8ce0..f6ba8a2df0 100755 --- a/OpenRA.Game/Effects/Bullet.cs +++ b/OpenRA.Game/Effects/Bullet.cs @@ -45,7 +45,6 @@ namespace OpenRA.Effects { readonly BulletInfo Info; readonly ProjectileArgs Args; - readonly int2 VisualDest; int t = 0; Animation anim; @@ -63,8 +62,6 @@ namespace OpenRA.Effects 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) { 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 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); 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; world.AddFrameEndTask(w => w.Add( @@ -105,7 +102,7 @@ namespace OpenRA.Effects var at = (float)t / TotalTime(); 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 ); if (Info.High || Info.Arcing) @@ -113,7 +110,7 @@ namespace OpenRA.Effects if (Info.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); } @@ -126,7 +123,7 @@ namespace OpenRA.Effects void Explode( World world ) { world.AddFrameEndTask(w => w.Remove(this)); - Combat.DoImpacts(Args, VisualDest - new int2(0, Args.destAltitude)); + Combat.DoImpacts(Args); } } } diff --git a/OpenRA.Game/Effects/GravityBomb.cs b/OpenRA.Game/Effects/GravityBomb.cs index 959e67a5c3..e8f448bbc6 100644 --- a/OpenRA.Game/Effects/GravityBomb.cs +++ b/OpenRA.Game/Effects/GravityBomb.cs @@ -54,7 +54,7 @@ namespace OpenRA.Effects if (--altitude <= Args.destAltitude) { world.AddFrameEndTask(w => w.Remove(this)); - Combat.DoImpacts(Args, Args.dest); + Combat.DoImpacts(Args); } anim.Tick(); diff --git a/OpenRA.Game/Effects/LaserZap.cs b/OpenRA.Game/Effects/LaserZap.cs index 5450d2906d..c78120f358 100644 --- a/OpenRA.Game/Effects/LaserZap.cs +++ b/OpenRA.Game/Effects/LaserZap.cs @@ -61,7 +61,7 @@ namespace OpenRA.Effects if (!doneDamage) { - Combat.DoImpacts(args, args.dest); + Combat.DoImpacts(args); doneDamage = true; } } diff --git a/OpenRA.Game/Effects/Missile.cs b/OpenRA.Game/Effects/Missile.cs index 26f5adf9c0..20c88989d5 100755 --- a/OpenRA.Game/Effects/Missile.cs +++ b/OpenRA.Game/Effects/Missile.cs @@ -116,7 +116,7 @@ namespace OpenRA.Effects world.AddFrameEndTask(w => w.Remove(this)); Args.dest = Pos.ToInt2(); if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */ - Combat.DoImpacts(Args, Pos.ToInt2()); + Combat.DoImpacts(Args); } public IEnumerable Render() diff --git a/OpenRA.Game/Effects/TeslaZap.cs b/OpenRA.Game/Effects/TeslaZap.cs index 126c3be584..486a69ab7e 100755 --- a/OpenRA.Game/Effects/TeslaZap.cs +++ b/OpenRA.Game/Effects/TeslaZap.cs @@ -51,7 +51,7 @@ namespace OpenRA.Effects if (!doneDamage) { - Combat.DoImpacts(Args, Args.dest); + Combat.DoImpacts(Args); doneDamage = true; } } diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index 1fd3c6ee89..3f37f630ef 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc firedBy = self, target = self, weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()] - }, self.CenterLocation.ToInt2()); + }); poisonTicks = Rules.Weapons[info.Weapon.ToLowerInvariant()].ROF; }