Programming
Fundamentals
Setting Up Development Environment
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes

Level Class

Warning
Game Framework is deprecated and no longer supported. We can't guarantee the stable work of the framework.

The level logic base class.

The Level class implementation can be found in the data/framework/game/level.h file.

Level Class

Members


void getEntities(string type = "", Entity ret[])

Selects the specified entities from all of the level entities.

Arguments

  • string type = "" - Name of the entities class. If type is an empty string, all of the entities types are added to the pool.
  • Entity ret[] - An array, to which the entities will be placed to.

void getEntities(string type = "", int childs = 1, Entity ret[])

Selects the specified entities from all of the level entities.

Arguments

  • string type = "" - Name of the entities class. If type is an empty string, all of the entities types are added to the pool.
  • int childs - A flag indicating if the entity class children are added to the array.
  • Entity ret[] - An array, to which the entities will be placed to.

Entity getEntity(variable index)

Returns an entity by its index.

Arguments

  • variable index - Entity index if index is an integer; entity name if index is a string.

Return value

Entity if exists; otherwise NULL.

void setEntityEnabled(Entity entity, int mode)

Toggles an entity.

Arguments

  • Entity entity - Entity.
  • int mode - 1 to enable an entity; 0 to disable it.

void setEntityEventEnabled(Entity entity, int event, int mode)

Toggles a call of the entity special function.

Arguments

  • Entity entity - Entity.
  • int event - One of the ENTITY_EVENT_* values.
  • int mode - 1 to enable a call of the function, which is specified by the ENTITY_EVENT_* value;0 to disable it.

void setEntityUpadeOrder(Entity entity, int order)

Sets an update order for the entity.

Arguments

  • Entity entity - Entity.
  • int order - Update order. This argument can take on the values from 0 to 16. The default is 8.

int isEvent(string name)

Returns a value indicating if an event with a specified name exists.

Arguments

  • string name - Event name.

Return value

1 if an event exists; otherwise 0.

void setEventEnabled(string name, int mode)

Sets a value indicating if an event enabled or disabled.

Arguments

  • string name - Event name.
  • int mode - 1 to enable an event; 0 to disable it.

int isEventEnabled(string name)

Returns a value indicating if an event is enabled.

Arguments

  • string name - Event name.

Return value

1 if the event is enabled; otherwise 0.

Game getGame()

Returns the game, to which the level belongs to.

Return value

Game.

void getIntersectionNodesEntity(variable bound, variable type, int childs = 1, int filter, Entity ret[])

Searches for the entities among the nodes within the specified area. Depending on the variable passed as the argument, the specified area can be either a box, sphere or frustum.
Notice
A root node of the node reference, to which an entity is binded, must have a surface_base property to get an intersection and to be returned.

Arguments

  • variable bound - Variable of one of the following types:
    • BoundBox - The instance of the BoundBox class.
    • BoundSphere - The instance of the BoundBox class.
    • BoundFrustum - The instance of the BoundBox class.
  • variable type - Variable of one of the following types:
    • string - The name of the entities class.
    • int - The ID of the entities class.
    Notice
    If the argument value is empty, all of the entities types will be added to the pool.
  • int childs - A flag indicating if the entity class children are added to the array.
  • int filter - Node type filter (one of the NODE_* variables), -1 not to use a filter.
  • Entity ret[] - An array, to which the entities will be placed to.

void getIntersectionObjectsEntity(variable bound, variable type, int childs = 1, Entity ret[])

Searches for the entities among the objects within the specified area. Depending on the variable passed as the argument, the specified area can be either a box, sphere or frustum.
Notice
A root node of the node reference, to which an entity is binded, must have a surface_base property to get an intersection and to be returned.

Arguments

  • variable bound - Variable of one of the following types:
    • BoundBox - The instance of the BoundBox class.
    • BoundSphere - The instance of the BoundBox class.
    • BoundFrustum - The instance of the BoundBox class.
  • variable type - Variable of one of the following types:
    • string - The name of the entities class.
    • int - The ID of the entities class.
    Notice
    If the argument value is empty, all of the entities types will be added to the pool.
  • int childs = 1 - A flag indicating if the entity class children are added to the array.
  • Entity ret[] - An array, to which the entities will be placed to.

string getName()

Returns a level name.

Return value

Level name.

int getNumEntities()

Returns a number of entities.

Return value

Number of entities.

void setPeriodicUpdate(variable instanse, string function, int frequency, int priority, variable arg0 = 0, variable arg1 = 0, variable arg2 = 0, variable arg3 = 0)

Sets the periodic update for the function.

Arguments

  • variable instanse - User class instance, for which the function is called. If the function is static, pass the NULL value.
  • string function - Function name.
  • int frequency - Frequency of the function call. The frequency takes on the values from 1 to 60.
  • int priority - Priority of the function call.
  • variable arg0 - Function argument, optional.
  • variable arg1 - Function argument, optional.
  • variable arg2 - Function argument, optional.
  • variable arg3 - Function argument, optional.

void appendEntity(Entity entity)

Appends an entity to the entity list.

Arguments

  • Entity entity - Entity to append.

void callEvent(string name)

Calls an event.

Arguments

  • string name - Event name.

void callEvent(string name, variable bound)

Calls the event within the specified area. Depending on the variable passed as the argument, the specified area can be either a box, sphere or frustum.
Notice
Entities, subscribed to the event, must have a surface_base property to get an intersection and to be called.

Arguments

  • string name - Event name.
  • variable bound - Variable of one of the following types:
    • BoundBox - The instance of the BoundBox class.
    • BoundSphere - The instance of the BoundBox class.
    • BoundFrustum - The instance of the BoundBox class.

Entity createEntity(string type, string name = "")

Creates an entity of a specified type. This function checks presence of the entity of the specified type in the pool and returns such entity if exists; otherwise the function creates the new entity and loads a new node reference, which corresponds to the new entity class.

Arguments

  • string type - Entity type.
  • string name = "" - Entity name, optional.

Return value

Entity.

void createEvent(string name)

Creates an event.

Arguments

  • string name - Unique event name.

void flush()

Updates a level physics.

void init(Game game, LevelData data)

Initializes a framework level. Creates entities, which are placed in the world.

Arguments

  • Game game - Game, to which the Level belongs to.
  • LevelData data - Level data.

Level()

Constructor. Creates a new Level class instance.

void onFlush()

Virtual method, which is called after the entity physics update. This method is empty by default.

void onInit()

Virtual method, which is called after the level initialization. This method is empty by default.

void onPostUpdate()

Virtual method, which is called after the entity update. This method is empty by default.

void onPreUpdate()

Virtual method, which is called before the entity update. This method is empty by default.

void onRender()

Virtual method, which is called after the render() call.

void onShutdown()

Virtual method, which is called after the level resources release. In this method, you need to unsubscribe from the events and remove the periodic update of the functions. This method is empty by default.

void onWarm()

Virtual method, which is called before the entities creation. This method is empty by default.

void removeEntity(Entity entity, int mode = 0)

Deletes an entity by using one of the deleting options.

Arguments

void removeEvent(string name)

Removes an event.

Arguments

  • string name - Unique event name.

void removePeriodicUpdate(variable instanse, string function, int num_ = 0)

Removes the periodic update of the function.

Arguments

  • variable instanse - User class instance, for which the function is called. If the function is static, pass the NULL value.
  • string function - Function name.
  • int num_ - Number of function arguments.

void render()

The render is called after the update() function. At first, the onRender() function is called for entities, and then the onRender() function of the level is called.

void shutdown()

Releases level resources.

void subscribe(string name, variable instanse, string function, variable arg0 = 0, variable arg1 = 0, variable arg2 = 0, variable arg3 = 0)

Subscribes a function to an event.

Arguments

  • string name - Event name.
  • variable instanse - User class instance, for which the function is called. If the function is static, pass the NULL value.
  • string function - Name of the function that is called when the event occurs.
  • variable arg0 - Function argument, optional.
  • variable arg1 - Function argument, optional.
  • variable arg2 - Function argument, optional.
  • variable arg3 - Function argument, optional.

void unsubscribe(string name, variable instanse, string function, int num_args = 0)

Unsubscribes a function from an event.

Arguments

  • string name - Event name.
  • variable instanse - User class instance, for which the function is called. If the function is static, pass the NULL value.
  • string function - Name of the function that is called when the event occurs.
  • int num_args - Number of function arguments.

void update()

Updates a level.

int ENTITY_EVENT_FLUSH

Description

Represents the onFlush() function.

int ENTITY_EVENT_RENDER

Description

Represents the onRender() function.

int ENTITY_EVENT_UPDATE

Description

Represents the onUpdate() function.

int REMOVE_ENTITY_MODE_DEFAULT

Description

Deletes an entity, but not a node reference.

int REMOVE_ENTITY_MODE_DELETE_NODE

Description

Deletes an entity and a node reference.

int REMOVE_ENTITY_MODE_POOL

Description

Adds an entity and a node reference to the pool. The pool provides an ability to create new entities faster: if the entity is in the pool, there is no need to create the node reference from the file, because it is already in the pool.
Last update: 2017-07-03