< Summary

Class:AttackBehavior
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Behavior/AttackBehavior.cs
Covered lines:11
Uncovered lines:3
Coverable lines:14
Total lines:51
Line coverage:78.5% (11 of 14)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:3
Method coverage:66.6% (2 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetNextWaypoint(...)0%2100%
ResolveBehaviorPath(...)0%220100%
FromJson(...)0%110100%

File(s)

/github/workspace/Assets/Scripts/Behavior/AttackBehavior.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3using Newtonsoft.Json;
 4using Newtonsoft.Json.Converters;
 5
 6public class AttackBehavior {
 7  public string name;
 8  public AttackBehaviorType attackBehaviorType;
 9
 10  public Vector3 targetPosition;
 11  public Vector3 targetVelocity;
 12  public Vector3 targetColliderSize;
 13  public FlightPlan flightPlan;
 14  // Returns the next waypoint for the threat to navigate to
 15  // In addition, return the power setting to use toward the waypoint
 16  public virtual (Vector3 waypointPosition, PowerSetting power)
 017      GetNextWaypoint(Vector3 currentPosition, Vector3 targetPosition) {
 018    return (targetPosition, PowerSetting.IDLE);
 019  }
 20
 1421  protected static string ResolveBehaviorPath(string json) {
 22    // Append "Configs/Behaviors/Attack/" to the json path if it's not already there
 2823    if (!json.StartsWith("Configs/Behaviors/Attack/")) {
 1424      json = "Configs/Behaviors/Attack/" + json;
 1425    }
 1426    return json;
 1427  }
 28
 729  public static AttackBehavior FromJson(string json) {
 730    string resolvedPath = ResolveBehaviorPath(json);
 731    string fileContent = ConfigLoader.LoadFromStreamingAssets(resolvedPath);
 732    return JsonConvert.DeserializeObject<AttackBehavior>(fileContent, new JsonSerializerSettings {
 33      Converters = { new Newtonsoft.Json.Converters.StringEnumConverter() }
 34    });
 735  }
 36
 37  [JsonConverter(typeof(StringEnumConverter))]
 38  public enum AttackBehaviorType { DIRECT_ATTACK, PREPLANNED_ATTACK, SLALOM_ATTACK }
 39}
 40
 41[System.Serializable]
 42public class VectorWaypoint : Waypoint {
 43  public Vector3 waypointPosition;
 44  public PowerSetting power;
 45}
 46
 47[System.Serializable]
 48public class Waypoint {}
 49public class FlightPlan {
 50  public string type;
 51}