public override bool Tick(Actor self) { // We are not currently attacking a target, so scan for new targets. if (!IsCanceling && ChildActivity != null && ChildActivity.NextActivity == null && autoTarget != null) { // ScanForTarget already limits the scanning rate for performance so we don't need to do that here. var target = autoTarget.ScanForTarget(self, false, true); if (target.Type != TargetType.Invalid) { // We have found a target so cancel the current move activity and queue attack activities. ChildActivity.Cancel(self); var attackBases = autoTarget.ActiveAttackBases; foreach (var ab in attackBases) { QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false)); } // Make sure to continue moving when the attack activities have finished. QueueChild(getInner()); } } // The last queued childactivity is guaranteed to be the inner move, so if the childactivity // queue is empty it means we have reached our destination and there are no more enemies on our path. return(TickChild(self)); }
public override bool Tick(Actor self) { if (IsCanceling) { return(TickChild(self)); } // We are currently not attacking, so scan for new targets. if (autoTarget != null && (ChildActivity == null || runningMoveActivity)) { // 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. target = autoTarget.ScanForTarget(self, false, true, !runningMoveActivity); // Cancel the current move activity and queue attack activities if we find a new target. if (target.Type != TargetType.Invalid) { runningMoveActivity = false; ChildActivity?.Cancel(self); foreach (var ab in autoTarget.ActiveAttackBases) { QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false)); } } // Continue with the move activity (or queue a new one) when there are no targets. if (ChildActivity == null) { runningMoveActivity = true; QueueChild(getMove()); } } // If the move activity finished, we have reached our destination and there are no more enemies on our path. return(TickChild(self) && runningMoveActivity); }