Sdk/Entity: Fix movement

Fixes OnEntityDestruction not being moved
This commit is contained in:
Lynix 2018-04-22 12:46:41 +02:00
parent 8ab1462402
commit 97067cb566
3 changed files with 6 additions and 24 deletions

View File

@ -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:

View File

@ -9,6 +9,7 @@
#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Signal.hpp>
#include <NDK/Algorithm.hpp>
#include <NDK/Prerequisites.hpp>
@ -33,7 +34,7 @@ namespace Ndk
public:
Entity(const Entity&) = delete;
Entity(Entity&& entity);
Entity(Entity&& entity) noexcept;
~Entity();
BaseComponent& AddComponent(std::unique_ptr<BaseComponent>&& component);
@ -96,8 +97,8 @@ namespace Ndk
Nz::Bitset<> m_componentBits;
Nz::Bitset<> m_removedComponentBits;
Nz::Bitset<> m_systemBits;
Nz::MovablePtr<World> m_world;
EntityId m_id;
World* m_world;
bool m_enabled;
bool m_valid;
};

View File

@ -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)