Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Doloro.Graphs.Path Class Reference

Detailed Description

Base logic of the navigation path between two points.

Inheritance diagram for Doloro.Graphs.Path:
Collaboration diagram for Doloro.Graphs.Path:

Public Types

enum  State {
  NotComputed , Built , Failed , Relayed ,
  InProgress
}
 

Public Member Functions

 Path (GraphNode from, GraphNode to)
 
 Path (bool isCached, IList< GraphNode > nodes)
 Creates path with predefined way points. More...
 
 Path (bool isCached, params GraphNode[] nodes)
 Creates path with predefined way points. More...
 
virtual ICollection< GraphNodeBuild ()
 Looks for cached Path if not overridden. More...
 
virtual IEnumerator BuildCoroutine ()
 Handler that should look the path using enumerator. In base implementation looks for cached Path in Coroutine friendly way. More...
 
virtual async Task< ICollection< GraphNode > > BuildAsync ()
 Handler that should look the path asynchronously. In base implementation looks for cached Path in tasks friendly way. More...
 
bool TryLoadCache ()
 Loads path cache to the instance in case if exists. More...
 
void Release ()
 Releasing cached path between two nodes in case if has been built.
 
void MakeFailed ()
 Forces path to has State.Failed state.
 
IEnumerator< GraphNodeGetEnumerator ()
 Enumerated computed path. More...
 

Static Public Member Functions

static void ReleaseCache ()
 Releases entire cache.
 
static bool TryGetCachedPath (GraphNode from, GraphNode to, out Path path)
 Looking for last cached path between two nodes. More...
 
static bool TryGetCachedPath< T > (GraphNode from, GraphNode to, out T path)
 Looking for cached path between two nodes. More...
 
static bool TryGetCachedPath (Type pathType, GraphNode from, GraphNode to, out Path path)
 Looking for cached path between two nodes. More...
 

Static Protected Member Functions

static void SetPathToCache (Path path)
 Updating cache registry with a path entry. More...
 

Properties

static int CachedPathsCount [get]
 Count of paths in cache.
 
ReadOnlyCollection< GraphNodepath [get, protected set]
 Public built path.
 
int Length [get]
 Length of the built path. -1 is not built yet.
 
GraphNode from [get]
 Path start graph's node.
 
GraphNode to [get]
 Path finish graph's node.
 
State state [get, protected set]
 Current state of the path build.
 
bool isComputed [get]
 Is the path has been computed.
 
bool isCached [get]
 Checks is the path located at the cache registry to fast access. More...
 

Events

static Action< PathPathReleased
 Occurs when any path is no longer exists in cache.
 

Member Enumeration Documentation

◆ State

Enumerator
NotComputed 

Path has no been computed yet.

Built 

Pathfinding has been finished with a success.

Failed 

Pathfinding has been failed.

Relayed 

Path build has been skipped due to exist of cached path.

InProgress 

Pathfinding in the process.

Constructor & Destructor Documentation

◆ Path() [1/2]

Doloro.Graphs.Path.Path ( bool  isCached,
IList< GraphNode nodes 
)

Creates path with predefined way points.

Parameters
isCachedIf true then the path will be automatically added to the cache and considered as valid.
nodesPath points collection.
See also
Release

◆ Path() [2/2]

Doloro.Graphs.Path.Path ( bool  isCached,
params GraphNode[]  nodes 
)

Creates path with predefined way points.

Parameters
isCachedIf true then the path will be automatically added to the cache and considered as valid.
nodesPath points collection.
See also
Release

Member Function Documentation

◆ Build()

virtual ICollection< GraphNode > Doloro.Graphs.Path.Build ( )
virtual

Looks for cached Path if not overridden.

Returns
Collection of nodes selected as path root.
Exceptions
NotSupportedExceptionAttempt to navigate between GraphNodes located at different Graphs.

Reimplemented in Doloro.Graphs.AStarPath.

◆ BuildAsync()

virtual async Task< ICollection< GraphNode > > Doloro.Graphs.Path.BuildAsync ( )
virtual

Handler that should look the path asynchronously. In base implementation looks for cached Path in tasks friendly way.

Returns
Task that returns collection of nodes selected as path root.
Exceptions
NotSupportedExceptionAttempt to navigate between GraphNodes located at different Graphs.

Reimplemented in Doloro.Graphs.AStarPath.

◆ BuildCoroutine()

virtual IEnumerator Doloro.Graphs.Path.BuildCoroutine ( )
virtual

Handler that should look the path using enumerator. In base implementation looks for cached Path in Coroutine friendly way.

Returns
Enumerator to result await.
Exceptions
NotSupportedExceptionAttempt to navigate between GraphNodes located at different Graphs.

Reimplemented in Doloro.Graphs.AStarPath.

◆ GetEnumerator()

IEnumerator< GraphNode > Doloro.Graphs.Path.GetEnumerator ( )

Enumerated computed path.

Returns
Enumerator of the path included nodes. Empty collection in case if state is not State.Built or State.Relayed.

◆ SetPathToCache()

static void Doloro.Graphs.Path.SetPathToCache ( Path  path)
staticprotected

Updating cache registry with a path entry.

Parameters
pathPath to set.

Decline caching of garbage paths with the 1 length.

◆ TryGetCachedPath() [1/2]

static bool Doloro.Graphs.Path.TryGetCachedPath ( GraphNode  from,
GraphNode  to,
out Path  path 
)
static

Looking for last cached path between two nodes.

Parameters
fromStart point.
toEnd point
pathPath instance if found.
Returns
Is the instance has been found.

◆ TryGetCachedPath() [2/2]

static bool Doloro.Graphs.Path.TryGetCachedPath ( Type  pathType,
GraphNode  from,
GraphNode  to,
out Path  path 
)
static

Looking for cached path between two nodes.

Parameters
pathTypeType of the path processor.
fromStart point.
toEnd point
pathPath instance if found.
Returns
Is the instance has been found.

◆ TryGetCachedPath< T >()

static bool Doloro.Graphs.Path.TryGetCachedPath< T > ( GraphNode  from,
GraphNode  to,
out T  path 
)
static

Looking for cached path between two nodes.

Template Parameters
TType of the path processor.
Parameters
fromStart point.
toEnd point
pathPath instance if found.
Returns
Is the instance has been found.
Type Constraints
T :Path 

◆ TryLoadCache()

bool Doloro.Graphs.Path.TryLoadCache ( )

Loads path cache to the instance in case if exists.

Returns
Is the cache has been loaded.

Property Documentation

◆ isCached

bool Doloro.Graphs.Path.isCached
get

Checks is the path located at the cache registry to fast access.

See also
Release

The documentation for this class was generated from the following file: