Refactor GravityBomb velocity/acceleration
This commit is contained in:
@@ -34,10 +34,11 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
|
||||
[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.")]
|
||||
public readonly WDist Acceleration = new WDist(15);
|
||||
[Desc("Value added to Velocity every tick.")]
|
||||
public readonly WVec Acceleration = new WVec(0, 0, -15);
|
||||
|
||||
public IProjectile Create(ProjectileArgs args) { return new GravityBomb(this, args); }
|
||||
}
|
||||
@@ -47,17 +48,18 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
readonly GravityBombInfo info;
|
||||
readonly Animation anim;
|
||||
readonly ProjectileArgs args;
|
||||
readonly WVec acceleration;
|
||||
[Sync] WVec velocity;
|
||||
[Sync] WPos pos;
|
||||
[Sync] WVec acceleration;
|
||||
|
||||
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
|
||||
{
|
||||
this.info = info;
|
||||
this.args = args;
|
||||
pos = args.Source;
|
||||
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Speed);
|
||||
acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);
|
||||
var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z);
|
||||
velocity = convertedVelocity.Rotate(WRot.FromFacing(args.Facing));
|
||||
acceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z);
|
||||
|
||||
if (!string.IsNullOrEmpty(info.Image))
|
||||
{
|
||||
@@ -72,7 +74,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
velocity -= acceleration;
|
||||
velocity += acceleration;
|
||||
pos += velocity;
|
||||
|
||||
if (pos.Z <= args.PassiveTarget.Z)
|
||||
|
||||
@@ -55,8 +55,8 @@ OrniBomb:
|
||||
Range: 2c0
|
||||
Projectile: GravityBomb
|
||||
Image: BOMBS
|
||||
Speed: 64
|
||||
Acceleration: 0
|
||||
Velocity: 0, 0, -64
|
||||
Acceleration: 0, 0, 0
|
||||
Shadow: true
|
||||
Warhead@1Dam: SpreadDamage
|
||||
Spread: 320
|
||||
|
||||
@@ -5,8 +5,8 @@ ParaBomb:
|
||||
Projectile: GravityBomb
|
||||
Image: PARABOMB
|
||||
OpenSequence: open
|
||||
Speed: 86
|
||||
Acceleration: 0
|
||||
Velocity: 0, 0, -86
|
||||
Acceleration: 0, 0, 0
|
||||
Warhead@1Dam: SpreadDamage
|
||||
Spread: 768
|
||||
Damage: 300
|
||||
|
||||
Reference in New Issue
Block a user