CoriEngine
Loading...
Searching...
No Matches
Layer.hpp
Go to the documentation of this file.
1#pragma once
2#include <box2cpp/debug_imgui_renderer.h>
3#include "Time.hpp"
7
8namespace Cori {
9 namespace Core {
13 class Layer {
14 public:
15 explicit Layer(std::string name);
16
17 virtual ~Layer();
18
22 virtual void OnAttach();
23
27 virtual void OnDetach();
28
33 virtual void OnUpdate([[maybe_unused]] GameTimer& gameTimer) {}
34
39 virtual void OnTickUpdate([[maybe_unused]] GameTimer& gameTimer) {}
40
41
46 virtual void OnImGuiRender([[maybe_unused]] GameTimer& gameTimer) {}
47
52 virtual void OnEvent([[maybe_unused]] Event& event) {}
53
54
61 void SetModal(const bool state) { m_Modal = state; }
62
66 [[nodiscard]] bool IsModal() const { return m_Modal; }
67
72 [[nodiscard]] std::string_view GetName() const { return m_Name; }
73
79 std::expected<void, CoriError<>> BindScene(const std::string& name);
80
85 std::expected<void, CoriError<>> UnbindScene();
86
91
92 inline static Physics::DebugImguiRenderer m_DebugImGuiRenderer;
93
94 private:
95 friend class Application;
96
97 void SceneUpdate(GameTimer& gameTimer) {
98 ActiveScene.OnUpdate(gameTimer);
99 }
100
101 void SceneTickrateUpdate(GameTimer& gameTimer) {
102 ActiveScene.OnTickUpdate(gameTimer);
103 }
104
105 void SceneImGuiRender(GameTimer& gameTimer) {
106 ActiveScene.OnImGuiRender(gameTimer);
107 }
108
109 bool m_Modal{ false };
110 std::string m_Name;
111 };
112 }
113}
An abstract class that is ment to be used as a template for defining events.
Definition Event.hpp:18
A GameTimer is responsible for managing everything that is connected with time, ticks,...
Definition Time.hpp:8
std::string_view GetName() const
Returns the name of the Layer.
Definition Layer.hpp:72
virtual void OnImGuiRender(GameTimer &gameTimer)
Run every frame, this is the method where you do all the ImGui stuff.
Definition Layer.hpp:46
friend class Application
Definition Layer.hpp:95
void SetModal(const bool state)
Change the Layer modal state.
Definition Layer.hpp:61
virtual void OnDetach()
Method that runs when the layer gets detached to the LayerStack.
Definition Layer.cpp:22
virtual void OnUpdate(GameTimer &gameTimer)
Run every frame.
Definition Layer.hpp:33
bool IsModal() const
Checks if the Layer is modal.
Definition Layer.hpp:66
std::expected< void, CoriError<> > BindScene(const std::string &name)
Binds the Scene to the Layer.
Definition Layer.cpp:26
World::SceneHandle ActiveScene
A SceneHandle to the Scene that is currently bound.
Definition Layer.hpp:90
static Physics::DebugImguiRenderer m_DebugImGuiRenderer
Definition Layer.hpp:92
virtual ~Layer()
Definition Layer.cpp:14
virtual void OnTickUpdate(GameTimer &gameTimer)
Run every tick.
Definition Layer.hpp:39
Layer(std::string name)
Definition Layer.cpp:7
std::expected< void, CoriError<> > UnbindScene()
Unbinds the Scene from the Layer.
Definition Layer.cpp:47
virtual void OnAttach()
Method that runs when the layer gets attached to the LayerStack.
Definition Layer.cpp:18
virtual void OnEvent(Event &event)
This is the method to handle all the event at.
Definition Layer.hpp:52
A handle for the scene, checks for scene validity before any call to the scene, if scene is invalid a...
void OnTickUpdate(Core::GameTimer &gameTimer)
void OnImGuiRender(Core::GameTimer &gameTimer)
Core systems of the engine are here.
Global engine namespace.