public void FilterTargetsCallsAllPickers() { var filteredTargets = _picker.FilterTargets(testTargets); Assert.AreEqual(ReturnedTargetsP2.Single().Score, filteredTargets.Single().Score); _p1.Verify(p => p.FilterTargets(It.IsAny <IEnumerable <PotentialTarget> >()), Times.Once); _p1.Verify(p => p.FilterTargets(testTargets), Times.Once); _p2.Verify(p => p.FilterTargets(It.IsAny <IEnumerable <PotentialTarget> >()), Times.Once); _p2.Verify(p => p.FilterTargets(ReturnedTargetsP1), Times.Once); }
// Update is called once per frame void FixedUpdate() { if (_active) { var targetIsInvalid = CurrentTarget == null || CurrentTarget.Transform.IsInvalid(); if (targetIsInvalid || (ContinuallyCheckForTargets && _pollCountdonwn <= 0)) { //either the target is invalid, or the poll interval has elapsed and the ContinuallyCheckForTargets boolean is true, so a new poll should be made. if (Detector == null) { Debug.LogWarning(name + " has no detector."); return; } //Debug.Log(name + " aquiring new target"); var allTargets = Detector.DetectTargets(IncludeNavigationTargets); var allTargetsList = allTargets.ToList(); FilteredTargets = TargetPicker.FilterTargets(allTargets).OrderByDescending(t => t.Score).Select(t => t as Target); var filteredTargetsList = FilteredTargets.ToList(); var bestTarget = FilteredTargets.FirstOrDefault(); if (TargetHasChanged(bestTarget, CurrentTarget)) { //LogTargetChange(CurrentTarget, bestTarget, targetIsInvalid); CurrentTarget = bestTarget; } if (CurrentTarget != null && NeverRetarget) { Deactivate(); //never try to find a new target, so deactivate } _pollCountdonwn = PollInterval; } else { //there was no poll this frame, so decrement the countdown. _pollCountdonwn -= Time.fixedDeltaTime; } } }