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

@@ -43,20 +43,18 @@ namespace OpenRA.Mods.Common.Projectiles
readonly InstantHitInfo info;
Target target;
WPos source;
public InstantHit(InstantHitInfo info, ProjectileArgs args)
{
this.args = args;
this.info = info;
source = args.Source;
if (args.Weapon.TargetActorCenter)
target = args.GuidedTarget;
else if (info.Inaccuracy.Length > 0)
{
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);
}
else
@@ -67,7 +65,7 @@ namespace OpenRA.Mods.Common.Projectiles
{
// Check for blocking actors
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))
{
target = Target.FromPos(blockedPos);