From d40750243284633e62b9a116cda975cf8dde9fc3 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Sat, 31 May 2014 22:15:44 +0200 Subject: [PATCH] CreateExplosion event published on shell collision now. --- src/InputManager.cpp | 13 ------------- src/InputManager.h | 1 - src/Systems/TankSteeringSystem.cpp | 23 +++++++++++++++++++++++ src/Systems/TankSteeringSystem.h | 1 + 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 5e6c942..01d61ba 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -85,19 +85,6 @@ void InputManager::Update(double dt) EventBroker->Publish(e); } - if(m_CurrentKeyState[GLFW_KEY_Z]) - { - Events::CreateExplosion e; - e.LifeTime = 1; - e.ParticleScale = 6; - e.ParticlesToSpawn = 1; - e.Position = glm::vec3(0, -15, 0); - e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); - e.Speed = 3; - e.SpreadAngle = glm::pi(); - e.spritePath = "Textures/Sprites/SeriousParticle.png"; - EventBroker->Publish(e); - } // // Lock mouse while holding LMB // if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT]) diff --git a/src/InputManager.h b/src/InputManager.h index 94d178d..69827ba 100644 --- a/src/InputManager.h +++ b/src/InputManager.h @@ -12,7 +12,6 @@ #include "Events/LockMouse.h" #include "Events/GamepadAxis.h" #include "Events/GamepadButton.h" -#include "Events/CreateExplosion.h" class InputManager { diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 5809fd9..bf72fc7 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -126,6 +126,29 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e ) auto physicsComponents = m_World->GetComponentsOfType(); auto shellTransform = m_World->GetComponent(shellEntity); //auto otherTransform = m_World->GetComponent(otherEntity); + + { + Events::CreateExplosion e; + e.LifeTime = 2; + e.ParticleScale = 8; + e.ParticlesToSpawn = 10; + e.Position = shellTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); + e.Speed = 3; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/Smoke1.png"; + EventBroker->Publish(e); + e.LifeTime = 1; + e.ParticleScale = 12; + e.ParticlesToSpawn = 10; + e.Position = shellTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); + e.Speed = 6; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/Fire.png"; + EventBroker->Publish(e); + } + for (auto &physComponent : *physicsComponents) { EntityID physicsEntity = std::dynamic_pointer_cast(physComponent)->Entity; diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index 9a9c696..f3115a6 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -5,6 +5,7 @@ #include "Events/SetVelocity.h" #include "Events/ApplyForce.h" #include "Events/ApplyPointImpulse.h" +#include "Events/CreateExplosion.h" #include "Events/Collision.h" #include "Components/Transform.h" #include "Components/TankSteering.h"