Replace 'inner' with 'move' inside AttackMoveActivity

This commit is contained in:
abcdefg30
2020-09-08 19:22:54 +02:00
committed by reaperrr
parent ad3722e19f
commit 57a3ad8ae2

View File

@@ -19,18 +19,18 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class AttackMoveActivity : Activity public class AttackMoveActivity : Activity
{ {
readonly Func<Activity> getInner; readonly Func<Activity> getMove;
readonly bool isAssaultMove; readonly bool isAssaultMove;
readonly AutoTarget autoTarget; readonly AutoTarget autoTarget;
readonly AttackMove attackMove; readonly AttackMove attackMove;
bool runningInnerActivity = false; bool runningMoveActivity = false;
int token = Actor.InvalidConditionToken; int token = Actor.InvalidConditionToken;
Target target = Target.Invalid; Target target = Target.Invalid;
public AttackMoveActivity(Actor self, Func<Activity> getInner, bool assaultMoving = false) public AttackMoveActivity(Actor self, Func<Activity> getMove, bool assaultMoving = false)
{ {
this.getInner = getInner; this.getMove = getMove;
autoTarget = self.TraitOrDefault<AutoTarget>(); autoTarget = self.TraitOrDefault<AutoTarget>();
attackMove = self.TraitOrDefault<AttackMove>(); attackMove = self.TraitOrDefault<AttackMove>();
isAssaultMove = assaultMoving; isAssaultMove = assaultMoving;
@@ -54,32 +54,32 @@ namespace OpenRA.Mods.Common.Activities
return TickChild(self); return TickChild(self);
// We are currently not attacking, so scan for new targets. // We are currently not attacking, so scan for new targets.
if (autoTarget != null && (ChildActivity == null || runningInnerActivity)) if (autoTarget != null && (ChildActivity == null || runningMoveActivity))
{ {
// Use the standard ScanForTarget rate limit while we are running the inner move activity to save performance. // Use the standard ScanForTarget rate limit while we are running the move activity to save performance.
// Override the rate limit if our attack activity has completed so we can immediately acquire a new target instead of moving. // Override the rate limit if our attack activity has completed so we can immediately acquire a new target instead of moving.
target = autoTarget.ScanForTarget(self, false, true, !runningInnerActivity); target = autoTarget.ScanForTarget(self, false, true, !runningMoveActivity);
// Cancel the current inner activity and queue attack activities if we find a new target. // Cancel the current move activity and queue attack activities if we find a new target.
if (target.Type != TargetType.Invalid) if (target.Type != TargetType.Invalid)
{ {
runningInnerActivity = false; runningMoveActivity = false;
ChildActivity?.Cancel(self); ChildActivity?.Cancel(self);
foreach (var ab in autoTarget.ActiveAttackBases) foreach (var ab in autoTarget.ActiveAttackBases)
QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false)); QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false));
} }
// Continue with the inner activity (or queue a new one) when there are no targets. // Continue with the move activity (or queue a new one) when there are no targets.
if (ChildActivity == null) if (ChildActivity == null)
{ {
runningInnerActivity = true; runningMoveActivity = true;
QueueChild(getInner()); QueueChild(getMove());
} }
} }
// If the inner activity finished, we have reached our destination and there are no more enemies on our path. // If the move activity finished, we have reached our destination and there are no more enemies on our path.
return TickChild(self) && runningInnerActivity; return TickChild(self) && runningMoveActivity;
} }
protected override void OnLastRun(Actor self) protected override void OnLastRun(Actor self)
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self) public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{ {
foreach (var n in getInner().TargetLineNodes(self)) foreach (var n in getMove().TargetLineNodes(self))
yield return n; yield return n;
yield break; yield break;