Refactor GravityBomb velocity/acceleration

This commit is contained in:
reaperrr
2017-01-22 16:42:13 +01:00
parent dac8a8e4f6
commit 5b617cf6e5
3 changed files with 13 additions and 11 deletions

View File

@@ -34,10 +34,11 @@ namespace OpenRA.Mods.Common.Projectiles
[PaletteReference] public readonly string ShadowPalette = "shadow"; [PaletteReference] public readonly string ShadowPalette = "shadow";
public readonly WDist Speed = WDist.Zero; [Desc("Projectile movement vector per tick (forward, right, up), use negative values for opposite directions.")]
public readonly WVec Velocity = WVec.Zero;
[Desc("Value added to speed every tick.")] [Desc("Value added to Velocity every tick.")]
public readonly WDist Acceleration = new WDist(15); public readonly WVec Acceleration = new WVec(0, 0, -15);
public IProjectile Create(ProjectileArgs args) { return new GravityBomb(this, args); } public IProjectile Create(ProjectileArgs args) { return new GravityBomb(this, args); }
} }
@@ -47,17 +48,18 @@ namespace OpenRA.Mods.Common.Projectiles
readonly GravityBombInfo info; readonly GravityBombInfo info;
readonly Animation anim; readonly Animation anim;
readonly ProjectileArgs args; readonly ProjectileArgs args;
readonly WVec acceleration;
[Sync] WVec velocity; [Sync] WVec velocity;
[Sync] WPos pos; [Sync] WPos pos;
[Sync] WVec acceleration;
public GravityBomb(GravityBombInfo info, ProjectileArgs args) public GravityBomb(GravityBombInfo info, ProjectileArgs args)
{ {
this.info = info; this.info = info;
this.args = args; this.args = args;
pos = args.Source; pos = args.Source;
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Speed); var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z);
acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration); velocity = convertedVelocity.Rotate(WRot.FromFacing(args.Facing));
acceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z);
if (!string.IsNullOrEmpty(info.Image)) if (!string.IsNullOrEmpty(info.Image))
{ {
@@ -72,7 +74,7 @@ namespace OpenRA.Mods.Common.Projectiles
public void Tick(World world) public void Tick(World world)
{ {
velocity -= acceleration; velocity += acceleration;
pos += velocity; pos += velocity;
if (pos.Z <= args.PassiveTarget.Z) if (pos.Z <= args.PassiveTarget.Z)

View File

@@ -55,8 +55,8 @@ OrniBomb:
Range: 2c0 Range: 2c0
Projectile: GravityBomb Projectile: GravityBomb
Image: BOMBS Image: BOMBS
Speed: 64 Velocity: 0, 0, -64
Acceleration: 0 Acceleration: 0, 0, 0
Shadow: true Shadow: true
Warhead@1Dam: SpreadDamage Warhead@1Dam: SpreadDamage
Spread: 320 Spread: 320

View File

@@ -5,8 +5,8 @@ ParaBomb:
Projectile: GravityBomb Projectile: GravityBomb
Image: PARABOMB Image: PARABOMB
OpenSequence: open OpenSequence: open
Speed: 86 Velocity: 0, 0, -86
Acceleration: 0 Acceleration: 0, 0, 0
Warhead@1Dam: SpreadDamage Warhead@1Dam: SpreadDamage
Spread: 768 Spread: 768
Damage: 300 Damage: 300