#include <Entity.h>
Description
Basic interactive object.
Entity s are the main classes that are extended to meet abstractions for your multimedia project. In conjunction with functionality you write in the OnStep(), OnDraw(), etc. virtual functions, you can dynamically extend Entity s using Component s and attaching them as you see fit.
Entity::ID s may also be used. Entity::ID s allow you to safely work with references of Entities. Using Entity::ID::Valid() calls can also safely and reliable tell you whether an Entity is still accessible.
Entity s are also inherently hierarchical. By Attach()ing other Entity s, you can create trees of self-managed Entities.
Data Structures | |
class | ID |
Public Types | |
enum | UpdateClass { Before, After } |
Functions | |
const std::vector< Entity::ID > & | GetChildren () const |
std::vector< Entity::ID > | GetAllSubEntities () const |
bool | Contains (Entity::ID) |
std::vector< Entity::ID > | FindChildByName (const std::string &) |
void | Step () |
void | Draw () |
void | Attach (Entity::ID) |
void | Detach (Entity::ID) |
template<typename T > | |
T * | CreateChild () |
int | GetNumChildren () |
double | StepDuration () |
double | DrawDuration () |
void | SetPriority (Priority p) |
void | SetPriorityLast () |
void | SetPriorityFirst () |
Priority | GetPriority () |
Entity & | GetParent () |
bool | HasParent () |
void | Remove () |
void | SetName (const std::string &name) |
ID | GetID () |
std::string | GetName () |
Variable control | |
When debugging, it is often convenient to view the value of something while the program runs normally. This interface allows you to connect specific values to be viewed in the Debugger. | |
void | Watch (Variable v) |
Variable | GetWatched (const std::string &name) |
std::vector< Variable > | GetWatchedVars () |
void | Unwatch (const std::string &varName) |
Component Control | |
Components offer additional standard sets of functionality that extend the capabilities of the Entity it is attached to. | |
template<typename T > | |
T * | AddComponent (UpdateClass when=UpdateClass::Before) |
template<typename T > | |
T * | QueryComponent () |
const std::vector< Component * > & | GetComponents () const |
void | RemoveComponent (const std::string &tag) |
void | RemoveComponent (const Component *) |
Static Functions | |
template<typename T > | |
static Entity::ID | Create () |
static Entity::ID | Create () |
template<typename T > | |
static T * | CreateReference () |
static std::vector< Entity::ID > | GetAll () |
Protected Member Functions | |
Base Functionality | |
virtual void | OnEnter () |
virtual void | OnDepart () |
virtual void | OnRemove () |
virtual void | OnPreStep () |
virtual void | OnStep () |
virtual void | OnPreDraw () |
virtual void | OnDraw () |
Update Handling | |
When using the Engine, Entities are utomatically updated based on your specified framerate. However, it is useful at times to control when you update the Entity manually. | |
bool | step |
bool | draw |
bool | IsStepping () |
bool | IsDrawing () |
Member Enumeration Documentation
|
strong |
Member Function Documentation
const std::vector<Entity::ID>& GetChildren | ( | ) | const |
Returns the i'th Entity starting at 0.
Entities are ordered by priority, where the first entity is guaranteed to be the one with the lowest Priority value. If unsuccessful, the EntityID will be invalid.
std::vector<Entity::ID> GetAllSubEntities | ( | ) | const |
Returns all Entities that are within this Entity's hierarchy.
bool Contains | ( | Entity::ID | ) |
std::vector<Entity::ID> FindChildByName | ( | const std::string & | ) |
void Step | ( | ) |
Updates all attached Entities.
void Draw | ( | ) |
Draws all attached Entities.
void Attach | ( | Entity::ID | ) |
Binds an entity to the World. If bound, an Entity will be updated when the World is updated.
void Detach | ( | Entity::ID | ) |
Unbinds an Entity.
|
inline |
Allocates an Entity and Attaches it for you.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Creates a new Entity of the given type.
int GetNumChildren | ( | ) |
Returns number of active Entities.
double StepDuration | ( | ) |
Returns the last recorded amount of milliseconds it took the Entity, iedentified by id, to complete its run cycle. A run cycle consists of the Entities Run function and any attached components' run.
double DrawDuration | ( | ) |
Returns the last recorded amount of milliseconds it took the Entity, iedentified by id, to complete its draw cycle. A draw cycle consists of the Entities Draw function and any attached components' draw.
void Watch | ( | Variable | v | ) |
Allows you to monitor a Variable through the debugger.
- Parameters
-
v The variable to watch.
Variable GetWatched | ( | const std::string & | name | ) |
void Unwatch | ( | const std::string & | varName | ) |
Stops watching a variable of the given name.
- Parameters
-
varName The variable to stop watching.
void SetPriority | ( | Priority | p | ) |
Alters the priority of this entity.
Priorty determines the order in which this entity is updated. A lower priority means it will be drawn and updated earlier. It is undefined which entity is updated first if both have the same priority.
- Parameters
-
p The new priority.
void SetPriorityLast | ( | ) |
Sends the entity of the ID to be the last of in line for drawing and updates.
void SetPriorityFirst | ( | ) |
Sends the entity to be drawn and updated as the last in the queue causing it to be on top when drawing.
Priority GetPriority | ( | ) |
Returns the priority of the this entity.
bool IsStepping | ( | ) |
bool IsDrawing | ( | ) |
Entity& GetParent | ( | ) |
bool HasParent | ( | ) |
Returns whether or not the Entity belongs to a world.
|
inline |
Attaches a component to this entity.
Once attached, the component's Step and Draw functions will be called before this entity's Run and Draw.
- Parameters
-
when When to step and draw this component in relation to the hosts own step/draw. The default is "before"
T * QueryComponent | ( | ) |
Returns whether or not there is currently an attached component of the type given.
If there is, a reference to the first one is returned. If not, nullptr is returned.
const std::vector<Component *>& GetComponents | ( | ) | const |
Returns all components that belong to the Entity.
void RemoveComponent | ( | const std::string & | tag | ) |
Removes the first occurrance of a component with the tag given.
No action is taken on the data associated with the component.
- Parameters
-
tag The tag that identifies the component to remove.
void RemoveComponent | ( | const Component * | ) |
Removes the attached component with the given pointer.
void Remove | ( | ) |
Detaches and marks this entity for deletion. After this is called, all references to.
void SetName | ( | const std::string & | name | ) |
ID GetID | ( | ) |
std::string GetName | ( | ) |
Returns the name identifier of the Entity.
|
static |
Returns a list of all Entitys. Note that this list is generated every time.
|
inlineprotectedvirtual |
The Entry function is called upon each attachment to a world.
On the first attachment, Init is called before Enter.
|
inlineprotectedvirtual |
The Depart function is called upon each detachment from a world.
|
inlineprotectedvirtual |
The Destruct function is called just before removal of the object.
It should be used like a destructor to free and resources associated with the entity.
|
inlineprotectedvirtual |
Called when Step() is called.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
Called when Draw() is called.
|
inlineprotectedvirtual |
Called when Draw() is called.
Reimplemented in ParticleEmitter2D, and InputBox.
Field Documentation
bool step |
bool draw |
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Entity.h