Simple C++ Game
Public Member Functions | List of all members
Entity::Component Class Reference

A component of an entity in the game's component entity system. More...

#include <Entity.hpp>

Inheritance diagram for Entity::Component:
Inheritance graph
[legend]

Public Member Functions

 Component (const std::string id)
 Construct a new Component object. More...
 
virtual ~Component ()
 This is only declared to make the class polymorphic so that dymaic_cast between Component types works.
 
const std::string getId () const
 Get the ID of the component. This will return the same value for all instances of a class of Component.
 

Detailed Description

A component of an entity in the game's component entity system.

Components represent an aspect of an Entity. They store state information, such as position and sprite data, as well as mark the Entity as belong to a certain class of object, like being the player or an AI opponent.

Component types are identified with their ID, which is passed to the constructor. To avoid odd bugs and behavior, all instances of the same Component subclass should have the same ID, which is usually declared as a static member of the class or a preprocessor constant in the header file.

Constructor & Destructor Documentation

◆ Component()

Entity::Component::Component ( const std::string  id)

Construct a new Component object.

Parameters
idThe Component's ID

The documentation for this class was generated from the following file: