Minor projectile clean-ups and perf optimizations

This commit is contained in:
reaperrr
2019-05-13 01:04:00 +02:00
committed by reaperrr
parent 6897ebe2a8
commit 90325305d6
6 changed files with 31 additions and 25 deletions

View File

@@ -103,20 +103,19 @@ namespace OpenRA.Mods.Common.Projectiles
readonly BulletInfo info; readonly BulletInfo info;
readonly ProjectileArgs args; readonly ProjectileArgs args;
readonly Animation anim; readonly Animation anim;
[Sync] readonly WAngle angle; readonly int facing;
[Sync] readonly WDist speed; readonly WAngle angle;
readonly WDist speed;
readonly string trailPalette;
readonly ContrailRenderable contrail;
ContrailRenderable contrail; [Sync]
string trailPalette; WPos pos, target, source;
[Sync] WPos pos, target, source;
int length; int length;
[Sync] int facing;
int ticks, smokeTicks; int ticks, smokeTicks;
int remainingBounces; int remainingBounces;
public Actor SourceActor { get { return args.SourceActor; } }
public Bullet(BulletInfo info, ProjectileArgs args) public Bullet(BulletInfo info, ProjectileArgs args)
{ {
this.info = info; this.info = info;

View File

@@ -51,8 +51,10 @@ namespace OpenRA.Mods.Common.Projectiles
readonly Animation anim; readonly Animation anim;
readonly ProjectileArgs args; readonly ProjectileArgs args;
readonly WVec acceleration; readonly WVec acceleration;
[Sync] WVec velocity; WVec velocity;
[Sync] WPos pos;
[Sync]
WPos pos;
public GravityBomb(GravityBombInfo info, ProjectileArgs args) public GravityBomb(GravityBombInfo info, ProjectileArgs args)
{ {

View File

@@ -43,20 +43,18 @@ namespace OpenRA.Mods.Common.Projectiles
readonly InstantHitInfo info; readonly InstantHitInfo info;
Target target; Target target;
WPos source;
public InstantHit(InstantHitInfo info, ProjectileArgs args) public InstantHit(InstantHitInfo info, ProjectileArgs args)
{ {
this.args = args; this.args = args;
this.info = info; this.info = info;
source = args.Source;
if (args.Weapon.TargetActorCenter) if (args.Weapon.TargetActorCenter)
target = args.GuidedTarget; target = args.GuidedTarget;
else if (info.Inaccuracy.Length > 0) else if (info.Inaccuracy.Length > 0)
{ {
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var maxOffset = inaccuracy * (args.PassiveTarget - source).Length / args.Weapon.Range.Length; var maxOffset = inaccuracy * (args.PassiveTarget - args.Source).Length / args.Weapon.Range.Length;
target = Target.FromPos(args.PassiveTarget + WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024); target = Target.FromPos(args.PassiveTarget + WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024);
} }
else else
@@ -67,7 +65,7 @@ namespace OpenRA.Mods.Common.Projectiles
{ {
// Check for blocking actors // Check for blocking actors
WPos blockedPos; WPos blockedPos;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target.CenterPosition, if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition,
info.Width, out blockedPos)) info.Width, out blockedPos))
{ {
target = Target.FromPos(blockedPos); target = Target.FromPos(blockedPos);

View File

@@ -103,12 +103,16 @@ namespace OpenRA.Mods.Common.Projectiles
readonly Animation hitanim; readonly Animation hitanim;
readonly Color color; readonly Color color;
readonly Color secondaryColor; readonly Color secondaryColor;
int ticks = 0; readonly bool hasLaunchEffect;
int ticks;
int interval; int interval;
bool showHitAnim; bool showHitAnim;
bool hasLaunchEffect;
[Sync] WPos target; [Sync]
[Sync] WPos source; WPos target;
[Sync]
WPos source;
public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color) public LaserZap(LaserZapInfo info, ProjectileArgs args, Color color)
{ {

View File

@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Projectiles
States state; States state;
bool targetPassedBy; bool targetPassedBy;
bool lockOn = false; bool lockOn;
bool allowPassBy; // TODO: use this also with high minimum launch angle settings bool allowPassBy; // TODO: use this also with high minimum launch angle settings
WPos targetPosition; WPos targetPosition;
@@ -187,7 +187,9 @@ namespace OpenRA.Mods.Common.Projectiles
WVec tarVel; WVec tarVel;
WVec predVel; WVec predVel;
[Sync] WPos pos; [Sync]
WPos pos;
WVec velocity; WVec velocity;
int speed; int speed;
int loopRadius; int loopRadius;
@@ -195,11 +197,12 @@ namespace OpenRA.Mods.Common.Projectiles
WDist rangeLimit; WDist rangeLimit;
int renderFacing; int renderFacing;
[Sync] int hFacing;
[Sync] int vFacing;
public Actor SourceActor { get { return args.SourceActor; } } [Sync]
public Target GuidedTarget { get { return args.GuidedTarget; } } int hFacing;
[Sync]
int vFacing;
public Missile(MissileInfo info, ProjectileArgs args) public Missile(MissileInfo info, ProjectileArgs args)
{ {

View File

@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Projectiles
public readonly Color BeamColor; public readonly Color BeamColor;
public readonly Color HelixColor; public readonly Color HelixColor;
int ticks = 0; int ticks;
bool animationComplete; bool animationComplete;
WPos target; WPos target;