Added OnComponentCreated event for systems
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#define System_h__
|
#define System_h__
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
@@ -16,6 +17,9 @@ public:
|
|||||||
// Called once for every entity in the world every tick
|
// Called once for every entity in the world every tick
|
||||||
virtual void Update(double dt, EntityID entity, EntityID parent) { }
|
virtual void Update(double dt, EntityID entity, EntityID parent) { }
|
||||||
|
|
||||||
|
// Called when a component is created
|
||||||
|
virtual void OnComponentCreated(std::string type, std:: shared_ptr<Component> component);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
World* m_World;
|
World* m_World;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,8 +44,12 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component->Entity = entity;
|
||||||
m_ComponentsOfType[componentType].push_back(component);
|
m_ComponentsOfType[componentType].push_back(component);
|
||||||
m_EntityComponents[entity][componentType] = component;
|
m_EntityComponents[entity][componentType] = component;
|
||||||
|
for (auto system : m_Systems) {
|
||||||
|
system->OnComponentCreated(componentType, component);
|
||||||
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user