|
Capycore Engine
0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
|
Represents a scene within the engine. A scene contains multiple GameObjects and manages their lifecycle, including running the game loop, stopping, and destroying the scene. More...
#include <scene.h>
Public Member Functions | |
| virtual | ~Scene () |
| void | on_run (listener_function_t &&listener) |
| Registers a listener function to be called when the scene starts running. | |
| void | on_stop (listener_function_t &&listener) |
| Registers a listener function to be called when the scene stops. | |
| void | on_destroy (listener_function_t &&listener) |
| Registers a listener function to be called when the scene is destroyed. | |
| void | stop () |
| marks the scene to be stopped. | |
| bool | marked_for_stopping () const |
| Checks if the scene is marked for stopping. | |
| void | mark_for_stopping () noexcept |
| Marks the scene to be stopped. | |
| Scene & | time_scale (float modifier) |
| Sets the time scale modifier for the scene. | |
| float | time_scale () const |
| Retrieves the current time scale modifier for the scene. | |
| const std::string & | name () const |
| Retrieves the name of the scene. | |
| bool | is_running () const |
| Checks if the scene is currently running. | |
| std::reference_wrapper< GameObject > | get_game_object (const std::string &id) const |
| Retrieves a GameObject by its unique identifier. | |
| std::vector< std::reference_wrapper< GameObject > > | game_objects () const |
| Retrieves all GameObjects in the scene. | |
| std::vector< std::reference_wrapper< GameObject > > | active_game_objects () const |
| Retrieves all active GameObjects in the scene. | |
| template<typename T , typename... Args> | |
| T & | add_game_object (Args &&... args) |
| Adds a new GameObject of type T to the scene. | |
| GameObject & | add_game_object (const std::string &name) |
| Adds a new GameObject with the given name to the scene. | |
| Scene & | add_game_object (std::unique_ptr< GameObject > game_object) |
| Adds an existing GameObject to the scene. | |
| Scene & | add_game_objects (std::vector< std::unique_ptr< GameObject > > game_objects) |
| Adds multiple existing GameObjects to the scene. | |
| std::unique_ptr< GameObject > | extract_game_object (GameObject &game_object) |
| Extracts a GameObject from the scene without deleting it. | |
| bool | remove_game_object (GameObject &game_object) |
| Removes a GameObject from the scene and deletes it. | |
| void | cleanup_destroyed_game_objects () |
| Cleans up and deletes all GameObjects that are marked for deletion. | |
| std::optional< std::reference_wrapper< Camera > > | main_camera () const |
| Retrieves the main camera of the scene. | |
Friends | |
| class | SceneService |
Represents a scene within the engine. A scene contains multiple GameObjects and manages their lifecycle, including running the game loop, stopping, and destroying the scene.
|
virtual |
| std::vector< std::reference_wrapper< GameObject > > Scene::active_game_objects | ( | ) | const |
Retrieves all active GameObjects in the scene.
|
inline |
Adds a new GameObject of type T to the scene.
| T | The type of the GameObject to add. Must be derived from GameObject |
| args | The arguments to forward to the GameObject's constructor. |
| GameObject & Scene::add_game_object | ( | const std::string & | name | ) |
Adds a new GameObject with the given name to the scene.
| name | The name of the GameObject to add. |
| Scene & Scene::add_game_object | ( | std::unique_ptr< GameObject > | game_object | ) |
Adds an existing GameObject to the scene.
| game_object | The unique pointer to the GameObject to add. |
| Scene & Scene::add_game_objects | ( | std::vector< std::unique_ptr< GameObject > > | game_objects | ) |
Adds multiple existing GameObjects to the scene.
| game_objects | A vector of unique pointers to the GameObjects to add. |
| void Scene::cleanup_destroyed_game_objects | ( | ) |
Cleans up and deletes all GameObjects that are marked for deletion.
| std::unique_ptr< GameObject > Scene::extract_game_object | ( | GameObject & | game_object | ) |
Extracts a GameObject from the scene without deleting it.
| game_object | The GameObject to extract. |
| std::vector< std::reference_wrapper< GameObject > > Scene::game_objects | ( | ) | const |
Retrieves all GameObjects in the scene.
| std::reference_wrapper< GameObject > Scene::get_game_object | ( | const std::string & | id | ) | const |
Retrieves a GameObject by its unique identifier.
| id | The unique identifier of the GameObject. |
| std::runtime_error | if no GameObject with the given ID exists in the scene. |
| bool Scene::is_running | ( | ) | const |
Checks if the scene is currently running.
| std::optional< std::reference_wrapper< Camera > > Scene::main_camera | ( | ) | const |
Retrieves the main camera of the scene.
|
noexcept |
Marks the scene to be stopped.
| bool Scene::marked_for_stopping | ( | ) | const |
Checks if the scene is marked for stopping.
| const std::string & Scene::name | ( | ) | const |
Retrieves the name of the scene.
| void Scene::on_destroy | ( | listener_function_t && | listener | ) |
Registers a listener function to be called when the scene is destroyed.
| listener | The function to be called when the scene is destroyed. |
| void Scene::on_run | ( | listener_function_t && | listener | ) |
Registers a listener function to be called when the scene starts running.
| listener | The function to be called when the scene starts. |
| void Scene::on_stop | ( | listener_function_t && | listener | ) |
Registers a listener function to be called when the scene stops.
| listener | The function to be called when the scene stops. |
| bool Scene::remove_game_object | ( | GameObject & | game_object | ) |
Removes a GameObject from the scene and deletes it.
| game_object | The GameObject to remove. |
| void Scene::stop | ( | ) |
marks the scene to be stopped.
| float Scene::time_scale | ( | ) | const |
Retrieves the current time scale modifier for the scene.
| Scene & Scene::time_scale | ( | float | modifier | ) |
Sets the time scale modifier for the scene.
| modifier | The time scale modifier. A value of 1.0 represents normal time, values greater than 1.0 speed up time, and values less than 1.0 slow down time. |
|
friend |