cangine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
cangine::IComponent Class Reference

Base interface for all components attached to a GameObject. More...

#include <component.hpp>

Inheritance diagram for cangine::IComponent:
Inheritance graph
[legend]
Collaboration diagram for cangine::IComponent:
Collaboration graph
[legend]

Public Member Functions

 IComponent (GameObject *gameObject=nullptr)
 Constructs the component, optionally bound to a game object.
 
virtual ~IComponent ()
 
GameObject * getGameObject () const
 Returns the game object this component is attached to.
 
virtual void firstFrame ()
 Called once before the first frame update.
 
virtual void frame (double deltaTime)
 Called every frame to update the component.
 
virtual void onMouseEvent (const MouseEvent *e)
 Called when a mouse event is dispatched to the owning object.
 

Public Attributes

bool isUnique = true
 If true, only one of this component type may exist per object.
 

Private Attributes

GameObject * gameObject
 Owning game object.
 

Friends

class GameObject
 

Detailed Description

Base interface for all components attached to a GameObject.

Components implement behavior via lifecycle hooks: firstFrame is called once before the first update, frame is called every frame, and onMouseEvent receives mouse input. Derived components override the hooks they need.

Constructor & Destructor Documentation

◆ IComponent()

cangine::IComponent::IComponent ( GameObject *  gameObject = nullptr)

Constructs the component, optionally bound to a game object.

Parameters
gameObjectOwning game object, or nullptr if unset.

◆ ~IComponent()

cangine::IComponent::~IComponent ( )
virtualdefault

Member Function Documentation

◆ firstFrame()

virtual void cangine::IComponent::firstFrame ( )
inlinevirtual

◆ frame()

virtual void cangine::IComponent::frame ( double  deltaTime)
inlinevirtual

Called every frame to update the component.

Parameters
deltaTimeSeconds elapsed since the previous frame.

Reimplemented in cangine::PanelComponent, cangine::QuadRendererComponent, cangine::TextRendererComponent, and cangine::InputFieldComponent.

◆ getGameObject()

GameObject * cangine::IComponent::getGameObject ( ) const

Returns the game object this component is attached to.

Returns
Owning game object, or nullptr.

◆ onMouseEvent()

virtual void cangine::IComponent::onMouseEvent ( const MouseEvent *  e)
inlinevirtual

Called when a mouse event is dispatched to the owning object.

Parameters
eThe mouse event.

Reimplemented in cangine::ButtonComponent, and cangine::InputFieldComponent.

Friends And Related Symbol Documentation

◆ GameObject

friend class GameObject
friend

Member Data Documentation

◆ gameObject

GameObject* cangine::IComponent::gameObject
private

Owning game object.

◆ isUnique

bool cangine::IComponent::isUnique = true

If true, only one of this component type may exist per object.


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