• Articles
  • Api Documentation
Show / Hide Table of Contents
  • AnyPath
    • Graphs
      • Extra
        • Line2D
        • Line3D
        • Triangle
      • HexGrid
        • HexGrid
        • HexGrid.Enumerator
        • HexGridCell
        • HexGridHeuristicProvider
        • HexGridType
      • Line
        • ClosestLineLocationPredicate
        • LineGraph
        • LineGraph.Edge
        • LineGraph.Enumerator
        • LineGraphBuilder
        • LineGraphBuilder.ProtoEdge
        • LineGraphDrawer
        • LineGraphHeuristic
        • LineGraphLocation
        • LineGraphPopulator
        • LineGraphProcessor
        • LineGraphWelder
        • SceneGraph
          • LineGraphNode
          • LineSceneGraph
          • LineSceneGraphEdge
          • SceneGraphNodeEditor
      • NavMesh
        • ClosestNavMeshLocationPredicate
        • CornerAndNormal
        • IUnrolledNavMeshGraphPortal
        • NavMeshGraph
        • NavMeshGraph.EnterCostAndFlags
        • NavMeshGraph.Enumerator
        • NavMeshGraphCorners
        • NavMeshGraphCorners3D
        • NavMeshGraphHeuristic
        • NavMeshGraphLocation
        • NavMeshGraphUnroller
        • NavMeshLineBitmaskMod
        • NavMeshLineMod
        • NavMeshPlaneBitmaskMod
        • NavMeshPlaneMod
        • NavMeshPopulator
        • NavMeshWelder
        • SSFA
        • UnrolledNavMeshGraphPortal
      • Node
        • NodeGraph
        • NodeGraphNode
      • PlatformerGraph
        • ClosestPlatformerGraphLocationPredicate
        • PlatformerGraph
        • PlatformerGraph.Enumerator
        • PlatformerGraphBuilder
        • PlatformerGraphBuilder.ProtoEdge
        • PlatformerGraphDrawer
        • PlatformerGraphHeuristic
        • PlatformerGraphLocation
        • PlatformerGraphPopulator
        • PlatformerGraphProcessor
        • PlatformerGraphWelder
        • SceneGraph
          • PlatformerSceneGraph
          • PlatformerSceneGraphEdge
          • PlatformerSceneGraphNode
          • SceneGraphNodeEditor
      • SquareGrid
        • SquareGrid
        • SquareGrid.Enumerator
        • SquareGridCell
        • SquareGridHeuristicProvider
        • SquareGridHeuristicProviderEightDirectional
        • SquareGridHeuristicProviderManhattanDistance
        • SquareGridType
      • VoxelGrid
        • VoxelGrid
        • VoxelGrid.DirCost
        • VoxelGrid.Enumerator
        • VoxelGridCell
        • VoxelGridDirectionFlags
        • VoxelGridDirectionMod
        • VoxelGridHeuristicProvider
        • VoxelGridHeuristicProviderManhattanDistance
    • Managed
      • ClearFinderFlags
      • FinderExtensions
      • IFinder
      • IOptionReserver<TOption>
      • IOptionValidator<TOption>
      • ImmutableFinderException
      • ManagedDisposeExtensions
      • Results
        • DijkstraResult<TNode>
        • Eval
        • Eval<TOption>
        • MultiEvalResult
        • MultiPathResult<TSeg>
        • Path<TSeg>
        • Path<TOption, TSeg>
    • Native
      • AStarCheapestOption
      • AStarEvalOptionResult
      • AStarEvalResult
      • AStarFindOptionResult
      • AStarFindPathResult
      • AStarOption
      • AStarStops
      • AStar<TNode>
      • ComposedGraph<TGraph, TNode>
      • Edge<TNode>
      • FlagBitmask<TNode>
      • IEdgeMod<TNode>
      • IGraph<TNode>
      • IHeuristicProvider<TNode>
      • INodeFlags
      • IPathProcessor<TNode, TSeg>
      • NativeListWrapper<TSeg>
      • NoEdgeMod<TNode>
      • NoProcessing<TNode>
      • OffsetInfo
      • ReversedGraph<TNode>
      • EdgeMods
        • AdditionalAndExcludeEdges<TNode>
        • AdditionalEdges<TNode>
        • ExcludeEdges<TNode>
        • ExcludeLocations<TNode>
      • Heuristics
        • ALTCompute<TGraph, TNode>
        • ALTSerialization
        • ALT<TNode>
        • LandmarkSelection<TGraph, TNode, TEnumerator>
      • Util
        • IRefComparer<T>
        • NativeMinHeap<T, TComp>
        • NativeRefMinHeap<T, TComp>

Struct HexGrid

A simple hexagonal grid structure that can be used for pathfinding queries. Each cell can have an additional cost and flags associated with it.

Implements
IGraph<HexGridCell>
IDisposable
Namespace: AnyPath.Graphs.HexGrid
Assembly: AnyPath.dll
Syntax
public struct HexGrid : IGraph<HexGridCell>, IDisposable
Remarks

The cells are stored in a hash map, which is more memory efficient for sparse grids. For raw performance, this grid can be easily modified to using an array instead.

Constructors

HexGrid(int2, int2, IReadOnlyList<HexGridCell>, Allocator, HexGridType)

Constructs a new hexagonal grid.

Declaration
public HexGrid(int2 min, int2 max, IReadOnlyList<HexGridCell> cells, Allocator allocator, HexGridType type = HexGridType.OddR)
Parameters
Type Name Description
int2 min

Boundary min

int2 max

Boundary max

IReadOnlyList<HexGridCell> cells

A list containing all cells that need to be set and the cost associated with them. Use a cost of PositiveInfinity to make a cell unwalkable. Locations that are ommitted in the array will be considered as open.

Allocator allocator
HexGridType type

Type of hexgrid

HexGrid(int2, int2, Allocator, HexGridType)

Constructs a new hexagonal grid.

Declaration
public HexGrid(int2 min, int2 max, Allocator allocator, HexGridType type = HexGridType.OddR)
Parameters
Type Name Description
int2 min

Boundary min

int2 max

Boundary max

Allocator allocator
HexGridType type

Type of hexgrid

Fields

gridType

Type of hexgrid

Declaration
public readonly HexGridType gridType
Field Value
Type Description
HexGridType

max

The boundary -max- position

Declaration
public readonly int2 max
Field Value
Type Description
int2

min

The boundary -min- position

Declaration
public readonly int2 min
Field Value
Type Description
int2

Methods

Collect(HexGridCell, ref NativeList<Edge<HexGridCell>>)

Collects all neighbouring cells from a given location

Declaration
public void Collect(HexGridCell node, ref NativeList<Edge<HexGridCell>> edgeBuffer)
Parameters
Type Name Description
HexGridCell node

The location to find the neighbours for

NativeList<Edge<HexGridCell>> edgeBuffer

GetCell(int2)

Returns the cell at a given position.

Declaration
public HexGridCell GetCell(int2 position)
Parameters
Type Name Description
int2 position
Returns
Type Description
HexGridCell

GetEnumerator()

Enumerates all of the cells in the grid, including unset ones. This can be used for constructing ALT heuristics.

Declaration
public HexGrid.Enumerator GetEnumerator()
Returns
Type Description
HexGrid.Enumerator

GetSetCells(Allocator)

Allocates an array containing all of the cells that are set on this grid.

Declaration
public NativeArray<HexGridCell> GetSetCells(Allocator allocator)
Parameters
Type Name Description
Allocator allocator
Returns
Type Description
NativeArray<HexGridCell>

InBounds(int2)

Returns wether a certain position is within the bounds of the grid

Declaration
public bool InBounds(int2 position)
Parameters
Type Name Description
int2 position
Returns
Type Description
bool

IsOpen(int2)

Returns wether a cell at a position is open/walkable.

Declaration
public bool IsOpen(int2 position)
Parameters
Type Name Description
int2 position
Returns
Type Description
bool

SetCell(int2, float, int)

Sets the cost for a cell.

Declaration
public void SetCell(int2 position, float enterCost, int flags = 0)
Parameters
Type Name Description
int2 position

Position to set

float enterCost

Additional cost for walking this cell. Use float.PositiveInfinity to make this cell unwalkable

int flags

Flags for this cell, this can be used in conjunction with FlagBitmask<TNode> to exclude certain areas.

Remarks

No bounds checking is done on the position

Implements

IGraph<TNode>
IDisposable

Extension Methods

FinderExtensions.AddOption<T, TNode, TOption>(T, TOption, TNode, TNode)
FinderExtensions.AddOptions<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRange<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRequest<T, TNode>(T, TNode, TNode)
FinderExtensions.AddRequests<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.AddStop<T, TNode>(T, TNode)
FinderExtensions.AddStops<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.SetComparer<T, TOption>(T, IComparer<TOption>)
FinderExtensions.SetEdgeMod<T, TMod>(T, TMod)
FinderExtensions.SetGraph<T, TGraph>(T, TGraph)
FinderExtensions.SetHeuristicProvider<T, TH>(T, TH)
FinderExtensions.SetPathProcessor<T, TProc>(T, TProc)
FinderExtensions.SetReserver<T, TOption>(T, IOptionReserver<TOption>)
FinderExtensions.SetStartAndGoal<T, TNode>(T, TNode, TNode)
FinderExtensions.SetValidator<T, TOption>(T, IOptionValidator<TOption>)
ManagedDisposeExtensions.DisposeGraph<TGraph>(TGraph)
In This Article
Back to top Generated by DocFX