Sdk/BaseComponent: Add OnEntityDisabled and OnEntityEnabled callbacks

This commit is contained in:
Lynix
2017-12-10 14:06:43 +01:00
parent 33b3b2feaf
commit 498bd77d8a
7 changed files with 59 additions and 20 deletions

View File

@@ -138,12 +138,11 @@ namespace Ndk
*
* \param id Identifier of the entity
*
* \remark Produces a NazaraError if the entity to clone does not exist
* \remark Cloning a disabled entity will produce an enabled clone
*/
const EntityHandle& World::CloneEntity(EntityId id)
{
EntityHandle original = GetEntity(id);
const EntityHandle& original = GetEntity(id);
if (!original)
{
NazaraError("Invalid entity ID");
@@ -151,6 +150,8 @@ namespace Ndk
}
const EntityHandle& clone = CreateEntity();
if (!original->IsEnabled())
clone->Disable();
const Nz::Bitset<>& componentBits = original->GetComponentBits();
for (std::size_t i = componentBits.FindFirst(); i != componentBits.npos; i = componentBits.FindNext(i))
@@ -159,6 +160,8 @@ namespace Ndk
clone->AddComponent(std::move(component));
}
clone->Enable();
return clone;
}