Manages a collection of entities and their hierarchical relationships. More...
#include <Scene.h>
Public Member Functions | |
| Scene (std::string name="Unnamed") | |
| Constructs a new Scene with an optional name. | |
| virtual | ~Scene () |
| Destructor. | |
| EntityID | create_entity (const std::string &name="GameObject") |
| Creates a new entity in the scene. | |
| void | destroy_entity (EntityID id) |
| Destroys an entity and removes it from the scene. | |
| Entity * | get_entity (EntityID id) |
| Retrieves an entity by its ID. | |
| const Entity * | get_entity (EntityID id) const |
| Retrieves an entity by its ID (const version) | |
| bool | is_descendant (EntityID potential_descendant, EntityID potential_ancestor) |
| Checks if one entity is a descendant of another. | |
| void | set_parent (EntityID child_id, EntityID parent_id) |
| Sets the parent of an entity. | |
| void | set_as_root (EntityID entity_id) |
| Makes an entity a root entity (removes parent) | |
| EntityID | get_parent (EntityID entity_id) const |
| Gets the parent ID of an entity. | |
| bool | has_parent (EntityID entity_id) const |
| Checks if an entity has a parent. | |
| std::vector< EntityID > | get_children (EntityID parent_id) const |
| Gets all children of a parent entity. | |
| const std::vector< EntityID > & | get_root_entities () const |
| Gets all root entities in the scene. | |
| virtual void | initialize () |
| Initializes the scene Called once when the scene is first loaded or created. | |
| virtual void | update (float delta_time) |
| Updates all entities in the scene. | |
| void | update_world_matrices () |
| Updates world transformation matrices for all entities Propagates transformations through the entity hierarchy. | |
| Entity * | find_entity_by_name (const std::string &name) |
| Finds an entity by its name. | |
| template<typename T > | |
| std::vector< EntityID > | find_entities_with_component () |
| Finds all entities that have a specific component type. | |
| void | set_default_camera (EntityID camera_id) |
| Sets the default camera for the scene. | |
| EntityID | get_default_camera_entity_id () const |
| CameraComponent * | get_default_camera () const |
| std::vector< EntityID > | get_camera_entities () const |
| size_t | get_entity_count () const |
| const std::string & | get_name () const |
| void | set_name (const std::string &name) |
| bool | is_playing () const |
| void | set_playing (bool active) |
| void | set_source_filename (const std::filesystem::path &filename) |
| const std::filesystem::path & | get_source_filename () const |
| bool | was_loaded_from_file () const |
| std::string | generate_unique_name (const std::string &base_name) |
| void | save () |
| SceneEnvironment * | environment () const |
| std::unordered_map< EntityID, std::unique_ptr< Entity > > & | get_all_entities () |
Private Member Functions | |
| void | update_hierarchy (EntityID entity_id, float delta_time) |
| void | update_world_matrices_recursive (unsigned int entity_id, const glm::mat4 &parent_world) |
| void | find_entities_recursive (EntityID entity_id, const std::function< bool(Entity *)> &predicate, std::vector< EntityID > &results) |
Private Attributes | |
| std::unordered_map< EntityID, std::unique_ptr< Entity > > | entities_ |
| std::unordered_map< EntityID, EntityID > | parent_map_ |
| std::unordered_map< EntityID, std::vector< EntityID > > | children_map_ |
| std::vector< EntityID > | root_entities_ |
| EntityID | next_id_ = 1 |
| EntityID | default_camera_entity_id_ = 0 |
| std::string | name_ |
| bool | is_playing_ |
| std::filesystem::path | source_filename_ |
| std::unordered_map< std::string, int > | name_counters_ |
| std::unique_ptr< SceneEnvironment > | environment_ |
Manages a collection of entities and their hierarchical relationships.
The Scene class represents a complete game scene containing entities, their parent-child relationships, cameras, and environmental settings. It handles entity lifecycle, hierarchy management, and scene updates.
| hellfire::Scene::Scene | ( | std::string | name = "Unnamed" | ) |
| EntityID hellfire::Scene::create_entity | ( | const std::string & | name = "GameObject" | ) |
| void hellfire::Scene::destroy_entity | ( | EntityID | id | ) |
|
inline |
| std::vector< EntityID > hellfire::Scene::find_entities_with_component | ( | ) |
| Entity * hellfire::Scene::find_entity_by_name | ( | const std::string & | name | ) |
| std::string hellfire::Scene::generate_unique_name | ( | const std::string & | base_name | ) |
| std::vector< EntityID > hellfire::Scene::get_camera_entities | ( | ) | const |
| CameraComponent * hellfire::Scene::get_default_camera | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
| bool hellfire::Scene::has_parent | ( | EntityID | entity_id | ) | const |
|
virtual |
| void hellfire::Scene::set_as_root | ( | EntityID | entity_id | ) |
| void hellfire::Scene::set_default_camera | ( | EntityID | camera_id | ) |
|
inline |
|
inline |
|
virtual |
|
private |
| void hellfire::Scene::update_world_matrices | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |