Sdk/Entity: Add OnEntityDestruction callback
This commit is contained in:
parent
605e5c2fd0
commit
3fe54ff777
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
|
@ -65,6 +66,8 @@ namespace Ndk
|
|||
Entity& operator=(const Entity&) = delete;
|
||||
Entity& operator=(Entity&&) = delete;
|
||||
|
||||
NazaraSignal(OnEntityDestruction, Entity* /*entity*/);
|
||||
|
||||
private:
|
||||
Entity(World* world, EntityId id);
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ namespace Ndk
|
|||
|
||||
void Entity::Destroy()
|
||||
{
|
||||
OnEntityDestruction(this);
|
||||
OnEntityDestruction.Clear();
|
||||
|
||||
// We prepare components for entity destruction (some components needs this to handle some final callbacks while the entity is still valid)
|
||||
for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i))
|
||||
m_components[i]->OnEntityDestruction();
|
||||
|
|
|
|||
Loading…
Reference in New Issue