Shared
A system that divides the map into smaller 2D cells. Entries in a cell can be added, removed, and listed.
GridEntry Class
A table representing a grid entry with the following properties.
- coords:
vector - length?:
number - width?:
number - radius?:
number
lib.grid.getCellPosition
Returns the position of the cell at the given point.
lib.grid.getCellPosition(point)- point:
vector
Returns:
- x:
number - y:
number
lib.grid.getCell
Returns all entries in the cell that belongs to the point.
lib.grid.getCell(point)- point:
vector
Returns:
- entries:
GridEntry[]
lib.grid.getNearbyEntries
Returns all entries near the point with an optional filter
lib.grid.getNearbyEntries(point, filter)- point:
vector - filter:
function(entry: GridEntry): boolean
Returns:
- entries:
Array<GridEntry>
lib.grid.addEntry
Adds an entry to the grid
lib.grid.addEntry(entry)- entry:
GridEntry
lib.grid.removeEntry
Removes and entry that was previously added to the grid
lib.grid.removeEntry(entry)- entry:
GridEntry
Returns:
- success:
boolean