| | | 1 | | //======================================================================= |
| | | 2 | | // FlowFieldQueryOptions.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | |
| | | 11 | | namespace Trailblazer.Pathing; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Defines immutable options specific to destination-centric flow field queries. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct FlowFieldQueryOptions : IEquatable<FlowFieldQueryOptions> |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets the non-negative additional integration cost applied by the flow query. |
| | | 20 | | /// </summary> |
| | | 21 | | public Fixed64 ExtraIntegrationCost { get; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Creates immutable flow field query options. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <exception cref="ArgumentOutOfRangeException">Thrown when the extra integration cost is negative.</exception> |
| | | 27 | | public FlowFieldQueryOptions(Fixed64 extraIntegrationCost) |
| | | 28 | | { |
| | 738 | 29 | | SwiftThrowHelper.ThrowIfArgumentOutOfRange( |
| | 738 | 30 | | extraIntegrationCost < Fixed64.Zero, |
| | 738 | 31 | | actualValue: null, |
| | 738 | 32 | | nameof(extraIntegrationCost), |
| | 738 | 33 | | "Extra integration cost cannot be negative."); |
| | | 34 | | |
| | 737 | 35 | | ExtraIntegrationCost = extraIntegrationCost; |
| | 737 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <inheritdoc/> |
| | 3805 | 39 | | public bool Equals(FlowFieldQueryOptions other) => ExtraIntegrationCost == other.ExtraIntegrationCost; |
| | | 40 | | |
| | | 41 | | /// <inheritdoc/> |
| | 204 | 42 | | public override bool Equals(object? obj) => obj is FlowFieldQueryOptions other && Equals(other); |
| | | 43 | | |
| | | 44 | | /// <inheritdoc/> |
| | 3372 | 45 | | public override int GetHashCode() => ExtraIntegrationCost.GetHashCode(); |
| | | 46 | | |
| | | 47 | | /// <summary>Returns whether two option values are exactly equal.</summary> |
| | 2420 | 48 | | public static bool operator ==(FlowFieldQueryOptions left, FlowFieldQueryOptions right) => left.Equals(right); |
| | | 49 | | |
| | | 50 | | /// <summary>Returns whether two option values differ.</summary> |
| | 1182 | 51 | | public static bool operator !=(FlowFieldQueryOptions left, FlowFieldQueryOptions right) => !left.Equals(right); |
| | | 52 | | |
| | | 53 | | } |