Grid Class
Grid hashmap to store entities indexed by their position.
Constructor
Grid
(
-
near
Parameters:
-
near
Numberis the cell size for the hashmap. Also the maximum distance to be consider "neighbours"
Item Index
Methods
_key
(
String
-
entity
-
x
-
y
Build the key to map coordinates to the hashmap.
Parameters:
Returns:
String:
key
_keyNeighbours
(
Array
-
x
-
y
Builds the keys of the neighbours of the position (x,y).
Returns:
Array:
neighbours keys
clear
()
Clear the hashmap.
insertOne
(
-
entity
-
x
-
y
Insert one entity.
neighbours
(
LazySequence
-
entity
-
x
-
y
Gets neighbours to (x,y) point or Entity.
Parameters:
Returns:
LazySequence:
neighbours
neighboursContext
(
LazySequence
-
context
Gets neighbours to a context by sampling its position with the cell size.
Parameters:
-
context
Context
Returns:
LazySequence:
neighbours
updateContextsHelper
(
-
contexts
Helper to update multiple contexts area points by sampling their area with the cell size.
Parameters:
-
contexts
Array
updateWallsHelper
(
-
walls
Helper to update multiple walls area points by sampling their path with the cell size.
Parameters:
-
walls
Array