EntityManager

EntityManager

Main handler of all entities in the world.

Constructor

new EntityManager()

Members

by

Entity selector. Its methods return an EntitySelection. Can select by id or name, see examples for usage.

Injected into World.

Example
var byId = sumerianRunner.world.by.id("2b88941938444da8afab8205b1c80616.entity").first();
var byName = sumerianRunner.world.by.name("Box").first();

Methods

addAdditionListener(listener)

Adds a listener that's called when an entity is added to the world.

Parameters:
Name Type Description
listener function

The listener to add.

addAttributeListener(attributeName, listener)

Adds a listener that's called when an attribute is added to or removed from an entity.

Parameters:
Name Type Description
attributeName string

The attribute to track.

listener function

The function to call.

addHierarchyChangeListener(listener)

Adds a listener that's called when the entity hierarchy changes.

Parameters:
Name Type Description
listener function

The listener to add.

addNameChangeListener(listener)

Adds a listener that's called when an entity's name changes.

Parameters:
Name Type Description
listener function

The listener to add.

addRemovalListener(listener)

Adds a listener that's called when an entity is removed from the world.

Parameters:
Name Type Description
listener function

The listener to add.

addTagListener(tag, listener)

Adds a listener that's called when a tag is added to or removed from an entity.

Parameters:
Name Type Description
tag string

The tag to track.

listener function

The function to call.

attributeAdded(attributeName, entity)

Called by an entity when an attribute is added to it.

Parameters:
Name Type Description
attributeName String

The attribute that was added.

entity Entity

The entity to which the attribute was added.

attributeRemoved(attributeName, entity)

Called by an entity when an attribute is removed from it.

Parameters:
Name Type Description
attributeName String

The attribute that was removed.

entity Entity

The entity from which the attribute was removed.

clear()

Removes all entities

clearListeners()

Clears all listeners for tag and attribute updates.

containsEntity(entity) → {boolean}

Checks if an entity exists

Parameters:
Name Type Description
entity

Entity to check for

getEntities() → {Array}

Get all entities in the world

getEntityById(id)

Retrieve an entity based on an id

Parameters:
Name Type Description
id

Id to retrieve entity for

getEntityByIndex(index)

Retrieve an entity based on an index

Parameters:
Name Type Description
index

Index to retrieve entity for

getEntityByName(name)

Retrieve an entity based on its name

Parameters:
Name Type Description
name

Name to retrieve entity for

getTopEntities() → {Array}

Get all entities on top level based on the transform scenegraph

hierarchyChanged()

Called when the entity hierarchy changes.

nameChanged(entity)

Called by an entity when its name changes.

Parameters:
Name Type Description
entity Entity

The entity whose name changed.

removeAdditionListener(listener)

Removes a previously added addition listener.

Parameters:
Name Type Description
listener function

The listener to remove.

removeAttributeListener(attributeName, listener)

Removes a previously added listener.

Parameters:
Name Type Description
attributeName string

The attribute for which the listener was registered.

listener function

The listener.

removeHierarchyChangeListener(listener)

Removes a previously added hierarchy change listener.

Parameters:
Name Type Description
listener function

The listener to remove.

removeNameChangeListener(listener)

Removes a previously added name change listener.

Parameters:
Name Type Description
listener function

The listener to remove.

removeRemovalListener(listener)

Removes a previously added removal listener.

Parameters:
Name Type Description
listener function

The listener to remove.

removeTagListener(tag, listener)

Removes a previously added listener.

Parameters:
Name Type Description
tag string

The tag for which the listener was registered.

listener function

The listener.

size() → {number}

Get the number of entities currently indexed by the Entity Manager

tagAdded(tag, entity)

Called by an entity when a tag is added to it.

Parameters:
Name Type Description
tag String

The tag that was added.

entity Entity

The entity to which the tag was added.

tagRemoved(tag, entity)

Called by an entity when a tag is removed from it.

Parameters:
Name Type Description
tag String

The tag that was removed.

entity Entity

The entity from which the tag was removed.