Class: Entity
Defined in: ecs/entity.ts:10
Represents an entity in the Entity-Component-System (ECS) architecture. An entity is a container for components and has a unique identifier.
Constructors
Constructor
new Entity(
name
,world
,initialComponents
,enabled
):Entity
Defined in: ecs/entity.ts:47
Creates a new Entity instance.
Parameters
name
string
The name of the entity.
world
initialComponents
The initial components to associate with the entity.
enabled
boolean
= true
Indicates whether the entity is enabled. Defaults to true.
Returns
Entity
Properties
enabled
enabled:
boolean
Defined in: ecs/entity.ts:19
Indicates whether the entity is enabled.
name
name:
string
Defined in: ecs/entity.ts:14
The name of the entity.
world
world:
World
Defined in: ecs/entity.ts:24
The world to which this entity belongs.
Accessors
id
Get Signature
get id():
number
Defined in: ecs/entity.ts:71
Gets the unique identifier of the entity.
Returns
number
Methods
addComponent()
addComponent(
component
):void
Defined in: ecs/entity.ts:79
Adds a component to the entity.
Parameters
component
The component to add.
Returns
void
containsAllComponents()
containsAllComponents(
query
):boolean
Defined in: ecs/entity.ts:89
Checks if the entity contains all specified components.
Parameters
query
The symbols of the components to check.
Returns
boolean
True if the entity contains all specified components, otherwise false.
getComponent()
getComponent<
T
>(componentName
):OrNull
<T
>
Defined in: ecs/entity.ts:118
Gets a component by its name.
Type Parameters
T
T
extends Component
Parameters
componentName
symbol
The name of the component to get.
Returns
OrNull
<T
>
The component if found, otherwise null.
getComponentRequired()
getComponentRequired<
T
>(componentName
):T
Defined in: ecs/entity.ts:134
Gets a component by its name.
Type Parameters
T
T
extends Component
Parameters
componentName
symbol
The name of the component to get.
Returns
T
The component if found.
Throws
An error if the component is not found.
removeComponent()
removeComponent(
componentName
):void
Defined in: ecs/entity.ts:150
Removes a component from the entity.
Parameters
componentName
symbol
The name of the component to remove.
Returns
void