Add ImpactOrientation to WarheadArgs

Allows to pass the horizontal facing/yaw
and vertical angle/pitch of the carrier
projectile to warheads for further use.

Add ImpactPosition to WarheadArgs

InflictDamage doesn't pass the impact pos
directly, and the very point of WarheadArgs
is to avoid adding more and more arguments
to the warhead methods.
This commit is contained in:
reaperrr
2019-09-26 17:14:11 +02:00
committed by teinarss
parent bf7fecff10
commit 8513a83331
9 changed files with 80 additions and 10 deletions

View File

@@ -12,6 +12,7 @@
using System.Collections.Generic;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Projectiles
@@ -58,7 +59,7 @@ namespace OpenRA.Mods.Common.Projectiles
WVec velocity;
[Sync]
WPos pos;
WPos pos, lastPos;
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
{
@@ -82,6 +83,7 @@ namespace OpenRA.Mods.Common.Projectiles
public void Tick(World world)
{
lastPos = pos;
pos += velocity;
velocity += acceleration;
@@ -90,7 +92,13 @@ namespace OpenRA.Mods.Common.Projectiles
pos += new WVec(0, 0, args.PassiveTarget.Z - pos.Z);
world.AddFrameEndTask(w => w.Remove(this));
args.Weapon.Impact(Target.FromPos(pos), new WarheadArgs(args));
var warheadArgs = new WarheadArgs(args)
{
ImpactOrientation = new WRot(WAngle.Zero, Util.GetVerticalAngle(lastPos, pos), args.Facing),
ImpactPosition = pos,
};
args.Weapon.Impact(Target.FromPos(pos), warheadArgs);
}
if (anim != null)