Nymph Game Engine
Chaiscript based Game Engine
|
Base Class for all components. More...
#include <component.h>
Public Member Functions | |
Component () | |
Component constructor. More... | |
virtual void | onStart ()=0 |
Called when the engine starts and when a new scene is loaded. More... | |
virtual bool | onUpdate (const double delta)=0 |
Called every engine loop. More... | |
virtual void | onDestroy ()=0 |
Called when the engine is shutting down. More... | |
void | setTransform (std::shared_ptr< Transform > transform) |
Sets the transform. More... | |
std::shared_ptr< Transform > | getTransform () const noexcept |
Gets the transform. More... | |
void | setActive (const bool active) noexcept |
Sets the component active or inactive. More... | |
bool | isActive () const noexcept |
Determines if active. More... | |
unsigned int | getId () const noexcept |
Gets the identifier. More... | |
virtual std::string | to_string () const noexcept |
Returns a string representation of the object. More... | |
virtual std::string | className () const noexcept |
Returns a string representing the class name. More... | |
virtual unsigned long long | getValueForSorting () const =0 |
Gets the value for sorting. More... | |
bool | operator< (Component &other) noexcept |
Operator < using getValueForSorting. More... | |
virtual void | onNotifyNow (std::shared_ptr< Events::Event > event) override |
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More... | |
virtual void | handleQueuedEvent (std::shared_ptr< Events::Event > event) override |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More... | |
virtual void | log (el::base::type::ostream_t &os) const override |
virtual | ~Component () |
Destroys the object. More... | |
Public Member Functions inherited from Events::Subject | |
virtual | ~Subject ()=default |
virtual void | notify (std::shared_ptr< Event > event) |
notify is used to tell observers of an event. More... | |
virtual void | notifyNow (std::shared_ptr< Event > event) |
notifyNow is used to tell observers of an event as an interrupt. More... | |
virtual void | addObserver (std::shared_ptr< Observer > observer) |
Adds an observer. More... | |
virtual void | removeObserver (std::shared_ptr< Observer > observer) |
Removes an observer. More... | |
Public Member Functions inherited from Events::Observer | |
virtual | ~Observer () |
void | onNotify (std::shared_ptr< Event > event) |
When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More... | |
void | processEventQueue () |
This should be called once ever loop for every Observer to properly use queued events. More... | |
Protected Attributes | |
std::weak_ptr< Entity > | entity |
std::shared_ptr< Transform > | transform |
bool | active |
unsigned int | id |
Static Protected Attributes | |
static unsigned int | next_id = 0 |
Friends | |
class | ComponentManager |
class | Entity |
Additional Inherited Members | |
Protected Member Functions inherited from Events::Observer | |
std::shared_ptr< Event > | getEvent () |
bool | eventsWaiting () const noexcept |
Base Class for all components.
|
inlinevirtual |
Destroys the object.
|
virtualnoexcept |
Returns a string representing the class name.
Reimplemented in Game::SpriteMovement, Graphics::Renderable, Graphics::Light, Graphics::Camera, Graphics::UI::Element, Graphics::TileAnimator< StateType >, Graphics::UI::Text, Graphics::UI::TextArea, Graphics::UI::WrappableText, Graphics::UI::TextField, Graphics::UI::Button, Graphics::UI::Area, and Graphics::UI::QuitButton.
Referenced by generated::getComponentModule(), and to_string().
|
noexcept |
Gets the identifier.
References id.
Referenced by generated::getComponentModule(), Graphics::Camera::getValueForSorting(), Graphics::Light::getValueForSorting(), Graphics::TileAnimator< StateType >::getValueForSorting(), Game::SpriteMovement::getValueForSorting(), and to_string().
|
noexcept |
Gets the transform.
References transform.
Referenced by Graphics::UI::Element::Element(), generated::getComponentModule(), Graphics::UI::Text::getValueForSorting(), Graphics::UI::Element::getValueForSorting(), Graphics::Renderable::getValueForSorting(), Graphics::Camera::handleQueuedEvent(), Graphics::Light::influenceOnComponent(), Graphics::Camera::isComponentWithin(), Graphics::Light::log(), Graphics::Camera::onStart(), Graphics::UI::TextField::onStart(), Game::SpriteMovement::onStart(), Graphics::Camera::onUpdate(), Graphics::UI::Text::onUpdate(), Graphics::Renderable::onUpdate(), Graphics::UI::Text::renderCharacter(), Engine::setup(), Game::SpriteMovement::SpriteMovement(), Graphics::UI::TextArea::TextArea(), and to_string().
|
pure virtual |
Gets the value for sorting.
Implemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::Light, Graphics::Camera, Graphics::UI::Element, Graphics::UI::Text, Sound::SoundInstance, and Physics::CollisionData.
Referenced by to_string().
|
overridevirtual |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.
[in] | event | The event |
Implements Events::Observer.
Reimplemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::Camera, Graphics::UI::Element, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, Graphics::UI::Button, and Sound::SoundInstance.
References entity, Events::SET_ACTIVE, Events::SET_ENTITY_ACTIVE, and setActive().
Referenced by Graphics::UI::Text::handleQueuedEvent(), Graphics::Camera::handleQueuedEvent(), Graphics::TileAnimator< StateType >::handleQueuedEvent(), Graphics::Renderable::handleQueuedEvent(), Game::SpriteMovement::handleQueuedEvent(), and onNotifyNow().
|
noexcept |
Determines if active.
References active.
Referenced by generated::getComponentModule(), Graphics::UI::Element::handleQueuedEvent(), Graphics::UI::TextField::onKeyDown(), Graphics::UI::WrappableText::onUpdate(), Graphics::UI::Text::onUpdate(), Graphics::Renderable::onUpdate(), and to_string().
|
overridevirtual |
Reimplemented in Game::SpriteMovement, Graphics::TileAnimator< StateType >, Graphics::Renderable, Graphics::UI::Element, Graphics::Camera, Graphics::Light, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, Graphics::UI::Button, and Physics::CollisionData.
References to_string().
Referenced by Graphics::Camera::log(), and Graphics::TileAnimator< StateType >::log().
|
pure virtual |
Called when the engine is shutting down.
Implemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::UI::Element, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextField, Graphics::UI::TextArea, Graphics::Camera, Graphics::UI::Area, Graphics::Light, Sound::SoundInstance, and Physics::CollisionData.
|
overridevirtual |
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.
[in] | event | The event |
Implements Events::Observer.
Reimplemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::Camera, Graphics::UI::Element, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, Graphics::UI::Button, and Sound::SoundInstance.
References handleQueuedEvent().
|
pure virtual |
Called when the engine starts and when a new scene is loaded.
Implemented in Game::SpriteMovement, Graphics::Renderable, Graphics::UI::Element, Graphics::TileAnimator< StateType >, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextField, Graphics::UI::TextArea, Graphics::Camera, Graphics::UI::Area, Graphics::Light, Sound::SoundInstance, and Physics::CollisionData.
|
pure virtual |
Called every engine loop.
[in] | delta | The delta |
Implemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::UI::Element, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextField, Graphics::UI::TextArea, Graphics::Camera, Graphics::UI::Area, Graphics::Light, Sound::SoundInstance, and Physics::CollisionData.
|
noexcept |
Operator < using getValueForSorting.
other | The other |
|
noexcept |
Sets the component active or inactive.
[in] | active | True if active |
Referenced by generated::getComponentModule(), handleQueuedEvent(), and Graphics::UI::TextField::onKeyDown().
void Component::setTransform | ( | std::shared_ptr< Transform > | transform | ) |
Sets the transform.
[in] | transform | The transform |
References transform.
Referenced by generated::getComponentModule().
|
virtualnoexcept |
Returns a string representation of the object.
Reimplemented in Game::SpriteMovement, Graphics::Renderable, Graphics::UI::Element, Graphics::UI::Text, Graphics::UI::TextArea, Graphics::UI::WrappableText, Graphics::UI::TextField, Graphics::UI::Area, and Physics::CollisionData.
References className(), getId(), getTransform(), getValueForSorting(), and isActive().
Referenced by generated::getComponentModule(), log(), Graphics::UI::Text::to_string(), Graphics::Renderable::to_string(), and Game::SpriteMovement::to_string().
|
friend |
|
friend |
|
protected |
|
protected |
Referenced by handleQueuedEvent().
|
protected |
Referenced by getId().
|
staticprotected |
Referenced by Component().
|
protected |
Referenced by Component(), getTransform(), Graphics::UI::WrappableText::onUpdate(), and setTransform().