Interface IFinder
Common Finder functionality. This can be used if you need interoperability between different finders and their results.
Namespace: AnyPath.Managed
Assembly: AnyPath.dll
Syntax
public interface IFinder
Examples
public class IFinderExample
{
class BaseTarget
{
}
class DerivedTarget : BaseTarget
{
}
public void Test()
{
HexGridPathFinder pathFinderA = new HexGridPathFinder();
HexGridFirstTargetFinder<BaseTarget> pathFinderB = new HexGridFirstTargetFinder<BaseTarget>();
HexGridCheapestTargetFinder<DerivedTarget> pathFinderC = new HexGridCheapestTargetFinder<DerivedTarget>();
pathFinderA.Completed += OnCompletedWithoutTarget;
pathFinderB.Completed += OnCompletedWithoutTarget;
pathFinderC.Completed += OnCompletedWithoutTarget;
pathFinderB.Completed += OnCompletedWithTarget;
pathFinderC.Completed += OnCompletedWithTarget;
}
private void OnCompletedWithoutTarget(IFinder<HexGrid, Path<HexGridEdge>> obj)
{
// compatible with A, B and C
}
private void OnCompletedWithTarget(IFinder<HexGrid, IPath<BaseTarget, HexGridEdge>> obj)
{
// using IPath with BaseTarget as the resut type makes this handler accept paths coming from both B and C
}
}
Properties
IsCompleted
Indicates if the finder's last request was completed.
Declaration
bool IsCompleted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsMutable
Indicates if the values of this request can be modified. Once a request is sent, it becomes immutable until Clear() is called.
Declaration
bool IsMutable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Clear(ClearFinderFlags)
Clear this finder allowing for a new request to be made.
Declaration
void Clear(ClearFinderFlags flags = ClearFinderFlags.ClearAll)
Parameters
| Type | Name | Description |
|---|---|---|
| ClearFinderFlags | flags | Flags that can be used to preserve certain settings on this finder |
Remarks
If the previous request was not completed yet, that request will be aborted.
Run()
Runs this finder's request immediately on the main thread.
Declaration
void Run()
Exceptions
| Type | Condition |
|---|---|
| ImmutableFinderException | This property can not be modified when the request is in flight |
Schedule()
Schedules this finder using Unity's Job System.
Declaration
IEnumerator Schedule()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator which can be used to suspend a coroutine while waiting for the result |
Exceptions
| Type | Condition |
|---|---|
| ImmutableFinderException | This property can not be modified when the request is in flight |