Skip to content

Latest commit

 

History

History
213 lines (97 loc) · 2.86 KB

File metadata and controls

213 lines (97 loc) · 2.86 KB

Home > server > EntityManager

EntityManager class

Manages entities in a world.

Signature:

export default class EntityManager 

Remarks

The EntityManager is created internally as a singleton for each World instance in a game server. It allows retrieval of all entities, player entities, and more.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the EntityManager class.

Example

// Get all entities in the world
const entityManager = world.entityManager;
const entities = entityManager.getAllEntities();

Properties

Property

Modifiers

Type

Description

entityCount

readonly

number

The number of spawned entities in the world.

world

readonly

World

The world the entity manager is for.

Methods

Method

Modifiers

Description

getAllEntities()

Gets all spawned entities in the world.

getAllPlayerEntities()

Gets all spawned player entities in the world.

getEntitiesByTag(tag)

Gets all spawned entities in the world with a specific tag.

getEntitiesByTagSubstring(tagSubstring)

Gets all spawned entities in the world with a tag that includes a specific substring.

getEntity(id)

Gets a spawned entity in the world by its id.

getEntityChildren(entity)

Gets all child entities of an entity.

getPlayerEntitiesByPlayer(player)

Gets all spawned entities in the world assigned to the provided player.