Class: BaseEntity

BaseEntity(options)

new BaseEntity(options)

Creates a BaseEntity instance.
Parameters:
Name Type Attributes Description
options object
options.id number <optional>
Optional existing entity ID to wrap. If not provided, a new one is created.
Source:

Members

engine

Source:

entityManager

Source:

id :number

Unique ID for this entity within the EntityManager.
Type:
  • number
Source:

Methods

addComponent(componentTypeName, data)

Adds a component to this entity.
Parameters:
Name Type Description
componentTypeName
data
Source:
Returns:

destroy()

Destroys this entity and all its components from the EntityManager.
Source:

emitEvent(eventName, eventDataopt)

Emits an event through the engine's EventManager, if available.
Parameters:
Name Type Attributes Default Description
eventName string The name of the event.
eventData object <optional>
{} Additional data for the event.
Source:

getAllComponents()

Retrieves all components for this entity.
Source:
Returns:

getComponent(componentTypeName)

Retrieves a component from this entity.
Parameters:
Name Type Description
componentTypeName
Source:
Returns:

hasComponent(componentTypeName) → {boolean}

Checks if this entity has a specific component.
Parameters:
Name Type Description
componentTypeName
Source:
Returns:
Type
boolean

removeComponent(componentTypeName) → {boolean}

Removes a component from this entity.
Parameters:
Name Type Description
componentTypeName
Source:
Returns:
Type
boolean