using UnityEngine;
namespace PlatypusIdeas.AirPath.Runtime.Configuration {
/// <summary>
/// Configuration for all visualization aspects of the pathfinding system
/// </summary>
[CreateAssetMenu(fileName = "VisualizationConfig", menuName = "Pathfinding/Configurations/Visualization Configuration")]
public class VisualizationConfiguration : ConfigurationBase {
[Header("Path Visualization")]
[SerializeField] private bool showPathLine = true;
[SerializeField] private bool showPathCellColors;
[SerializeField] private bool showDebugGizmos;
[SerializeField] private bool showHeatmapGrid;
[Header("Path Line Settings")]
[SerializeField] private GameObject pathLineRendererPrefab;
[SerializeField, Range(0f, 50f)] private float pathLineHeight = 15f;
[SerializeField] private Material pathMaterial;
[SerializeField] private Color pathColor = Color.blue;
[SerializeField] private AnimationCurve pathLineWidthCurve = AnimationCurve.Linear(0, 2f, 1, 0.5f);
[SerializeField, Range(0.1f, 5f)] private float pathLineWidth = 2f;
[Header("Grid Visualization")]
[SerializeField] private GameObject heatMapCubePrefab; // Changed from Material to GameObject prefab
[SerializeField] private GameObject pathCellPrefab; // New prefab for path cells
[SerializeField, Range(0.1f, 1f)] private float cellTransparency = 0.8f;
[SerializeField] private Color startCellColor = Color.green;
[SerializeField] private Color endCellColor = Color.red;
[Header("Debug Settings")]
[SerializeField] private bool showBoundaryWarnings = true;
[SerializeField] private bool showSpeedIndicators = false;
[SerializeField] private Color debugPathColor = Color.cyan;
// Properties
public bool ShowPathLine => showPathLine;
public bool ShowPathCellColors => showPathCellColors;
public bool ShowDebugGizmos => showDebugGizmos;
public bool ShowHeatmapGrid => showHeatmapGrid;
public GameObject PathLineRendererPrefab => pathLineRendererPrefab;
public float PathLineHeight => pathLineHeight;
public Material PathMaterial => pathMaterial;
public Color PathColor => pathColor;
public AnimationCurve PathLineWidthCurve => pathLineWidthCurve;
public float PathLineWidth => pathLineWidth;
public GameObject HeatMapCubePrefab => heatMapCubePrefab;
public GameObject PathCellPrefab => pathCellPrefab;
public float CellTransparency => cellTransparency;
public Color StartCellColor => startCellColor;
public Color EndCellColor => endCellColor;
public Color DebugPathColor => debugPathColor;
public override bool Validate() {
var valid = true;
if (showPathLine && pathLineRendererPrefab == null) {
Debug.LogWarning($"[{ConfigurationName}] Path line renderer prefab is required when Show Path Line is enabled");
valid = false;
}
if (pathLineRendererPrefab != null) {
var lineRenderer = pathLineRendererPrefab.GetComponent<LineRenderer>();
if (lineRenderer == null) {
Debug.LogError($"[{ConfigurationName}] Path line renderer prefab must have a LineRenderer component");
valid = false;
}
}
// Validate grid prefabs if debug grid is enabled
if (showHeatmapGrid) {
if (heatMapCubePrefab == null) {
Debug.LogWarning($"[{ConfigurationName}] Heat map cube prefab is required when Show Debug Grid is enabled");
valid = false;
}
if (heatMapCubePrefab != null && heatMapCubePrefab.GetComponent<MeshRenderer>() == null) {
Debug.LogError($"[{ConfigurationName}] Heat map cube prefab must have a MeshRenderer component");
valid = false;
}
}
if (showPathCellColors && pathCellPrefab == null) {
Debug.LogWarning($"[{ConfigurationName}] Path cell prefab is required when Show Path Cell Colors is enabled");
valid = false;
}
if (pathCellPrefab != null && pathCellPrefab.GetComponent<MeshRenderer>() == null) {
Debug.LogError($"[{ConfigurationName}] Path cell prefab must have a MeshRenderer component");
valid = false;
}
return valid;
}
public override void ResetToDefaults() {
showPathLine = true;
showPathCellColors = false;
showDebugGizmos = false;
showHeatmapGrid = false;
pathLineHeight = 15f;
pathColor = Color.blue;
pathLineWidthCurve = AnimationCurve.Linear(0, 2f, 1, 0.5f);
pathLineWidth = 2f;
cellTransparency = 0.8f;
startCellColor = Color.green;
endCellColor = Color.red;
showBoundaryWarnings = true;
showSpeedIndicators = false;
debugPathColor = Color.cyan;
// Clear prefab references on reset
heatMapCubePrefab = null;
pathCellPrefab = null;
}
}
}