< Summary

Class:TacticalSymbol
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/UI/TacticalSymbol.cs
Covered lines:0
Uncovered lines:51
Coverable lines:51
Total lines:96
Line coverage:0% (0 of 51)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:11
Method coverage:0% (0 of 11)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2100%
SetDirectionArrowRotation(...)0%6200%
DisableDirectionArrow()0%6200%
SetSprite(...)0%12300%
SetUniqueDesignator(...)0%2100%
SetIFF(...)0%2100%
SetType(...)0%2100%
SetSpeedAlt(...)0%2100%
SetAdditionalInfo(...)0%2100%
SetText(...)0%6200%
Update()0%2100%

File(s)

/github/workspace/Assets/Scripts/UI/TacticalSymbol.cs

#LineLine coverage
 1using UnityEngine;
 2using TMPro;
 3using UnityEngine.UI;
 4public class TacticalSymbol : MonoBehaviour {
 5  [SerializeField]
 6  private GameObject _directionArrow;
 7  [SerializeField]
 8  private TextMeshProUGUI _uniqueDesignatorText;
 9  [SerializeField]
 10  private TextMeshProUGUI _iffText;
 11  [SerializeField]
 12  private TextMeshProUGUI _typeText;
 13  [SerializeField]
 14  private TextMeshProUGUI _speedAltText;
 15  [SerializeField]
 16  private TextMeshProUGUI _additionalInfoText;
 17
 18  private SpriteManager _spriteManager;
 19
 020  void Awake() {
 021    _spriteManager = new SpriteManager();
 022    _uniqueDesignatorText.text = "";
 023    _iffText.text = "";
 024    _typeText.text = "";
 025    _speedAltText.text = "";
 026    _additionalInfoText.text = "";
 027  }
 28
 029  public void SetDirectionArrowRotation(float rotationDegrees) {
 030    if (_directionArrow != null) {
 031      _directionArrow.GetComponent<RectTransform>().rotation =
 32          Quaternion.Euler(0, 0, rotationDegrees);
 033    }
 034  }
 35
 036  public void DisableDirectionArrow() {
 037    if (_directionArrow != null) {
 038      _directionArrow.SetActive(false);
 039    } else {
 040      Debug.LogWarning("Direction arrow not found on TacticalSymbol" + name);
 041    }
 042  }
 43
 044  public void SetSprite(string spriteName) {
 045    spriteName = spriteName.ToUpper();
 46    // Update main symbol image
 047    Image symbolImage = GetComponent<Image>();
 048    if (symbolImage != null) {
 049      Sprite symbolSprite = _spriteManager.LoadSymbolSprite(spriteName);
 050      if (symbolSprite != null) {
 051        symbolImage.sprite = symbolSprite;
 052      }
 053    }
 054  }
 55
 056  public void SetUniqueDesignator(string text) {
 057    SetText(_uniqueDesignatorText, text);
 058  }
 59
 060  public void SetIFF(string text) {
 061    SetText(_iffText, text);
 062  }
 63
 064  public void SetType(string text) {
 065    SetText(_typeText, text);
 066  }
 67
 068  public void SetSpeedAlt(string text) {
 069    SetText(_speedAltText, text);
 070  }
 71
 072  public void SetAdditionalInfo(string text) {
 073    SetText(_additionalInfoText, text);
 074  }
 75
 076  private void SetText(TextMeshProUGUI textComponent, string text) {
 077    if (textComponent != null) {
 078      textComponent.text = text.ToUpper();
 079    }
 080  }
 81
 082  void Update() {}
 83}
 84
 85public class SpriteManager {
 86  private const string SymbolPathFormat = "APP6-D_Symbology/{0}";
 87
 88  public Sprite LoadSymbolSprite(string symbolName) {
 89    string path = string.Format(SymbolPathFormat, symbolName);
 90    Sprite sprite = Resources.Load<Sprite>(path);
 91    if (sprite == null) {
 92      Debug.LogWarning($"Failed to load sprite at path: {path}");
 93    }
 94    return sprite;
 95  }
 96}