GameWorld

GameWorld

This class implements a singleton game world instance, created by Lance. It represents an instance of the game world, and includes all the game objects. It is the state of the game.

Constructor

new GameWorld()

Constructor of the World instance. Invoked by Lance on startup.

Source:

Methods

forEachObject(callback)

World object iterator. Invoke callback(objId, obj) for each object

Parameters:
Name Type Description
callback function

function receives id and object. If callback returns false, the iteration will cease

Source:

queryObject(query) → {Object}

Returns The first game object encountered which matches a criteria. Syntactic sugar for queryObjects with returnSingle: true

Parameters:
Name Type Description
query Object

See queryObjects

Source:
Returns:

The game object, if found

Type
Object

queryObjects(query) → {Array|Object}

Returns all the game world objects which match a criteria

Parameters:
Name Type Description
query Object

The query object

Properties
Name Type Attributes Description
id Object <optional>

object id

playerId Object <optional>

player id

instanceType Class <optional>

matches whether object instanceof instanceType

components Array <optional>

An array of component names

returnSingle Boolean <optional>

Return the first object matched

Source:
Returns:

All game objects which match all the query parameters, or the first match if returnSingle was specified

Type
Array | Object