< Summary

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

Metrics

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

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 {
 128  public SpeedEscapeDetector(IAgent agent) : base(agent) {}
 9
 410  public override bool IsEscaping(IHierarchical target) {
 511    if (target == null) {
 112      return false;
 13    }
 14
 315    float predictedAgentSpeed = CalculatePredictedAgentSpeed(target.Position);
 316    return predictedAgentSpeed <= target.Speed;
 417  }
 18
 19  // Calculate the predicted agent speed when it has reached the target's current position.
 320  private float CalculatePredictedAgentSpeed(in Vector3 targetPosition) {
 321    float fractionalSpeed = FractionalSpeed.Calculate(Agent, targetPosition);
 322    return fractionalSpeed * Agent.Speed;
 323  }
 24}