tank modifications
This commit is contained in:
@@ -10,13 +10,14 @@ namespace Components
|
|||||||
|
|
||||||
struct SoundEmitter : Component
|
struct SoundEmitter : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class SoundType
|
enum class SoundType
|
||||||
{
|
{
|
||||||
SOUND_3D,
|
SOUND_3D,
|
||||||
SOUND_2D
|
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 Gain;
|
||||||
float MaxDistance;
|
float MaxDistance;
|
||||||
float MinDistance;
|
float MinDistance;
|
||||||
|
|||||||
@@ -653,6 +653,7 @@ EntityID GameWorld::CreateTank(int playerID)
|
|||||||
barrelSteering->ShotSpeed = 70.f;
|
barrelSteering->ShotSpeed = 70.f;
|
||||||
barrelSteering->LowerRotationLimit = glm::radians(-10.f);
|
barrelSteering->LowerRotationLimit = glm::radians(-10.f);
|
||||||
barrelSteering->UpperRotationLimit = glm::radians(40.f);
|
barrelSteering->UpperRotationLimit = glm::radians(40.f);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shot = CreateEntity(barrel);
|
auto shot = CreateEntity(barrel);
|
||||||
auto transform = AddComponent<Components::Transform>(shot);
|
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->Orientation = glm::angleAxis(-glm::pi<float>() / 2.f, glm::vec3(1, 0, 0));
|
||||||
transform->Scale = glm::vec3(3.f);
|
transform->Scale = glm::vec3(3.f);
|
||||||
AddComponent<Components::Template>(shot);
|
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);
|
auto physics = AddComponent<Components::Physics>(shot);
|
||||||
physics->Mass = 25.f;
|
physics->Mass = 25.f;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
|
|||||||
@@ -108,6 +108,18 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
|
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
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 )
|
bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "Components/TriggerExplosion.h"
|
#include "Components/TriggerExplosion.h"
|
||||||
#include "Components/FrameTimer.h"
|
#include "Components/FrameTimer.h"
|
||||||
|
|
||||||
|
#include "Events/PlaySFX.h"
|
||||||
|
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
#include "Components/Vehicle.h"
|
#include "Components/Vehicle.h"
|
||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user