World Class
The world where al entities live
Item Index
Methods
- _getEntityList
- _onCreate
- _onDestroy
- _saveHelper
- addAgents
- addContext
- addEntity
- addGroup
- addPath
- addWall
- agentsInContext
- changesNumber
- freeze
- getAgents
- getContextById
- getContexts
- getDefaultGroup
- getEntitiesIterator
- getEntityById
- getGroups
- getNearAgents
- getNearWalls
- getPathById
- getPaths
- getWalls
- load
- removeAgents
- removeEntity
- save
- step
Methods
_getEntityList
-
entity
Returns the property that holds the entity list, used internally.
Parameters:
-
entity
EntityContext, Group, Wall or Path
_onCreate
-
entity
Callback trigger when an entity is created
Parameters:
-
entity
EntityContext, Group, Wall or Path
_onDestroy
-
entity
Callback trigger when an entity is destroyed
Parameters:
-
entity
EntityContext, Group, Wall or Path
_saveHelper
-
o
Save helper to remove loops and agents from world data.
Parameters:
-
o
Objectthe world.entities property
Returns:
JSON data that represents the world.entities
addEntity
-
entity
Add an entity from the world. Called by entities on constructor.
Parameters:
-
entity
EntityContext, Group, Wall or Path
agentsInContext
-
context
Get the list of agents in a given Context
Parameters:
-
context
Context
Returns:
all entities
changesNumber
()
Number
Gets and resets the number of steps executed since last call
Returns:
changes
freeze
-
freeze
Get/set if the world is not running (Frozen). This is set from the Engine
Parameters:
-
freeze
Boolean
Returns:
true if world is static
getContextById
-
id
Search an context in the world by its id.
Parameters:
-
id
String
Returns:
contexts
getNearAgents
-
agent
Returns the agents near to another. The near property is given in the options constructor parameter
Parameters:
-
agent
Agent
Returns:
agents
getNearWalls
-
agent
Returns the agents near to another.
The near property is given in the options constructor parameter
Parameters:
-
agent
Agent
Returns:
walls
getPathById
-
id
Search an path in the world by its id.
Parameters:
-
id
String
Returns:
paths
load
-
loader
-
loadDefault
Load the world state from a loader.
removeEntity
-
entity
Remove an entity from the world. Called by entities on destroy.
Parameters:
-
entity
EntityContext, Group, Wall or Path
save
-
save
Save the world state without agents.
Parameters:
-
save
Booleantrue to store internally; false to return the JSON data