< Summary

Class:MovementBase
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Movements/MovementBase.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:29
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MovementBase(...)0%110100%
LimitAccelerationInput(...)0%110100%

File(s)

/github/workspace/Assets/Scripts/Movements/MovementBase.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4// Base implementation of a movement behavior.
 5public abstract class MovementBase : IMovement {
 6  // Agent to which the movement behavior is assigned.
 1607  public IAgent Agent { get; init; }
 8
 349  public MovementBase(IAgent agent) {
 1710    Agent = agent;
 1711  }
 12
 13  // Determine the agent's actual acceleration input given its intended acceleration input by
 14  // applying physics and other constraints.
 15  public abstract Vector3 Act(in Vector3 accelerationInput);
 16
 17  // Limit acceleration input to the agent's maximum forward and normal accelerations.
 1418  protected Vector3 LimitAccelerationInput(in Vector3 accelerationInput) {
 1419    Vector3 forwardAccelerationInput = Vector3.Project(accelerationInput, Agent.Forward);
 1420    Vector3 normalAccelerationInput = Vector3.ProjectOnPlane(accelerationInput, Agent.Forward);
 21
 22    // Limit the forward and the normal acceleration magnitude.
 1423    forwardAccelerationInput =
 24        Vector3.ClampMagnitude(forwardAccelerationInput, Agent.MaxForwardAcceleration());
 1425    normalAccelerationInput =
 26        Vector3.ClampMagnitude(normalAccelerationInput, Agent.MaxNormalAcceleration());
 1427    return forwardAccelerationInput + normalAccelerationInput;
 1428  }
 29}