diff --git a/OpenRA.Mods.RA/Air/AttackHeli.cs b/OpenRA.Mods.RA/Air/AttackHeli.cs index 540523af0f..8e134c24f3 100755 --- a/OpenRA.Mods.RA/Air/AttackHeli.cs +++ b/OpenRA.Mods.RA/Air/AttackHeli.cs @@ -22,10 +22,9 @@ namespace OpenRA.Mods.RA.Air { public AttackHeli(Actor self, AttackHeliInfo info) : base(self, info) { } - protected override void QueueAttack(Actor self, bool queued, Target newTarget) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { - target = newTarget; - self.QueueActivity(queued, new HeliAttack(newTarget)); + return new HeliAttack( newTarget ); } } } diff --git a/OpenRA.Mods.RA/Air/AttackPlane.cs b/OpenRA.Mods.RA/Air/AttackPlane.cs index ab5304b252..4293b137f6 100755 --- a/OpenRA.Mods.RA/Air/AttackPlane.cs +++ b/OpenRA.Mods.RA/Air/AttackPlane.cs @@ -22,10 +22,9 @@ namespace OpenRA.Mods.RA.Air { public AttackPlane(Actor self, AttackPlaneInfo info) : base(self, info) { } - protected override void QueueAttack(Actor self, bool queued, Target newTarget) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { - target = newTarget; - self.QueueActivity(queued, new FlyAttack(newTarget)); + return new FlyAttack( newTarget ); } protected override bool CanAttack(Actor self) diff --git a/OpenRA.Mods.RA/Air/FlyAttack.cs b/OpenRA.Mods.RA/Air/FlyAttack.cs index 5f6d920096..0971e71b6d 100755 --- a/OpenRA.Mods.RA/Air/FlyAttack.cs +++ b/OpenRA.Mods.RA/Air/FlyAttack.cs @@ -27,7 +27,9 @@ namespace OpenRA.Mods.RA.Air if( limitedAmmo != null && !limitedAmmo.HasAmmo() ) Cancel( self ); - self.Trait().DoAttack( self, Target ); + var attack = self.Trait(); + attack.target = Target; + attack.DoAttack( self, Target ); if( inner == null ) { diff --git a/OpenRA.Mods.RA/Air/HeliAttack.cs b/OpenRA.Mods.RA/Air/HeliAttack.cs index 8bf786e45c..25cb166a3a 100755 --- a/OpenRA.Mods.RA/Air/HeliAttack.cs +++ b/OpenRA.Mods.RA/Air/HeliAttack.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Air return this; } - var attack = self.Trait(); + var attack = self.Trait(); var range = attack.GetMaximumRange() - 1; var dist = target.CenterLocation - self.CenterLocation; @@ -46,6 +46,7 @@ namespace OpenRA.Mods.RA.Air if( !float2.WithinEpsilon( float2.Zero, dist, range * Game.CellSize ) ) aircraft.TickMove( 1024 * aircraft.MovementSpeed, desiredFacing ); + attack.target = target; attack.DoAttack( self, target ); return this; diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index 2b3eef7ab6..d99f256987 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -149,7 +149,7 @@ namespace OpenRA.Mods.RA { if (order.OrderString == "Attack") { - QueueAttack(self, order.Queued, Target.FromOrder(order)); + self.QueueActivity(order.Queued, GetAttackActivity(self, Target.FromOrder(order))); if (self.Owner == self.World.LocalPlayer) self.World.AddFrameEndTask(w => @@ -180,7 +180,7 @@ namespace OpenRA.Mods.RA return (order.OrderString == "Attack") ? "Attack" : null; } - protected abstract void QueueAttack(Actor self, bool queued, Target newTarget); + protected abstract IActivity GetAttackActivity(Actor self, Target newTarget); public bool HasAnyValidWeapons(Target t) { return Weapons.Any(w => w.IsValidAgainst(self.World, t)); } public float GetMaximumRange() { return Weapons.Max(w => w.Info.Range); } diff --git a/OpenRA.Mods.RA/AttackFrontal.cs b/OpenRA.Mods.RA/AttackFrontal.cs index d648b2813f..3dcdf736a4 100644 --- a/OpenRA.Mods.RA/AttackFrontal.cs +++ b/OpenRA.Mods.RA/AttackFrontal.cs @@ -40,15 +40,12 @@ namespace OpenRA.Mods.RA return true; } - protected override void QueueAttack(Actor self, bool queued, Target newTarget) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { var weapon = ChooseWeaponForTarget(newTarget); - - if (weapon != null) - self.QueueActivity( queued, - new Activities.Attack( - newTarget, - Math.Max(0, (int)weapon.Info.Range))); + if( weapon == null ) + return null; + return new Activities.Attack(newTarget, Math.Max(0, (int)weapon.Info.Range)); } } } diff --git a/OpenRA.Mods.RA/AttackLeap.cs b/OpenRA.Mods.RA/AttackLeap.cs index 9808ef1cba..ce5640e1f0 100644 --- a/OpenRA.Mods.RA/AttackLeap.cs +++ b/OpenRA.Mods.RA/AttackLeap.cs @@ -40,15 +40,12 @@ namespace OpenRA.Mods.RA self.QueueActivity(new Leap(self, target)); } - protected override void QueueAttack(Actor self, bool queued, Target newTarget) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { var weapon = ChooseWeaponForTarget(newTarget); - - if (weapon != null) - self.QueueActivity( queued, - new Activities.Attack( - newTarget, - Math.Max(0, (int)weapon.Info.Range))); + if( weapon == null ) + return null; + return new Activities.Attack(newTarget, Math.Max(0, (int)weapon.Info.Range)); } } } diff --git a/OpenRA.Mods.RA/AttackOmni.cs b/OpenRA.Mods.RA/AttackOmni.cs index d8d3ade121..039ca79a0e 100644 --- a/OpenRA.Mods.RA/AttackOmni.cs +++ b/OpenRA.Mods.RA/AttackOmni.cs @@ -38,9 +38,9 @@ namespace OpenRA.Mods.RA DoAttack(self, target); } - protected override void QueueAttack(Actor self, bool queued, Target newTarget) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { - self.QueueActivity( queued, new SetTarget( newTarget ) ); + return new SetTarget( newTarget ); } class SetTarget : CancelableActivity diff --git a/OpenRA.Mods.RA/AttackTurreted.cs b/OpenRA.Mods.RA/AttackTurreted.cs index e1f66904d7..20b0e9b449 100644 --- a/OpenRA.Mods.RA/AttackTurreted.cs +++ b/OpenRA.Mods.RA/AttackTurreted.cs @@ -46,12 +46,9 @@ namespace OpenRA.Mods.RA DoAttack( self, target ); } - protected override void QueueAttack( Actor self, bool queued, Target newTarget ) + protected override IActivity GetAttackActivity(Actor self, Target newTarget) { - if (self.TraitsImplementing().Any(d => d.Disabled)) - return; - - self.QueueActivity( queued, new AttackActivity( newTarget ) ); + return new AttackActivity( newTarget ); } bool buildComplete = false; @@ -66,6 +63,9 @@ namespace OpenRA.Mods.RA { if( IsCanceled ) return NextActivity; + if (self.TraitsImplementing().Any(d => d.Disabled)) + return this; + var attack = self.Trait(); const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ var weapon = attack.ChooseWeaponForTarget(newTarget);