< Summary

Class:SpeedEscapeDetector
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Escape/SpeedEscapeDetector.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:24
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SpeedEscapeDetector(...)0%2100%
IsEscaping(...)0%6200%
CalculatePredictedAgentSpeed(...)0%2100%

File(s)

/github/workspace/Assets/Scripts/Escape/SpeedEscapeDetector.cs

#LineLine coverage
 1using UnityEngine;
 2
 3// Speed escape detector.
 4//
 5// The speed escape detector checks whether the agent has a speed greater than the threat's when it
 6// has navigated to the threat's current position.
 7public class SpeedEscapeDetector : EscapeDetectorBase {
 08  public SpeedEscapeDetector(IAgent agent) : base(agent) {}
 9
 010  public override bool IsEscaping(IHierarchical target) {
 011    if (target == null) {
 012      return false;
 13    }
 14
 015    float predictedAgentSpeed = CalculatePredictedAgentSpeed(target.Position);
 016    return predictedAgentSpeed <= target.Speed;
 017  }
 18
 19  // Calculate the predicted agent speed when it has reached the target's current position.
 020  private float CalculatePredictedAgentSpeed(in Vector3 targetPosition) {
 021    float fractionalSpeed = FractionalSpeed.Calculate(Agent, targetPosition);
 022    return fractionalSpeed * Agent.Speed;
 023  }
 24}