Damage and Spashdamage working, phantomShapes not really working

This commit is contained in:
ViktorLjung
2014-05-27 07:04:29 +02:00
parent a0ee235473
commit c37df5c178
27 changed files with 804 additions and 202 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "PrecompiledHeader.h"
#include "DamageSystem.h"
#include "World.h"
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
{
cf->Register<Components::Health>([]() { return new Components::Health(); });
}
void Systems::DamageSystem::Initialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EDamage, &Systems::DamageSystem::OnDamage);
}
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
{
auto health = m_World->GetComponent<Components::Health>(event.Entity);
health->health -= event.damage;
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->health);
return true;
}