-
Notifications
You must be signed in to change notification settings - Fork 2
Entity
jsutlive edited this page May 16, 2023
·
14 revisions
extends N/A
implements IBehavior
Entity is a the base class for all simulation objects which receive updates during the physics system. It typically contains references to IRigidbodies (Nodes, Edges, e.g.) which carry out the actions of changing the position of the object.
| Accessibility | Type | Field Name | Description |
|---|---|---|---|
| public | string | name | name of the object as it appears in the inspector |
| private | int | uniqueID | ID of this entity |
| private | List(Component) | components | components that reference this entity and perform tasks during physics loop |
| private | Tag | tag | can be used to identify "special" entities, such as the overall model, etc. |
| public | Entity | parent | returns an entity if this object has physics dependent on another entity, else is null |
| public | List(Entity) | children | returns a list of entities if there are other entities dependent on this object, else is null |
| Accessibility | Return Type | Method Name | Description |
|---|---|---|---|
| public | void | setStateID | sets uniqueID equal to value given as input |
| public | int | getStateID | returns uniqueID |
| public | Tag | getTag | returns a tag if one is assigned, null otherwise |
| public | void | addTag | adds a tag to this entity |
| public | void | destroy | removes object from physics/ render system and performs onDestroy() actions in all components |
| public | Component (T) | addComponent | adds a component to the entity |
| public | Component (T) | getComponent | returns first available component of the requested type |
| public | List(Component) | getComponents | returns all components |
| public | void | removeComponent | remove component from entity |
| Accessibility | Type | Event Name | Description |
|---|---|---|---|
| public, static | Entity | onAddEntity | Invoked when an entity is added to the scene |
| public, static | Entity | onRemoveEntity | Invoked when an entity is removed from the scene |
Entities perform actions by having components attached to them. This method makes code much more legible and makes it easier to isolate problems in the system.
See this tutorial for an example on how to add components to entities in code
When entities are created, they call the static event OnEntityAdded to signal to the state machine that a component has been added to the entity