Walls are now destroyable!

This commit is contained in:
Tleety
2014-06-02 18:21:39 +02:00
parent 0e2934647c
commit 00268f027a
13 changed files with 606 additions and 63 deletions
+8 -1
View File
@@ -1,7 +1,6 @@
#include "PrecompiledHeader.h"
#include "DamageSystem.h"
#include "World.h"
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
{
cf->Register<Components::Health>([]() { return new Components::Health(); });
@@ -15,8 +14,16 @@ void Systems::DamageSystem::Initialize()
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
{
if(!m_World->ValidEntity(event.Entity))
return false;
auto health = m_World->GetComponent<Components::Health>(event.Entity);
health->Amount -= event.Amount;
if(health->Amount <= 0)
{
Events::OnDead e;
e.Entity = event.Entity;
EventBroker->Publish(e);
}
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
return true;
}