19 SceneHandle(
const std::shared_ptr<Scene>& scene) : m_SceneRaw(scene) {}
32 return m_SceneRaw.lock()->CreateBlankEntity();
42 template<
typename... T>
45 return m_SceneRaw.lock()->CreateEntity<T...>(name);
54 m_SceneRaw.lock()->DestroyEntity(entity);
66 return m_SceneRaw.lock()->AddEntityToCache(entity, key);
76 return m_SceneRaw.lock()->GetEntityFromCache(key);
85 m_SceneRaw.lock()->RemoveEntityFromCache(key);
96 template<
typename... T>
97 [[nodiscard]] std::expected<Entity, Core::CoriError<>>
FindEntity(
const std::string& name) {
99 return m_SceneRaw.lock()->FindEntity<T...>(name);
109 template<
typename... T>
112 return m_SceneRaw.lock()->StaticView<T...>();
124 template<
typename... T,
typename... ExcludeT>
127 return m_SceneRaw.lock()->StaticView<T...>(excludeList);
138 return m_SceneRaw.lock()->DynamicView();
154 template<
typename T,
typename... Args>
157 return m_SceneRaw.lock()->AddContextComponent<T>(std::forward<Args>(args)...);
169 return m_SceneRaw.lock()->GetContextComponent<T>();
181 return m_SceneRaw.lock()->GetContextComponent<T>();
192 return m_SceneRaw.lock()->HasContextComponent<T>();
203 m_SceneRaw.lock()->RemoveContextComponent<T>();
214 template <
typename T,
typename... Args>
requires IsSystem<T>
217 m_SceneRaw.lock()->RegisterSystem<T>(std::forward<Args>(args)...);
228 m_SceneRaw.lock()->UnregisterSystem<T>();
239 return m_SceneRaw.lock()->GetSystem<T>();
248 return m_SceneRaw.lock()->GetCameraController();
257 return m_SceneRaw.lock()->GetCameraController();
264 [[nodiscard]] std::string_view
GetName()
const {
266 return m_SceneRaw.lock()->GetName();
277 return m_SceneRaw.lock()->m_Registry;
285 return !m_SceneRaw.expired();
293 if (!m_SceneRaw.expired()) {
294 m_SceneRaw.lock()->BeginRender();
299 if (!m_SceneRaw.expired()) {
300 m_SceneRaw.lock()->EndRender();
305 if (!m_SceneRaw.expired()) {
306 m_SceneRaw.lock()->OnUpdate(gameTimer);
311 if (!m_SceneRaw.expired()) {
312 m_SceneRaw.lock()->OnTickUpdate(gameTimer);
317 if (!m_SceneRaw.expired()) {
318 m_SceneRaw.lock()->OnImGuiRender(gameTimer);
323 if (!m_SceneRaw.expired()) {
324 return m_SceneRaw.lock()->OnUnbind();
330 if (!m_SceneRaw.expired()) {
331 return m_SceneRaw.lock()->OnBind();
337 std::weak_ptr<Scene> m_SceneRaw;
#define CORI_CORE_ASSERT(x,...)
Main Application object, there can only be one Application object. Basically a root of the program.
Custom error class mainly used in std::expected.
A GameTimer is responsible for managing everything that is connected with time, ticks,...
An abstract class that is ment to be used as a template for defining layers.
A class that is used to manipulate Camera of the Scene. Each Scene has one of those.
A wrapper for an EnTT runtime view that provides an iterator to access Entity instances directly.
Entities are the essential part of WorldSystem.
void OnTickUpdate(Core::GameTimer &gameTimer)
std::expected< std::weak_ptr< T >, Core::CoriError<> > GetSystem()
Retries a registered system instance from the scene.
void RegisterSystem(Args &&... args)
Registers the system for the scene.
void OnImGuiRender(Core::GameTimer &gameTimer)
entt::registry & GetRegistry()
Retrieves the EnTT registry.
std::string_view GetName() const
Retrieves the name of the scene.
void RemoveEntityFromCache(const Utility::StringHash32 key)
Removes an entity from the scene local entity cache.
void UnregisterSystem()
Unregisters the system from the scene.
void DestroyEntity(Entity entity)
Destroys the entity.
auto StaticView(Exclude< ExcludeT... > excludeList)
Constructs a static view of the entities that have a particular set of components....
Entity CreateEntity(const std::string &name)
Creates an Entity with a default set of components.
DynamicEntityView DynamicView()
Constructs a dynamic view which can be configured at runtime.
SceneHandle(const std::shared_ptr< Scene > &scene)
Creates a handle for the scene.
void RemoveContextComponent()
Removes a context component from the scene.
std::expected< void, Core::CoriError<> > AddEntityToCache(Entity entity, const Utility::StringHash32 key)
Adds entity to the local scene cache.
Entity CreateBlankEntity()
Creates a blank Entity with no components attached.
bool IsValid() const
Checks if the scene the handle points to is still valid.
bool HasContextComponent() const
Checks if a scene has a specific context component.
const T & GetContextComponent() const
Retries the reference to the requested context component. Const variant.
T & AddContextComponent(Args &&... args)
Adds a component to the scene.
void OnUpdate(Core::GameTimer &gameTimer)
T & GetContextComponent()
Retries the reference to the requested context component.
auto StaticView()
Constructs a view of the entities that have a particular set of components. Variant without component...
std::expected< Entity, Core::CoriError<> > GetEntityFromCache(const Utility::StringHash32 key)
Retries the entity from a scene local entity cache.
const Graphics::CameraController & GetActiveCamera() const
Retrieves a const reference to the CameraController associated with the current camera.
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...
Graphics::CameraController & GetActiveCamera()
Retrieves a reference to the CameraController associated with the current camera.
Core systems of the engine are here.
entt::hashed_string::hash_type StringHash32
Anything connected to WorldSystem (ECS) is in this namespace.
Helper to exclude certain components from a static view.