galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::Scene Class Reference

Represents a scene in a game. More...

#include <Scene.hpp>

+ Inheritance diagram for galaxy::Scene:
+ Collaboration diagram for galaxy::Scene:

Public Member Functions

 Scene (const std::string &name) noexcept
 Name constructor.
 
virtual ~Scene () noexcept
 Destructor.
 
void on_push () override
 When scene is pushed to the stack.
 
void on_pop () override
 When scene is popped from the stack.
 
virtual void on_event (SDL_Event &event)
 Handle an event for a scene.
 
virtual void update (EntityManager &em)
 Process events and updates.
 
virtual void render ()
 Render scene.
 
nlohmann::json serialize ()
 Serializes object.
 
void deserialize (const nlohmann::json &json)
 Deserializes from object.
 
SystemManagersys_man () noexcept
 Get system manager.
 
- Public Member Functions inherited from galaxy::State
 State (State &&)=default
 Move constructor.
 
Stateoperator= (State &&)=default
 Move assignment operator.
 
 State (const State &)=default
 Copy constructor.
 
Stateoperator= (const State &)=default
 Copy assignment operator.
 
virtual ~State ()=default
 Virtual destructor.
 
const std::string & name () const noexcept
 Get state name.
 

Private Member Functions

 Scene ()=delete
 Constructor.
 
 Scene (const Scene &)=delete
 Copy constructor.
 
Sceneoperator= (const Scene &)=delete
 Copy assignment operator.
 

Private Attributes

SystemManager m_sysman
 Systems only used by this scene.
 
entt::dispatcher m_dispatcher
 Scene event handler.
 

Additional Inherited Members

- Protected Member Functions inherited from galaxy::State
 State (const std::string &name) noexcept
 Name constructor.
 
- Protected Attributes inherited from galaxy::State
std::string m_name
 Name for debug purposes.
 

Detailed Description

Represents a scene in a game.

Scenes should be logically grouped -> i.e. a map, player data + ui, battle, menu, etc. Each scene is an independant collection of systems, but not entities.

Definition at line 26 of file Scene.hpp.

Constructor & Destructor Documentation

◆ Scene() [1/3]

galaxy::Scene::Scene ( const std::string & name)
noexcept

Name constructor.

Parameters
nameName of the scene for debug / editor purposes.

Definition at line 27 of file Scene.cpp.

◆ ~Scene()

galaxy::Scene::~Scene ( )
virtualnoexcept

Destructor.

Definition at line 43 of file Scene.cpp.

◆ Scene() [2/3]

galaxy::Scene::Scene ( )
privatedelete

Constructor.

◆ Scene() [3/3]

galaxy::Scene::Scene ( const Scene & )
privatedelete

Copy constructor.

Member Function Documentation

◆ on_push()

void galaxy::Scene::on_push ( )
overridevirtual

When scene is pushed to the stack.

Implements galaxy::State.

Definition at line 47 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ on_pop()

void galaxy::Scene::on_pop ( )
overridevirtual

When scene is popped from the stack.

Implements galaxy::State.

Definition at line 51 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ on_event()

void galaxy::Scene::on_event ( SDL_Event & event)
virtual

Handle an event for a scene.

Parameters
eEvent that was triggered.

Definition at line 59 of file Scene.cpp.

◆ update()

void galaxy::Scene::update ( EntityManager & em)
virtual

Process events and updates.

Parameters
emEntities to process.

Definition at line 254 of file Scene.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

void galaxy::Scene::render ( )
virtual

Render scene.

Definition at line 266 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ serialize()

nlohmann::json galaxy::Scene::serialize ( )
nodiscard

Serializes object.

Returns
JSON object containing data to be serialized.

Definition at line 294 of file Scene.cpp.

◆ deserialize()

void galaxy::Scene::deserialize ( const nlohmann::json & json)

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Definition at line 351 of file Scene.cpp.

◆ sys_man()

SystemManager & galaxy::Scene::sys_man ( )
nodiscardnoexcept

Get system manager.

Returns
Reference to systems for this specfic scene.

Definition at line 412 of file Scene.cpp.

+ Here is the caller graph for this function:

◆ operator=()

Scene & galaxy::Scene::operator= ( const Scene & )
privatedelete

Copy assignment operator.

Member Data Documentation

◆ m_sysman

SystemManager galaxy::Scene::m_sysman
private

Systems only used by this scene.

Definition at line 113 of file Scene.hpp.

◆ m_dispatcher

entt::dispatcher galaxy::Scene::m_dispatcher
private

Scene event handler.

Definition at line 118 of file Scene.hpp.


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