UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1

Entity Class

The base class for a custom entity. This class provides the quick access to the node.

The Entity class implementation can be found in the data/framework/game/entity.h file.

Entity Class

Members


Entity ()

Constructor. Creates a new Entity class instance.

void init (string name, Level level, NodeReference ref)

Initializes an entity and binds it to a node reference.

Arguments

  • string name - Entity name.
  • Level level - Level, to which an entity belongs to.
  • NodeReference ref - Node reference.

void shutdown ()

Releases entity resources.

void onInit ()

Virtual method, which is called after entity initialization. This method is empty by default. The custom logic of the entity can be implemented here.

void onUpdate ()

Virtual method, which is called on each update().It is empty by default. The custom logic of the entity can be implemented here. Also this method can be disabled if necessary.

void onFlush ()

Virtual method, which is called on each flush(). It is empty by default. The custom logic of the entity can be implemented here. Also this method can be disabled if necessary.

void onRender ()

Virtual method, which is called on each render(). It is empty by default. The custom logic of the entity can be implemented here. Also this method can be disabled if necessary.

void onShutdown ()

Virtual method, which is called after shutdown(). This method is empty by default. The custom logic of the entity can be implemented here.

void setEnabled (int mode)

Toggles an entity and an associated node reference. The setter attribute is [set_toggle: Enabled].

Arguments

  • int mode - 1 to enable an entity and a node reference; 0 to disable.

int isEnabled ()

Returns a value indicating if an entity is enabled. The getter attribute is [get_toggle: Enabled].

Return value

1 if an entity is enabled; otherwise 0.

void setRenderable (int mode)

Toggles the onRender() function call. The setter attribute is [set_toggle: Renderable].

Arguments

  • int mode - 1 to enable the onRender() function call; 0 to disable.

int isRenderable ()

Returns a value indicating if onRender() function is called. The getter attribute is [get_toggle: Renderable].

Return value

1 if the onRender() is called; otherwise 0.

void setFlushable (int mode)

Toggles the onFlush() function call. The setter attribute is [set_toggle: Flushable].

Arguments

  • int mode - 1 to enable the onFlush() function call; 0 to disable.

int isFlushable ()

Returns a value indicating if the onFlush() function is called. The getter attribute is [get_toggle: Flushable].

Return value

1 if the onFlush() function is called; otherwise 0.

void setUpdateable (int mode)

Toggles the onUpdate() function call. The setter attribute is [set_toggle: Updateable].

Arguments

  • int mode - 1 to enable the onUpdate() function call; 0 to disable.

int isUpdateable ()

Returns a value indicating if the onUpdate() function is called. The getter attribute is [get_toggle: Updateable].

Return value

1 if the onUpdate() function is called; otherwise 0.

void setUpdateOrder (int order)

Sets an entity update order. The setter attribute is [set_switch: Update order].

Arguments

  • int order - Update order. It can take on the values from 0 to 16. The default is 8.

int getUpdateOrder ()

Returns an update order value. The getter attribute is [get_switch: Update order:"-8,-7,-6,-5,-4,-3,-2,-1,default,+1,+2,+3,+4,+5,+6,+7,+8":8].

Return value

Update order. The value can be from 0 to 16.

string getName ()

Returns an entity name.

Return value

Entity name.

Level getLevel ()

Returns the current level.

Return value

Current Level.

Game getGame ()

Returns the current game.

Return value

Current game.

NodeReference getNodeReference ()

Returns a node reference associated with an entity (if a node associated with the entity is not a node reference, an assert will be returned).

Return value

Node reference.

Node getRootNode ()

Returns a root node of a node reference, associated with an entity (if a node associated with the entity is not a node reference, an assert will be returned).

Return value

Root node.

Node getNode ()

Returns the node associated with the entity.

Return value

Node; if the node is not found, returns NULL.

Node getNode (string name)

Returns the first occurrence of a node in node reference (or other node) children.

Arguments

  • string name - Node name.

Return value

Node; if the node is not found, returns NULL.

Vec3 getPosition ()

Returns a node reference position.

Return value

Position coordinates of the node reference.

void setPosition (Vec3 pos)

Sets a node reference position.

Arguments

  • Vec3 pos - Position coordinates of the node reference.

Mat4 getTransform ()

Returns the node reference transformation matrix.

Return value

Transformation matrix.

void setTransform (Mat4 t)

Sets the transformation matrix for the node reference.

Arguments

  • Mat4 t - Transformation matrix.

quat getRotation ()

Returns the node reference rotation.

Return value

Node reference rotation in the local space.

void setRotation (quat q)

Sets the node reference rotation.

Arguments

  • quat q - Node reference rotation in the local space.
Last update: 2017-07-03