diff --git a/lib/wal/sources/Entity/Entity.hpp b/lib/wal/sources/Entity/Entity.hpp index 061b42e4..8e157c6e 100644 --- a/lib/wal/sources/Entity/Entity.hpp +++ b/lib/wal/sources/Entity/Entity.hpp @@ -111,7 +111,7 @@ namespace WAL Entity(Entity &&) = default; //! @brief A default destructor ~Entity() = default; - //! @brief An entity is assignable - Entity &operator=(const Entity &) = default; + //! @brief An entity is not assignable + Entity &operator=(const Entity &) = delete; }; } // namespace WAL \ No newline at end of file diff --git a/lib/wal/sources/Scene/Scene.cpp b/lib/wal/sources/Scene/Scene.cpp index 0ec83228..3c07f3c8 100644 --- a/lib/wal/sources/Scene/Scene.cpp +++ b/lib/wal/sources/Scene/Scene.cpp @@ -10,4 +10,8 @@ namespace WAL { return this->_entities; } + Scene &Scene::operator=(const Scene &) + { + return *this; + } } // namespace WAL \ No newline at end of file diff --git a/lib/wal/sources/Scene/Scene.hpp b/lib/wal/sources/Scene/Scene.hpp index c36a6a0c..bddf1e5c 100644 --- a/lib/wal/sources/Scene/Scene.hpp +++ b/lib/wal/sources/Scene/Scene.hpp @@ -36,7 +36,7 @@ namespace WAL //! @brief A default destructor ~Scene() = default; //! @brief A scene is assignable - Scene &operator=(const Scene &) = default; + Scene &operator=(const Scene &); Scene(Scene &&) = default; }; } // namespace WAL \ No newline at end of file diff --git a/lib/wal/sources/Wal.cpp b/lib/wal/sources/Wal.cpp index 5bab4a43..875e3bd8 100644 --- a/lib/wal/sources/Wal.cpp +++ b/lib/wal/sources/Wal.cpp @@ -12,7 +12,7 @@ namespace WAL void Wal::_update(std::chrono::nanoseconds dtime) { - auto &entities = this->scene.getEntities(); + auto &entities = this->scene->getEntities(); for (auto &system : this->_systems) { for (auto &entity : entities) { @@ -26,7 +26,7 @@ namespace WAL void Wal::_fixedUpdate() { - auto &entities = this->scene.getEntities(); + auto &entities = this->scene->getEntities(); for (auto &system : this->_systems) { for (auto &entity : entities) { diff --git a/lib/wal/sources/Wal.hpp b/lib/wal/sources/Wal.hpp index ec2d1786..0cb32505 100644 --- a/lib/wal/sources/Wal.hpp +++ b/lib/wal/sources/Wal.hpp @@ -39,7 +39,7 @@ namespace WAL static bool _hasDependencies(const Entity &entity, const System &system); public: //! @brief The scene that contains entities. - Scene scene; + std::shared_ptr scene; //! @brief The time between each fixed update. static std::chrono::nanoseconds timestep; diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 06c2cd6b..baa4eb96 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -45,11 +45,12 @@ namespace BBM int run() { + WAL::Scene gameScene = loadGameScene(); WAL::Wal wal; wal.addSystem(); enableRaylib(wal); WAL::Scene scene = loadGameScene(); - wal.scene = scene; + wal.scene = std::make_shared(scene); // wal.scene = loadGameScene();