Started on CollisionSystem and TriggerSystem. Moved collision code to Collision folder.

This commit is contained in:
William Moberg
2015-12-14 17:08:00 +01:00
parent 8d87841691
commit 59095c2ce5
13 changed files with 162 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
#include "Collision/CollisionSystem.h"
void CollisionSystem::Update(World * world, ComponentWrapper & collision, double dt)
{
m_EventBroker->Process<CollisionSystem>();
(glm::vec3&)collision["Center"] = (glm::vec3)world->GetComponent(collision.EntityID, "Transform")["Position"];
}
bool CollisionSystem::OnKeyUp(const Events::KeyUp & event)
{
if (event.KeyCode == GLFW_KEY_Z) {
}
return false;
}
+22
View File
@@ -0,0 +1,22 @@
#include "Collision/TriggerSystem.h"
#include "Core/AABB.h"
void TriggerSystem::Update(World* world, ComponentWrapper& trigger, double dt)
{
auto players = world->GetComponents("Player");
if (players == nullptr) {
return;
}
//WTODO: Assumes box exists.
ComponentWrapper& cBox = world->GetComponent(trigger.EntityID, "AABB");
AABB aabb;
aabb.CreateFromCenter(cBox["BoxCenter"], cBox["BoxSize"]);
for (auto& c : *players) {
Events::TriggerEnter e;
e.Trigger = trigger.EntityID;
e.Entity = 41;
m_EventBroker->Publish(e);
}
}