From ea0522118057c511e882afa460e61cc964d16770 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 26 Nov 2017 11:53:01 +0000 Subject: [PATCH] Count AttackStatus.NeedsToTurn as valid for AttackBase.IsAttacking. --- OpenRA.Mods.Common/Activities/Attack.cs | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index f73f37b4b8..9bb82d661d 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities public class Attack : Activity { [Flags] - enum AttackStatus { UnableToAttack, NeedsToTurn, NeedsToMove, Attacking } + protected enum AttackStatus { UnableToAttack, NeedsToTurn, NeedsToMove, Attacking } protected readonly Target Target; readonly AttackBase[] attackTraits; @@ -58,8 +58,8 @@ namespace OpenRA.Mods.Common.Activities foreach (var attack in attackTraits.Where(x => !x.IsTraitDisabled)) { - var activity = InnerTick(self, attack); - attack.IsAttacking = activity == this; + var status = TickAttack(self, attack); + attack.IsAttacking = status == AttackStatus.Attacking || status == AttackStatus.NeedsToTurn; } if (attackStatus.HasFlag(AttackStatus.Attacking)) @@ -74,17 +74,17 @@ namespace OpenRA.Mods.Common.Activities return NextActivity; } - protected virtual Activity InnerTick(Actor self, AttackBase attack) + protected virtual AttackStatus TickAttack(Actor self, AttackBase attack) { if (IsCanceled) - return NextActivity; + return AttackStatus.UnableToAttack; var type = Target.Type; if (!Target.IsValidFor(self) || type == TargetType.FrozenActor) - return NextActivity; + return AttackStatus.UnableToAttack; if (attack.Info.AttackRequiresEnteringCell && !positionable.CanEnterCell(Target.Actor.Location, null, false)) - return NextActivity; + return AttackStatus.UnableToAttack; // Drop the target if it moves under the shroud / fog. // HACK: This would otherwise break targeting frozen actors @@ -93,12 +93,12 @@ namespace OpenRA.Mods.Common.Activities if (!attack.Info.IgnoresVisibility && type == TargetType.Actor && !Target.Actor.Info.HasTraitInfo() && !Target.Actor.CanBeViewedByPlayer(self.Owner)) - return NextActivity; + return AttackStatus.UnableToAttack; // Drop the target once none of the weapons are effective against it var armaments = attack.ChooseArmamentsForTarget(Target, forceAttack).ToList(); if (armaments.Count == 0) - return NextActivity; + return AttackStatus.UnableToAttack; // Update ranges minRange = armaments.Max(a => a.Weapon.MinRange); @@ -112,11 +112,11 @@ namespace OpenRA.Mods.Common.Activities { // Try to move within range, drop the target otherwise if (move == null) - return NextActivity; + return AttackStatus.UnableToAttack; attackStatus |= AttackStatus.NeedsToMove; moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this); - return NextActivity; + return AttackStatus.NeedsToMove; } var targetedPosition = attack.GetTargetPosition(pos, Target); @@ -125,13 +125,13 @@ namespace OpenRA.Mods.Common.Activities { attackStatus |= AttackStatus.NeedsToTurn; turnActivity = ActivityUtils.SequenceActivities(new Turn(self, desiredFacing), this); - return NextActivity; + return AttackStatus.NeedsToTurn; } attackStatus |= AttackStatus.Attacking; attack.DoAttack(self, Target, armaments); - return this; + return AttackStatus.Attacking; } } }