hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
214 lines (97 loc) • 2.93 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [EntityManager](./server.entitymanager.md)
## EntityManager class
Manages entities in a world.
**Signature:**
```typescript
export default class EntityManager
```
## Remarks
The EntityManager is created internally as a singleton for each [World](./server.world.md) 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
```typescript
// Get all entities in the world
const entityManager = world.entityManager;
const entities = entityManager.getAllEntities();
```
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[entityCount](./server.entitymanager.entitycount.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The number of spawned entities in the world.
</td></tr>
<tr><td>
[world](./server.entitymanager.world.md)
</td><td>
`readonly`
</td><td>
[World](./server.world.md)
</td><td>
The world the entity manager is for.
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[getAllEntities()](./server.entitymanager.getallentities.md)
</td><td>
</td><td>
Gets all spawned entities in the world.
</td></tr>
<tr><td>
[getAllPlayerEntities()](./server.entitymanager.getallplayerentities.md)
</td><td>
</td><td>
Gets all spawned player entities in the world.
</td></tr>
<tr><td>
[getEntitiesByTag(tag)](./server.entitymanager.getentitiesbytag.md)
</td><td>
</td><td>
Gets all spawned entities in the world with a specific tag.
</td></tr>
<tr><td>
[getEntitiesByTagSubstring(tagSubstring)](./server.entitymanager.getentitiesbytagsubstring.md)
</td><td>
</td><td>
Gets all spawned entities in the world with a tag that includes a specific substring.
</td></tr>
<tr><td>
[getEntity(id)](./server.entitymanager.getentity.md)
</td><td>
</td><td>
Gets a spawned entity in the world by its id.
</td></tr>
<tr><td>
[getEntityChildren(entity)](./server.entitymanager.getentitychildren.md)
</td><td>
</td><td>
Gets all child entities of an entity.
</td></tr>
<tr><td>
[getPlayerEntitiesByPlayer(player)](./server.entitymanager.getplayerentitiesbyplayer.md)
</td><td>
</td><td>
Gets all spawned entities in the world assigned to the provided player.
</td></tr>
</tbody></table>