tank modifications

This commit is contained in:
Stiffly
2014-06-03 19:44:33 +02:00
parent e7eca74b03
commit a5105e5859
4 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -10,13 +10,14 @@ namespace Components
struct SoundEmitter : Component
{
enum class SoundType
{
SOUND_3D,
SOUND_2D
};
SoundEmitter() : Gain(1.f), MaxDistance(1.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
SoundEmitter() : Gain(1.f), MaxDistance(10000.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
float Gain;
float MaxDistance;
float MinDistance;
+6
View File
@@ -653,6 +653,7 @@ EntityID GameWorld::CreateTank(int playerID)
barrelSteering->ShotSpeed = 70.f;
barrelSteering->LowerRotationLimit = glm::radians(-10.f);
barrelSteering->UpperRotationLimit = glm::radians(40.f);
{
auto shot = CreateEntity(barrel);
auto transform = AddComponent<Components::Transform>(shot);
@@ -660,6 +661,11 @@ EntityID GameWorld::CreateTank(int playerID)
transform->Orientation = glm::angleAxis(-glm::pi<float>() / 2.f, glm::vec3(1, 0, 0));
transform->Scale = glm::vec3(3.f);
AddComponent<Components::Template>(shot);
auto soundEmitter = AddComponent<Components::SoundEmitter>(shot);
soundEmitter->MinDistance = 1000;
soundEmitter->Gain = 1;
soundEmitter->Loop = false;
auto physics = AddComponent<Components::Physics>(shot);
physics->Mass = 25.f;
physics->Static = false;
+12
View File
@@ -108,6 +108,18 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
}
auto shot = m_World->GetComponent<Components::TankShell>(entity);
if(shot)
{
if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
{
Events::PlaySFX e;
e.Resource = "Sounds/SFX/LongBoom.wav";
e.Emitter = entity;
EventBroker->Publish(e);
}
}
}
bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
+2
View File
@@ -29,6 +29,8 @@
#include "Components/TriggerExplosion.h"
#include "Components/FrameTimer.h"
#include "Events/PlaySFX.h"
#include "Events/Damage.h"
#include "Components/Vehicle.h"
#include "Components/Player.h"