pass target to DoAttack
This commit is contained in:
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
}
|
}
|
||||||
|
|
||||||
attack.target = Target;
|
attack.target = Target;
|
||||||
attack.DoAttack(self);
|
attack.DoAttack(self, Target);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if( limitedAmmo != null && !limitedAmmo.HasAmmo() )
|
if( limitedAmmo != null && !limitedAmmo.HasAmmo() )
|
||||||
Cancel( self );
|
Cancel( self );
|
||||||
|
|
||||||
self.Trait<AttackPlane>().DoAttack( self );
|
self.Trait<AttackPlane>().DoAttack( self, Target );
|
||||||
|
|
||||||
if( IsCanceled && inner == null ) return NextActivity;
|
if( IsCanceled && inner == null ) return NextActivity;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
||||||
aircraft.center += (rawSpeed / dist.Length) * dist;
|
aircraft.center += (rawSpeed / dist.Length) * dist;
|
||||||
|
|
||||||
attack.DoAttack( self );
|
attack.DoAttack( self, target );
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA
|
|||||||
a();
|
a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoAttack(Actor self)
|
public void DoAttack(Actor self, Target target)
|
||||||
{
|
{
|
||||||
if( !CanAttack( self ) ) return;
|
if( !CanAttack( self ) ) return;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "Attack" || order.OrderString == "Heal")
|
if (order.OrderString == "Attack" || order.OrderString == "Heal")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
QueueAttack(self, order);
|
QueueAttack(self, Target.FromOrder(order));
|
||||||
|
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
@@ -181,14 +181,14 @@ namespace OpenRA.Mods.RA
|
|||||||
return (order.OrderString == "Attack" || order.OrderString == "Heal") ? "Attack" : null;
|
return (order.OrderString == "Attack" || order.OrderString == "Heal") ? "Attack" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void QueueAttack(Actor self, Order order)
|
protected virtual void QueueAttack(Actor self, Target newTarget)
|
||||||
{
|
{
|
||||||
var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
|
var weapon = ChooseWeaponForTarget(newTarget);
|
||||||
|
|
||||||
if (weapon != null)
|
if (weapon != null)
|
||||||
self.QueueActivity(
|
self.QueueActivity(
|
||||||
new Activities.Attack(
|
new Activities.Attack(
|
||||||
Target.FromOrder(order),
|
newTarget,
|
||||||
Math.Max(0, (int)weapon.Info.Range)));
|
Math.Max(0, (int)weapon.Info.Range)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public AttackHeli(Actor self) : base(self, 20) { }
|
public AttackHeli(Actor self) : base(self, 20) { }
|
||||||
|
|
||||||
protected override void QueueAttack(Actor self, Order order)
|
protected override void QueueAttack(Actor self, Target newTarget)
|
||||||
{
|
{
|
||||||
target = Target.FromOrder(order);
|
target = newTarget;
|
||||||
self.QueueActivity(new HeliAttack(target));
|
self.QueueActivity(new HeliAttack(newTarget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ namespace OpenRA.Mods.RA
|
|||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
DoAttack(self);
|
DoAttack(self, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void QueueAttack(Actor self, Order order)
|
protected override void QueueAttack(Actor self, Target newTarget)
|
||||||
{
|
{
|
||||||
target = Target.FromOrder(order);
|
target = newTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public AttackPlane(Actor self) : base(self, 20) { }
|
public AttackPlane(Actor self) : base(self, 20) { }
|
||||||
|
|
||||||
protected override void QueueAttack(Actor self, Order order)
|
protected override void QueueAttack(Actor self, Target newTarget)
|
||||||
{
|
{
|
||||||
target = Target.FromOrder(order);
|
target = newTarget;
|
||||||
self.QueueActivity(new FlyAttack(target));
|
self.QueueActivity(new FlyAttack(newTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CanAttack(Actor self)
|
protected override bool CanAttack(Actor self)
|
||||||
|
|||||||
@@ -42,23 +42,23 @@ namespace OpenRA.Mods.RA
|
|||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
DoAttack( self );
|
DoAttack( self, target );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void QueueAttack( Actor self, Order order )
|
protected override void QueueAttack( Actor self, Target newTarget )
|
||||||
{
|
{
|
||||||
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
|
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||||
var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
|
var weapon = ChooseWeaponForTarget(newTarget);
|
||||||
if (weapon == null)
|
if (weapon == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
target = Target.FromOrder(order);
|
target = newTarget;
|
||||||
|
|
||||||
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||||
self.QueueActivity( new Follow( target,
|
self.QueueActivity( new Follow( newTarget,
|
||||||
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
|
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var attack = self.TraitOrDefault<AttackBase>();
|
var attack = self.TraitOrDefault<AttackBase>();
|
||||||
var isAttacking = attack != null && attack.target.IsValid;
|
var isAttacking = attack.IsAttacking;
|
||||||
anims["turret_0"].Animation.ReplaceAnim(isAttacking ? "aim" : "turret");
|
anims["turret_0"].Animation.ReplaceAnim(isAttacking ? "aim" : "turret");
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user