Added a TriggerSystem, seems to work as intended.

This commit is contained in:
William Moberg
2015-12-15 14:49:52 +01:00
parent ae7d4b9097
commit 170610bcb1
9 changed files with 178 additions and 24 deletions
+17 -1
View File
@@ -8,6 +8,8 @@
#include "Core/EventBroker.h"
#include "ETrigger.h"
class AABB;
class TriggerSystem : public System
{
public:
@@ -18,7 +20,21 @@ public:
virtual void Update(World* world, ComponentWrapper& collision, double dt) override;
private:
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesInTrigger;
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesTouchingTrigger;
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesCompletelyInTrigger;
bool getEntityBox(World* world, EntityID id, AABB& outBox);
//True if leave event was thrown.
bool throwLeaveIfWasInTrigger(std::unordered_set<EntityID>& triggerSet, EntityID pId, EntityID tId);
void attachAABBComponentFromModel(World* world, EntityID id);
template<typename Event>
void publish(EntityID pId, EntityID tId)
{
Event e;
e.Trigger = tId;
e.Entity = pId;
m_EventBroker->Publish(e);
}
};
#endif