diff --git a/ChangeLog.md b/ChangeLog.md index 8a71843c4..11c2003bf 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -140,6 +140,7 @@ Nazara Development Kit: - Add DebugComponent (a component able to show aabb/obb/collision mesh) - ⚠️ TextAreaWidget now support text selection (WIP) - ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position +- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called. # 0.4: diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 2bf6b6dad..355028fef 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,7 @@ namespace Ndk public: Entity(const Entity&) = delete; - Entity(Entity&& entity); + Entity(Entity&& entity) noexcept; ~Entity(); BaseComponent& AddComponent(std::unique_ptr&& component); @@ -96,8 +97,8 @@ namespace Ndk Nz::Bitset<> m_componentBits; Nz::Bitset<> m_removedComponentBits; Nz::Bitset<> m_systemBits; + Nz::MovablePtr m_world; EntityId m_id; - World* m_world; bool m_enabled; bool m_valid; }; diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 863428d2a..ffcce07f0 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -14,26 +14,8 @@ namespace Ndk * \brief NDK class that represents an entity in a world */ - /*! - * \brief Constructs a Entity object by move semantic - * - * \param entity Entity to move into this - */ - - Entity::Entity(Entity&& entity) : - HandledObject(std::move(entity)), - m_components(std::move(entity.m_components)), - m_containedInLists(std::move(entity.m_containedInLists)), - m_componentBits(std::move(entity.m_componentBits)), - m_removedComponentBits(std::move(entity.m_removedComponentBits)), - m_systemBits(std::move(entity.m_systemBits)), - m_id(entity.m_id), - m_world(entity.m_world), - m_enabled(entity.m_enabled), - m_valid(entity.m_valid) - { - entity.m_world = nullptr; - } + // Must exists in .cpp file because of BaseComponent unique_ptr + Entity::Entity(Entity&&) noexcept = default; /*! * \brief Constructs a Entity object linked to a world and with an id @@ -41,7 +23,6 @@ namespace Ndk * \param world World in which the entity interact * \param id Identifier of the entity */ - Entity::Entity(World* world, EntityId id) : m_id(id), m_world(world) @@ -53,7 +34,6 @@ namespace Ndk * * \see Destroy */ - Entity::~Entity() { if (m_world && m_valid)