Ndk/Components: Added OnComponent[Attached|Detacted] events

And m_entity member variable


Former-commit-id: d6bd9e382e55bafd357e7ec62862ae731c21f897
This commit is contained in:
Lynix
2015-04-20 01:54:09 +02:00
parent a7be4c6346
commit 5b44619592
4 changed files with 55 additions and 7 deletions

View File

@@ -14,8 +14,11 @@
namespace Ndk
{
class Entity;
class NDK_API BaseComponent
{
friend Entity;
friend class Sdk;
public:
@@ -35,10 +38,15 @@ namespace Ndk
protected:
ComponentIndex m_componentIndex;
Entity* m_entity;
static ComponentIndex RegisterComponent(ComponentId id, Factory factoryFunc);
private:
virtual void OnComponentAttached(BaseComponent& component);
virtual void OnComponentDetached(BaseComponent& component);
void SetEntity(Entity* entity);
static bool Initialize();
static void Uninitialize();

View File

@@ -7,7 +7,8 @@
namespace Ndk
{
inline BaseComponent::BaseComponent(ComponentIndex index) :
m_componentIndex(index)
m_componentIndex(index),
m_entity(nullptr)
{
}
@@ -35,6 +36,11 @@ namespace Ndk
return index;
}
inline void BaseComponent::SetEntity(Entity* entity)
{
m_entity = entity;
}
inline bool BaseComponent::Initialize()
{
// Rien à faire