Sdk: Make World moveable

Former-commit-id: 285cb9da4cbafd3da0c0859eb9d366bb2fb978a3
This commit is contained in:
Lynix
2016-03-01 14:01:31 +01:00
parent 36067e31c4
commit dbce7592a9
8 changed files with 47 additions and 14 deletions

View File

@@ -13,6 +13,11 @@ namespace Ndk
AddDefaultSystems();
}
inline World::World(World&& world) noexcept
{
operator=(std::move(world));
}
inline BaseSystem& World::AddSystem(std::unique_ptr<BaseSystem>&& system)
{
NazaraAssert(system, "System must be valid");
@@ -25,7 +30,7 @@ namespace Ndk
// Affectation et retour du système
m_systems[index] = std::move(system);
m_systems[index]->SetWorld(*this);
m_systems[index]->SetWorld(this);
Invalidate(); // On force une mise à jour de toutes les entités
@@ -152,4 +157,22 @@ namespace Ndk
{
m_dirtyEntities.UnboundedSet(id, true);
}
inline World& World::operator=(World&& world) noexcept
{
m_aliveEntities = std::move(world.m_aliveEntities);
m_dirtyEntities = std::move(world.m_dirtyEntities);
m_freeIdList = std::move(world.m_freeIdList);
m_killedEntities = std::move(world.m_killedEntities);
m_entities = std::move(world.m_entities);
for (EntityBlock& block : m_entities)
block.entity.SetWorld(this);
m_systems = std::move(world.m_systems);
for (const auto& systemPtr : m_systems)
systemPtr->SetWorld(this);
return *this;
}
}