aboutsummaryrefslogtreecommitdiff
path: root/source/30-game/World.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2023-10-19 22:50:07 -0700
committerrtk0c <[email protected]>2025-08-16 11:31:16 -0700
commit297232d21594b138bb368a42b5b0d085ff9ed6aa (patch)
tree075d5407e1e12a9d35cbee6e4c20ad34e0765c42 /source/30-game/World.cpp
parentd5cd34ff69f7fd134d5450696f298af1a864afbc (diff)
The great renaming: switch to "module style"
Diffstat (limited to 'source/30-game/World.cpp')
-rw-r--r--source/30-game/World.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/source/30-game/World.cpp b/source/30-game/World.cpp
deleted file mode 100644
index 83b9a10..0000000
--- a/source/30-game/World.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "World.hpp"
-
-#include "GameObject.hpp"
-#include "PodVector.hpp"
-
-#include <glad/glad.h>
-
-namespace ProjectBrussel_UNITY_ID {
-template <typename TFunction>
-void CallGameObjectRecursive(GameObject* start, TFunction&& func) {
- PodVector<GameObject*> stack;
- stack.push_back(start);
-
- while (!stack.empty()) {
- auto obj = stack.back();
- stack.pop_back();
-
- for (auto child : obj->GetChildren()) {
- stack.push_back(child);
- }
-
- func(obj);
- }
-}
-} // namespace ProjectBrussel_UNITY_ID
-
-GameWorld::GameWorld()
- : mRoot{ new GameObject(this) } {
-}
-
-GameWorld::~GameWorld() {
- if (mAwakened) {
- Resleep();
- }
-
- delete mRoot;
-}
-
-const GameObject& GameWorld::GetRoot() const {
- return *mRoot;
-};
-
-void GameWorld::Awaken() {
- using namespace ProjectBrussel_UNITY_ID;
-
- if (mAwakened) {
- return;
- }
-
- CallGameObjectRecursive(mRoot, [](GameObject* obj) { obj->Awaken(); });
- mAwakened = true;
-}
-
-void GameWorld::Resleep() {
- using namespace ProjectBrussel_UNITY_ID;
-
- if (!mAwakened) {
- return;
- }
-
- CallGameObjectRecursive(mRoot, [](GameObject* obj) { obj->Resleep(); });
- mAwakened = false;
-}
-
-void GameWorld::Update() {
- using namespace ProjectBrussel_UNITY_ID;
-
- CallGameObjectRecursive(mRoot, [this](GameObject* obj) {
- obj->Update();
- });
-}
-
-GameObject& GameWorld::GetRoot() {
- return *mRoot;
-}
-
-bool GameWorld::IsAwake() const {
- return mAwakened;
-}