Add generic handlers

Former-commit-id: 8fc343d3a056de8031cf453748b8801d50d3710e
This commit is contained in:
Lynix
2016-03-31 21:14:22 +02:00
parent a2f6e54104
commit a77ad42fcb
16 changed files with 542 additions and 423 deletions

View File

@@ -4,14 +4,13 @@
#include <NDK/Entity.hpp>
#include <NDK/BaseComponent.hpp>
#include <NDK/EntityHandle.hpp>
#include <NDK/World.hpp>
namespace Ndk
{
Entity::Entity(Entity&& entity) :
HandledObject(std::move(entity)),
m_components(std::move(entity.m_components)),
m_handles(std::move(entity.m_handles)),
m_componentBits(std::move(entity.m_componentBits)),
m_systemBits(std::move(entity.m_systemBits)),
m_id(entity.m_id),
@@ -19,8 +18,6 @@ namespace Ndk
m_enabled(entity.m_enabled),
m_valid(entity.m_valid)
{
for (EntityHandle* handle : m_handles)
handle->OnEntityMoved(this);
}
Entity::Entity(World* world, EntityId id) :
@@ -63,11 +60,6 @@ namespace Ndk
return component;
}
EntityHandle Entity::CreateHandle()
{
return EntityHandle(this);
}
void Entity::Kill()
{
m_world->KillEntity(this);
@@ -132,11 +124,7 @@ namespace Ndk
}
m_systemBits.Clear();
// On informe chaque handle de notre destruction pour éviter qu'il ne continue de pointer sur nous
for (EntityHandle* handle : m_handles)
handle->OnEntityDestroyed();
m_handles.clear();
UnregisterAllHandles();
m_valid = false;
}

View File

@@ -1,10 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/EntityHandle.hpp>
namespace Ndk
{
const EntityHandle EntityHandle::InvalidHandle;
}

View File

@@ -61,7 +61,7 @@ namespace Ndk
void World::Clear() noexcept
{
///DOC: Tous les handles sont correctement invalidés
///DOC: Tous les handles sont correctement invalidés, les entités sont immédiatement invalidées
// Destruction des entités d'abord, et des handles ensuite
// ceci pour éviter que les handles n'informent les entités inutilement lors de leur destruction