Merge remote-tracking branch 'origin/master' into Sound+Particles

Conflicts:
	vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
Stiffly
2014-06-04 18:22:16 +02:00
24 changed files with 538 additions and 70 deletions
+6 -6
View File
@@ -18,12 +18,12 @@ bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
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);
}
//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;
}
+19
View File
@@ -0,0 +1,19 @@
#include "PrecompiledHeader.h"
#include "GameStateSystem.h"
#include "World.h"
void Systems::GameStateSystem::Initialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EFlagCaptured, &Systems::GameStateSystem::OnFlagCaptured);
}
bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event)
{
m_InGame = false;
Events::GameOver e;
e.Winner = event.Player;
EventBroker->Publish(e);
return true;
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef GameStateSystem_h__
#define GameStateSystem_h__
#include <set>
#include "System.h"
#include "Components/Transform.h"
#include "Components/Player.h"
#include "Events/FlagCaptured.h"
#include "Events/GameOver.h"
namespace Systems
{
class GameStateSystem : public System
{
public:
GameStateSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
: System(world, eventBroker, resourceManager)
, m_InGame(true)
{ }
void Initialize() override;
bool InGame() const { return m_InGame; }
private:
bool m_InGame;
EventRelay<GameStateSystem, Events::FlagCaptured> m_EFlagCaptured;
bool OnFlagCaptured(const Events::FlagCaptured &event);
};
}
#endif // GameStateSystem_h__
+1
View File
@@ -48,6 +48,7 @@
#include "Components/Input.h"
#include "Events/SetViewportCamera.h"
#include "Events/GameOver.h"
namespace Systems
{
+16 -17
View File
@@ -25,30 +25,29 @@ bool Systems::WallSystem::Damage( const Events::Damage &event )
{
return false;
}
LOG_INFO("You are dead");
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
LOG_INFO("Entity %i is dead", event.Entity);
//auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
Components::Transform transformComponent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(event.Entity);
for(auto d : wallComponent->Walldebris)
{
auto debris = m_World->CloneEntity(d);
auto transform = m_World->GetComponent<Components::Transform>(debris);
transform->Position += transformComponent->Position;
// DO STUFF! :D
float distance = glm::distance(transform->Position, transformComponent->Position);
float radius = 5.f;
float strength = (1.f - pow(distance / radius, 2)) * 500.f;
glm::vec3 direction = glm::normalize(transformComponent->Position - transform->Position);
Events::ApplyPointImpulse e;
e.Entity = debris;
e.Impulse = direction * strength;
e.Position = transformComponent->Position;
EventBroker->Publish(e);
transform->Orientation = transform->Orientation * transformComponent.Orientation;
transform->Position = transform->Orientation * transform->Position + transformComponent.Position;
//DO STUFF! :D
float distance = glm::distance(transform->Position, transformComponent.Position);
float radius = 5.f;
float strength = (1.f - pow(distance / radius, 2)) * 20.f;
glm::vec3 direction = glm::normalize(transformComponent.Position - transform->Position);
Events::ApplyPointImpulse e;
e.Entity = debris;
e.Impulse = direction * strength;
e.Position = transformComponent.Position;
EventBroker->Publish(e);
}
m_World->RemoveEntity(event.Entity);
+1
View File
@@ -3,6 +3,7 @@
#include "System.h"
#include "Systems/TransformSystem.h"
#include "Events/OnDead.h"
#include "Events/Damage.h"
#include "Events/ApplyPointImpulse.h"