| | | 1 | | using FixedMathSharp; |
| | | 2 | | using System; |
| | | 3 | | |
| | | 4 | | namespace Trailblazer.Pathing; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Provides extension methods for displaying information about walkable positions and XZ plane slices in a NavigationCh |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// These extension methods are intended to assist with debugging or visualizing navigation data by printing walkable po |
| | | 11 | | /// and 2D slices of the navigation chart to the console. |
| | | 12 | | /// </remarks> |
| | | 13 | | public static class NavigationChartExtensions |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Prints all walkable positions in the specified navigation chart to the console. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <remarks> |
| | | 19 | | /// Each walkable position is printed in the format (x, y, z) under a header containing the chart's name. |
| | | 20 | | /// This method is intended for debugging or informational purposes and writes output directly to the standard conso |
| | | 21 | | /// </remarks> |
| | | 22 | | /// <param name="chart">The navigation chart from which to retrieve and display walkable positions. Cannot be null.< |
| | | 23 | | public static void PrintWalkablePositions(this NavigationChart chart) |
| | | 24 | | { |
| | 1 | 25 | | Console.WriteLine($"Walkable Positions for Chart [{chart.Name}]:"); |
| | | 26 | | |
| | 6 | 27 | | foreach (Vector3d pos in chart.GetWalkablePositions()) |
| | 2 | 28 | | Console.WriteLine($" ({pos.x}, {pos.y}, {pos.z})"); |
| | 1 | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Prints a visual representation of the XZ plane at the specified Y level for the given navigation chart to the co |
| | | 33 | | /// </summary> |
| | | 34 | | /// <remarks> |
| | | 35 | | /// Each cell in the output represents whether the corresponding position is walkable. |
| | | 36 | | /// Walkable positions are indicated by 'O', and non-walkable positions by '.'. |
| | | 37 | | /// This method is intended for debugging or visualization purposes. |
| | | 38 | | /// </remarks> |
| | | 39 | | /// <param name="chart">The navigation chart from which to extract and display the XZ plane.</param> |
| | | 40 | | /// <param name="yLevel">The Y coordinate at which to display the XZ plane.</param> |
| | | 41 | | public static void PrintXZPlane(this NavigationChart chart, int yLevel) |
| | | 42 | | { |
| | 1 | 43 | | Console.WriteLine($"XZ Plane at Y={yLevel} for Chart [{chart.Name}]:"); |
| | | 44 | | |
| | 6 | 45 | | for (int z = (int)chart.MinBounds.z; z < (int)chart.MaxBounds.z; z++) |
| | | 46 | | { |
| | 12 | 47 | | for (int x = (int)chart.MinBounds.x; x < (int)chart.MaxBounds.x; x++) |
| | | 48 | | { |
| | 4 | 49 | | Vector3d pos = new(x, yLevel, z); |
| | 4 | 50 | | bool walkable = chart.IsWalkable(pos); |
| | 4 | 51 | | Console.Write(walkable ? "O " : ". "); |
| | | 52 | | } |
| | 2 | 53 | | Console.WriteLine(); |
| | | 54 | | } |
| | 1 | 55 | | } |
| | | 56 | | } |