@page entitymanager Entity Manager
An Entity, U4DEngine::U4DEntity, is a base root object from which all game objects derive their properties.
Game characters, images, buttons, skyboxes, camera inherit their properties and behaviors from the U4DEntity parent class.
The U4DEntity object provides its subclasses with Transformation Properties. That is, it provides translations and rotation properties. It also provides two important virtual methods, that can be overwritten, if necessary.
These methods are:
The render() method is in charge of rendering the entity on the screen. Whereas, the update() can be used to update the properties of the entity.
One of the many responsibilities of a game engine is to manage the number of entities in a game efficiently.
The algorithm a game engine uses to manage entities affects the flow of a game. A brute-force algorithm will create bottlenecks and affect gameplay, even if a game only has five characters. An efficient algorithm, however, will be able to handle several dozen characters without slowing down the game.
To efficiently store and manage game entities, game engines implement a Data-Structure known as a Scenegraph. A scenegraph is a tree-like structure that has an efficient traversal property. Meaning that a game engine can traverse several dozen game entities without affecting gameplay.
An Entity Manager, U4DEngine::U4DEntityManager, manages a scenegraph. When a game character is created, the Entity Manager adds the entity into the scenegraph. In contrast, when a character is destroyed, the Entity Manager removes the entity from the scenegraph. An Entity Manager also has the responsibility of supplying entities to the Game Engine Loop.
Both, the Entity Manager and Game Engine Loop work together. During a game tick, the Entity Manager traverses the scenegraph and provides game entities to the Game Engine Loop. The Game Engine Loop then renders and updates each object.