diff options
author | rtk0c <[email protected]> | 2022-05-30 17:03:20 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 17:03:20 -0700 |
commit | e66286ebe30afc9acc4531fc2bea29b7fb924f93 (patch) | |
tree | fa6b76554c3eb88bc8f088fbab68e20c40118ca7 /source/World.cpp | |
parent | 366ef5a5450c6e0e680c924c3454943a9ae9814d (diff) |
Changeset: 56 Buildsystem cleanup: change to layered structure for different targets
Diffstat (limited to 'source/World.cpp')
-rw-r--r-- | source/World.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/source/World.cpp b/source/World.cpp deleted file mode 100644 index d4a8344..0000000 --- a/source/World.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "World.hpp" - -#include "GameObject.hpp" -#include "PodVector.hpp" - -#include <glad/glad.h> - -namespace ProjectBrussel_UNITY_ID { -template <class 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); - } -} - -struct DrawCall { - GLuint vao; - GLuint vbo; -}; -} // 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() { - if (mAwakened) return; - - ProjectBrussel_UNITY_ID::CallGameObjectRecursive(mRoot, [](GameObject* obj) { obj->Awaken(); }); - mAwakened = true; -} - -void GameWorld::Resleep() { - if (!mAwakened) return; - - ProjectBrussel_UNITY_ID::CallGameObjectRecursive(mRoot, [](GameObject* obj) { obj->Resleep(); }); - mAwakened = false; -} - -void GameWorld::Update() { - ProjectBrussel_UNITY_ID::CallGameObjectRecursive(mRoot, [this](GameObject* obj) { - obj->Update(); - }); -} - -GameObject& GameWorld::GetRoot() { - return *mRoot; -} - -bool GameWorld::IsAwake() const { - return mAwakened; -} |