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

Singleton registry that owns and updates all game objects. More...

#include <object_manager.hpp>

Collaboration diagram for cangine::ObjectManager:
Collaboration graph
[legend]

Public Member Functions

 ObjectManager ()
 Constructs the object manager.
 
 ~ObjectManager ()
 Destroys the object manager.
 
void registerObject (GameObject *obj)
 Registers a game object for updates and event delivery.
 
void updateAll ()
 Updates every registered game object for the current frame.
 
void fireMouseEvent (const MouseEvent *event)
 Forwards a mouse event to all registered objects.
 

Static Public Member Functions

static ObjectManager * getInstance ()
 Returns the singleton instance.
 

Private Attributes

std::vector< GameObject * > objects
 All registered game objects.
 
Window * win
 Window the manager is associated with.
 

Static Private Attributes

static ObjectManager * instance = nullptr
 Singleton instance.
 

Detailed Description

Singleton registry that owns and updates all game objects.

Tracks every registered GameObject, updates them each frame and forwards mouse events to them.

Constructor & Destructor Documentation

◆ ObjectManager()

cangine::ObjectManager::ObjectManager ( )

Constructs the object manager.

◆ ~ObjectManager()

cangine::ObjectManager::~ObjectManager ( )

Destroys the object manager.

Member Function Documentation

◆ fireMouseEvent()

void cangine::ObjectManager::fireMouseEvent ( const MouseEvent *  event)

Forwards a mouse event to all registered objects.

Parameters
eventMouse event to dispatch.

◆ getInstance()

ObjectManager * cangine::ObjectManager::getInstance ( )
static

Returns the singleton instance.

Returns
Pointer to the ObjectManager instance.

◆ registerObject()

void cangine::ObjectManager::registerObject ( GameObject *  obj)

Registers a game object for updates and event delivery.

Parameters
objObject to register.

◆ updateAll()

void cangine::ObjectManager::updateAll ( )

Updates every registered game object for the current frame.

Member Data Documentation

◆ instance

ObjectManager * cangine::ObjectManager::instance = nullptr
staticprivate

Singleton instance.

◆ objects

std::vector<GameObject*> cangine::ObjectManager::objects
private

All registered game objects.

◆ win

Window* cangine::ObjectManager::win
private

Window the manager is associated with.


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