|
CoriEngine
|
A handle for the scene, checks for scene validity before any call to the scene, if scene is invalid asserts. Will not keep the scene alive. More...
#include <SceneHandle.hpp>
Public Member Functions | |
| SceneHandle (const std::shared_ptr< Scene > &scene) | |
| Creates a handle for the scene. | |
| Entity | CreateBlankEntity () |
| Creates a blank Entity with no components attached. | |
| template<typename... T> | |
| Entity | CreateEntity (const std::string &name) |
| Creates an Entity with a default set of components. | |
| void | DestroyEntity (Entity entity) |
| Destroys the entity. | |
| std::expected< void, Core::CoriError<> > | AddEntityToCache (Entity entity, const Utility::StringHash32 key) |
| Adds entity to the local scene cache. | |
| std::expected< Entity, Core::CoriError<> > | GetEntityFromCache (const Utility::StringHash32 key) |
| Retries the entity from a scene local entity cache. | |
| void | RemoveEntityFromCache (const Utility::StringHash32 key) |
| Removes an entity from the scene local entity cache. | |
| template<typename... T> | |
| std::expected< Entity, Core::CoriError<> > | FindEntity (const std::string &name) |
| Conducts a scene wide search for the entity with a particular name and optionally a set of components. | |
| template<typename... T> | |
| auto | StaticView () |
| Constructs a view of the entities that have a particular set of components. Variant without component exclusion. | |
| template<typename... T, typename... ExcludeT> | |
| auto | StaticView (Exclude< ExcludeT... > excludeList) |
| Constructs a static view of the entities that have a particular set of components. Variant with component exclusion. | |
| DynamicEntityView | DynamicView () |
| Constructs a dynamic view which can be configured at runtime. | |
| template<typename T, typename... Args> | |
| T & | AddContextComponent (Args &&... args) |
| Adds a component to the scene. | |
| template<typename T> | |
| T & | GetContextComponent () |
| Retries the reference to the requested context component. | |
| template<typename T> | |
| const T & | GetContextComponent () const |
| Retries the reference to the requested context component. Const variant. | |
| template<typename T> | |
| bool | HasContextComponent () const |
| Checks if a scene has a specific context component. | |
| template<typename T> | |
| void | RemoveContextComponent () |
| Removes a context component from the scene. | |
| template<typename T, typename... Args> requires IsSystem<T> | |
| void | RegisterSystem (Args &&... args) |
| Registers the system for the scene. | |
| template<typename T> requires IsSystem<T> | |
| void | UnregisterSystem () |
| Unregisters the system from the scene. | |
| template<typename T> requires IsSystem<T> | |
| std::expected< std::weak_ptr< T >, Core::CoriError<> > | GetSystem () |
| Retries a registered system instance from the scene. | |
| Graphics::CameraController & | GetActiveCamera () |
| Retrieves a reference to the CameraController associated with the current camera. | |
| const Graphics::CameraController & | GetActiveCamera () const |
| Retrieves a const reference to the CameraController associated with the current camera. | |
| std::string_view | GetName () const |
| Retrieves the name of the scene. | |
| entt::registry & | GetRegistry () |
| Retrieves the EnTT registry. | |
| bool | IsValid () const |
| Checks if the scene the handle points to is still valid. | |
Protected Member Functions | |
| void | BeginRender () |
| void | EndRender () |
| void | OnUpdate (Core::GameTimer &gameTimer) |
| void | OnTickUpdate (Core::GameTimer &gameTimer) |
| void | OnImGuiRender (Core::GameTimer &gameTimer) |
| bool | OnUnbind () |
| bool | OnBind () |
A handle for the scene, checks for scene validity before any call to the scene, if scene is invalid asserts. Will not keep the scene alive.
Definition at line 13 of file SceneHandle.hpp.
|
inline |
Creates a handle for the scene.
| scene | Scene to create a handle for. |
Definition at line 19 of file SceneHandle.hpp.
|
inline |
Adds a component to the scene.
| T | Type of component to add. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments passed to the component constructor. |
Definition at line 155 of file SceneHandle.hpp.
|
inline |
Adds entity to the local scene cache.
| entity | Handle of the entity to add to cache. |
| key | 32bit FNV-1a hashed string, you can use ""_hs32 operator to create a compile time hash. The only purpose of a scene local entity cache is to store entities that you plan to access very frequently but don't have a good place on the client side to store the handle. |
Definition at line 64 of file SceneHandle.hpp.
|
inlineprotected |
Definition at line 292 of file SceneHandle.hpp.
|
inlinenodiscard |
Creates a blank Entity with no components attached.
Definition at line 30 of file SceneHandle.hpp.
|
inlinenodiscard |
Creates an Entity with a default set of components.
| name | Name to assign to the Entity. |
| T | Optional set of components or tags that will be added to the entity at creation. |
Unlike Scene::CreateBlankEntity() it is safe to use an Entity created with this method anywhere you like. Default set of components is <Name, Hierarchy, UUID, Transform>.
Definition at line 43 of file SceneHandle.hpp.
|
inline |
Destroys the entity.
| entity | Handle of the entity to destroy. |
Definition at line 52 of file SceneHandle.hpp.
|
inlinenodiscard |
Constructs a dynamic view which can be configured at runtime.
Use this when the exact set of components a view should have is not known at compile time.
Definition at line 136 of file SceneHandle.hpp.
|
inlineprotected |
Definition at line 298 of file SceneHandle.hpp.
|
inlinenodiscard |
Conducts a scene wide search for the entity with a particular name and optionally a set of components.
| name | Name of the entity you're searching for. |
| T | Optional set of components or tags the desired entity should be filtered by. |
Definition at line 97 of file SceneHandle.hpp.
|
inlinenodiscard |
Retrieves a reference to the CameraController associated with the current camera.
Definition at line 246 of file SceneHandle.hpp.
|
inlinenodiscard |
Retrieves a const reference to the CameraController associated with the current camera.
Definition at line 255 of file SceneHandle.hpp.
|
inlinenodiscard |
Retries the reference to the requested context component.
| T | Type of context component to retrieve. |
Definition at line 167 of file SceneHandle.hpp.
|
inlinenodiscard |
Retries the reference to the requested context component. Const variant.
| T | Type of context component to retrieve. |
Definition at line 179 of file SceneHandle.hpp.
|
inlinenodiscard |
Retries the entity from a scene local entity cache.
| key | Key you associated with an entity when adding it via AddEntityToCache method. |
Definition at line 74 of file SceneHandle.hpp.
|
inlinenodiscard |
Retrieves the name of the scene.
Definition at line 264 of file SceneHandle.hpp.
|
inlinenodiscard |
Retrieves the EnTT registry.
For the most part this is needed if your system need some special behaviour/feature (listeners, reactive storage, etc.) from EnTT that I don't have abstraction over.
Making a feature complete wrapper over EnTT is out of the scope of this project.
Definition at line 275 of file SceneHandle.hpp.
|
inlinenodiscard |
Retries a registered system instance from the scene.
| T | System to retrieve. |
Definition at line 237 of file SceneHandle.hpp.
|
inlinenodiscard |
Checks if a scene has a specific context component.
| T | Component type to check. |
Definition at line 190 of file SceneHandle.hpp.
|
inlinenodiscard |
Checks if the scene the handle points to is still valid.
Definition at line 284 of file SceneHandle.hpp.
|
inlinenodiscardprotected |
Definition at line 329 of file SceneHandle.hpp.
|
inlineprotected |
Definition at line 316 of file SceneHandle.hpp.
|
inlineprotected |
Definition at line 310 of file SceneHandle.hpp.
|
inlinenodiscardprotected |
Definition at line 322 of file SceneHandle.hpp.
|
inlineprotected |
Definition at line 304 of file SceneHandle.hpp.
|
inline |
Registers the system for the scene.
| T | System to register. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments that will be passed to Create method of your system class. |
Scene has full control of the system lifetime, the system will be kept alive for as long as the scene is alive, but you can also explicitly unregister the system.
Definition at line 215 of file SceneHandle.hpp.
|
inline |
Removes a context component from the scene.
| T | Context component type to remove. |
Definition at line 201 of file SceneHandle.hpp.
|
inline |
Removes an entity from the scene local entity cache.
| key | Key you associated with an entity when adding it via AddEntityToCache method. |
Definition at line 83 of file SceneHandle.hpp.
|
inlinenodiscard |
Constructs a view of the entities that have a particular set of components. Variant without component exclusion.
| T | A set of components of the entities in the view. |
Example usage: auto view = View<ComponentOne, ComponentTwo>();
This way the view will consist of entities that both have <ComponentOne, ComponentTwo> components.
Definition at line 110 of file SceneHandle.hpp.
|
inlinenodiscard |
Constructs a static view of the entities that have a particular set of components. Variant with component exclusion.
| T | A set of components of the entities in the view. |
| ExcludeT | Component types to exclude from the view. |
| excludeList | Instance of Exclude with ExcludeT components. |
Example usage: auto view = View<ComponentOne, ComponentTwo>(Exclude<FlagOne, FlagTwo>());
This way the view will consist of entities that both have <ComponentOne, ComponentTwo> components, and at the same time don't have either FlagOne or FlagTwo.
Definition at line 125 of file SceneHandle.hpp.
|
inline |
Unregisters the system from the scene.
| T | System to unregister. |
Definition at line 226 of file SceneHandle.hpp.