Dungeon Architect  17.0.0
SharpNav.Collections.Generic.ProximityGrid< T > Class Template Reference

A ProximityGrid<T> is a uniform 2d grid that can efficiently retrieve items near a specified grid cell. More...

Public Member Functions

 ProximityGrid (int poolSize, float cellSize)
 Initializes a new instance of the ProximityGrid<T> class. More...
 
void Clear ()
 Reset all the data More...
 
void AddItem (T value, float minX, float minY, float maxX, float maxY)
 Take all the coordinates within a certain range and add them all to an array More...
 
int QueryItems (float minX, float minY, float maxX, float maxY, T[] values, int maxVals)
 Take all the items within a certain range and add their ids to an array. More...
 
int GetItemCountAtLocation (int x, int y)
 Gets the number of items at a specific location. More...
 

Static Public Member Functions

static int HashPos2 (int x, int y, int n)
 Hash function More...
 

Detailed Description

A ProximityGrid<T> is a uniform 2d grid that can efficiently retrieve items near a specified grid cell.

Template Parameters
TAn equatable type.
Type Constraints
T :IEquatable<T> 

Definition at line 21 of file ProximityGrid.cs.

Constructor & Destructor Documentation

◆ ProximityGrid()

SharpNav.Collections.Generic.ProximityGrid< T >.ProximityGrid ( int  poolSize,
float  cellSize 
)

Initializes a new instance of the ProximityGrid<T> class.

Parameters
poolSizeThe size of the item array
cellSizeThe size of each cell

Definition at line 47 of file ProximityGrid.cs.

Member Function Documentation

◆ AddItem()

void SharpNav.Collections.Generic.ProximityGrid< T >.AddItem ( value,
float  minX,
float  minY,
float  maxX,
float  maxY 
)

Take all the coordinates within a certain range and add them all to an array

Parameters
valueThe value.
minXMinimum x-coordinate
minYMinimum y-coordinate
maxXMaximum x-coordinate
maxYMaximum y-coordinate

Definition at line 91 of file ProximityGrid.cs.

◆ Clear()

Reset all the data

Definition at line 73 of file ProximityGrid.cs.

◆ GetItemCountAtLocation()

int SharpNav.Collections.Generic.ProximityGrid< T >.GetItemCountAtLocation ( int  x,
int  y 
)

Gets the number of items at a specific location.

Parameters
xThe X coordinate.
yThe Y coordinate.
Returns
The number of items at the specified coordinates.

Definition at line 180 of file ProximityGrid.cs.

◆ HashPos2()

static int SharpNav.Collections.Generic.ProximityGrid< T >.HashPos2 ( int  x,
int  y,
int  n 
)
static

Hash function

Parameters
xThe x-coordinate
yThe y-coordinate
nTotal size of hash table
Returns
A hash value

Definition at line 204 of file ProximityGrid.cs.

◆ QueryItems()

int SharpNav.Collections.Generic.ProximityGrid< T >.QueryItems ( float  minX,
float  minY,
float  maxX,
float  maxY,
T[]  values,
int  maxVals 
)

Take all the items within a certain range and add their ids to an array.

Parameters
minXThe minimum x-coordinate
minYThe minimum y-coordinate
maxXThe maximum x-coordinate
maxYThe maximum y-coordinate
valuesThe array of values
maxValsThe maximum number of values that can be stored
Returns
The number of unique values

Definition at line 132 of file ProximityGrid.cs.


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