Sdk: Make World moveable
Former-commit-id: 285cb9da4cbafd3da0c0859eb9d366bb2fb978a3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user