Skip to content
jsutlive edited this page May 16, 2023 · 14 revisions

Final Class Entity

extends N/A

implements IBehavior

Introduction

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.

Fields

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

Methods

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

Events

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

Entity-Component System

Introduction

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.

Examples

See this tutorial for an example on how to add components to entities in code

Entities and Program State

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

Clone this wiki locally