< Summary

Information
Class: Trailblazer.Pathing.FlowFieldSurveyResult
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/FlowField/FlowFieldSurveyResult.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 92
Line coverage: 100%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_HasPath()100%44100%
.cctor()100%11100%
.ctor()100%11100%
Create(...)100%11100%
Create(...)75%44100%
Reset()100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/FlowField/FlowFieldSurveyResult.cs

#LineLine coverage
 1using GridForge.Spatial;
 2using SwiftCollections;
 3using System;
 4
 5namespace Trailblazer.Pathing;
 6
 7/// <summary>
 8/// Represents the result of a flow field survey operation, including the mapping of world voxel indices
 9/// to their associated flow fields and related survey metadata.
 10/// </summary>
 11/// <remarks>
 12/// Use this class to access the flow fields generated by a survey operation, along with information
 13/// about which charts were utilized and the request key associated with the result. The class provides an empty result
 14/// instance for cases where no survey data is available.
 15/// </remarks>
 16public class FlowFieldSurveyResult : SurveyResult
 17{
 18    /// <summary>
 19    /// Gets the collection of flow fields associated with each world voxel index.
 20    /// </summary>
 21    /// <remarks>
 22    /// The returned dictionary maps each unique world voxel index to its corresponding flow field.
 23    /// The property may be null if no flow fields have been initialized or assigned.
 24    /// </remarks>
 25    public SwiftDictionary<WorldVoxelIndex, FlowField>? Fields { get; private set; }
 26
 27    internal FlowFieldSamplingGrid[] SamplingGrids { get; private set; } = Array.Empty<FlowFieldSamplingGrid>();
 28
 29    /// <inheritdoc/>
 188130    public override bool HasPath => IsValid && Fields != null && Fields.Count > 0;
 31
 32    /// <summary>
 33    /// Represents an empty result for a flow field survey operation.
 34    /// </summary>
 35    /// <remarks>
 36    /// Use this field to represent a default or uninitialized survey result when no data is available.
 37    /// </remarks>
 138    public static readonly FlowFieldSurveyResult Empty = new();
 39
 25440    private FlowFieldSurveyResult() { }
 41
 42    /// <summary>
 43    /// Creates a new instance of the FlowFieldSurveyResult class using the specified flow fields, utilized charts, and 
 44    /// </summary>
 45    /// <param name="context">The world context that owns the survey result.</param>
 46    /// <param name="fields">A dictionary mapping world voxel indices to their corresponding flow fields. Cannot be null
 47    /// <param name="chartsUtilized">An array of chart identifiers that were utilized during the survey. If null, an emp
 48    /// <param name="key">A unique integer key representing the request associated with this survey result.</param>
 49    /// <returns>A FlowFieldSurveyResult instance initialized with the provided flow fields, charts, and request key.</r
 50    public static FlowFieldSurveyResult Create(
 51        TrailblazerWorldContext context,
 52        SwiftDictionary<WorldVoxelIndex, FlowField> fields,
 53        string[] chartsUtilized,
 54        int key)
 55    {
 456        PathRequestContextResolver.ThrowIfUnusable(context);
 457        return Create(
 458            context,
 459            fields,
 460            chartsUtilized,
 461            key,
 462            Array.Empty<FlowFieldSamplingGrid>());
 63    }
 64
 65    internal static FlowFieldSurveyResult Create(
 66        TrailblazerWorldContext context,
 67        SwiftDictionary<WorldVoxelIndex, FlowField> fields,
 68        string[] chartsUtilized,
 69        int key,
 70        FlowFieldSamplingGrid[] samplingGrids)
 71    {
 12672        return new FlowFieldSurveyResult()
 12673        {
 12674            IsValid = true,
 12675            IsInUse = false,
 12676            Context = context,
 12677            ChartsUtilized = chartsUtilized ?? Array.Empty<string>(),
 12678            Fields = fields,
 12679            SamplingGrids = samplingGrids ?? Array.Empty<FlowFieldSamplingGrid>(),
 12680            LastUsedFrame = -1,
 12681            RequestHashKey = key
 12682        };
 83    }
 84
 85    /// <inheritdoc/>
 86    public override void Reset()
 87    {
 2288        base.Reset();
 2289        Fields = null;
 2290        SamplingGrids = Array.Empty<FlowFieldSamplingGrid>();
 2291    }
 92}