12 #include "GameObject.hpp"
14 #include "KapEngineSettings.hpp"
24 namespace SceneManagement {
35 namespace SceneManagement {
42 void addGameObject(std::shared_ptr<GameObject> go);
43 void destroyGameObject(std::shared_ptr<GameObject>
const go);
45 void destroyGameObject(std::size_t
id);
47 bool setId(std::size_t
id) {
48 PROFILER_FUNC_START();
58 std::size_t getId()
const {
59 PROFILER_FUNC_START();
64 std::string getName()
const {
65 PROFILER_FUNC_START();
70 bool operator==(
Scene const& scene) {
71 PROFILER_FUNC_START();
72 if (_id == scene.getId()) {
80 bool operator==(std::shared_ptr<Scene> scene) {
81 PROFILER_FUNC_START();
83 return *
this == *scene;
86 bool operator!=(
Scene const& scene) {
87 PROFILER_FUNC_START();
88 if (_id != scene.getId()) {
96 bool operator!=(std::shared_ptr<Scene> scene) {
97 PROFILER_FUNC_START();
99 return *
this != *scene;
118 std::shared_ptr<GameObject> &
getObject(std::size_t
id) {
119 PROFILER_FUNC_START();
124 std::shared_ptr<GameObject> getGameObjectConst(std::size_t
id)
const;
134 PROFILER_FUNC_START();
136 return getGameObjectConst(
id);
139 std::vector<std::shared_ptr<GameObject>> getAllGameObjects();
148 PROFILER_FUNC_START();
150 return getAllGameObjects();
163 PROFILER_FUNC_START();
168 std::vector<std::shared_ptr<GameObject>> getGameObjects(std::string
const& name);
170 std::vector<std::shared_ptr<GameObject>> getGameObjectByTag(std::string
const& tag);
192 #if !KAPENGINE_BETA_ACTIVE
198 #if KAPENGINE_THREAD_ACTIVE
205 static void __threadSceneUpdate(std::vector<std::shared_ptr<GameObject>> gos,
bool physics);
208 #if KAPENGINE_THREAD_ACTIVE
211 void __updatePhysics();
212 void __updateComponents();
213 void __updateRender();
240 void dump(
bool showComponents =
false);
242 std::shared_ptr<GameObject> createGameObject(std::string
const& name);
258 PROFILER_FUNC_START();
259 _tmpActionsAfterUpdate.push_back(action);
263 bool __isChangingScene()
const {
264 return _changingScene;
271 std::size_t _idObjectMax = 0;
272 SceneManager &manager;
273 std::vector<std::shared_ptr<GameObject>> _gameObjects;
274 std::vector<std::shared_ptr<GameObject>> _gameObjectsRun;
275 std::vector<std::size_t> _gameObjectsToDestroy;
276 bool _changingScene =
false;
278 void __checkDestroy();
279 #if KAPENGINE_THREAD_ACTIVE
280 #if KAPENGINE_BETA_ACTIVE
282 bool _destroying =
false;
284 void __checkThread();
287 std::size_t __nbGameObjectNoParent();
288 std::vector<std::shared_ptr<GameObject>> __getGameObjectsNoParent();
289 void __updateGameObjects(std::vector<std::shared_ptr<GameObject>> objs);
290 std::vector<std::function<void(Scene &scene)>> _tmpActionsAfterUpdate;