Merge remote-tracking branch 'origin/Sound+Particles'
This commit is contained in:
@@ -21,7 +21,7 @@ struct ParticleEmitter : Component
|
|||||||
, LifeTime(0)
|
, LifeTime(0)
|
||||||
, TimeSinceLastSpawn(100)
|
, TimeSinceLastSpawn(100)
|
||||||
, Emitting(false)
|
, Emitting(false)
|
||||||
, Color(glm::vec4(0)) { }
|
, Color(glm::vec4(1)) { }
|
||||||
|
|
||||||
EntityID ParticleTemplate;
|
EntityID ParticleTemplate;
|
||||||
float SpawnFrequency;
|
float SpawnFrequency;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ struct Vehicle : Component
|
|||||||
Vehicle()
|
Vehicle()
|
||||||
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(2500.0f), MaxRPM(4000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
|
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(2500.0f), MaxRPM(4000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
|
||||||
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(3500.0f), DownshiftRPM(1000.0f),
|
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(3500.0f), DownshiftRPM(1000.0f),
|
||||||
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ }
|
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f), currentRPM(0.0f){ }
|
||||||
float MaxTorque;
|
float MaxTorque;
|
||||||
float MinRPM;
|
float MinRPM;
|
||||||
float OptimalRPM;
|
float OptimalRPM;
|
||||||
@@ -29,6 +29,7 @@ struct Vehicle : Component
|
|||||||
float gearsRatio1;
|
float gearsRatio1;
|
||||||
float gearsRatio2;
|
float gearsRatio2;
|
||||||
float gearsRatio3;
|
float gearsRatio3;
|
||||||
|
float currentRPM;
|
||||||
|
|
||||||
Vehicle* Clone() const override { return new Vehicle(*this); }
|
Vehicle* Clone() const override { return new Vehicle(*this); }
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -41,10 +41,10 @@ public:
|
|||||||
m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World);
|
m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World);
|
||||||
m_FreeCamViewport->Hide();
|
m_FreeCamViewport->Hide();
|
||||||
}
|
}
|
||||||
//m_WorldFrame->Hide();
|
m_WorldFrame->Hide();
|
||||||
//m_MainMenuFrame = new MainMenuFrame(this, "MainMenu");
|
|
||||||
|
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
|
|
||||||
|
m_MainMenuFrame = new MainMenuFrame(this, "MainMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+10
-2
@@ -5,6 +5,7 @@
|
|||||||
#include "GUI/HealthOverlay.h"
|
#include "GUI/HealthOverlay.h"
|
||||||
|
|
||||||
#include "Events/GameStart.h"
|
#include "Events/GameStart.h"
|
||||||
|
#include "Events/PlayBGM.h"
|
||||||
|
|
||||||
namespace GUI
|
namespace GUI
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,10 @@ public:
|
|||||||
m_TargetCoordinate = m_CurrentCoordinate;
|
m_TargetCoordinate = m_CurrentCoordinate;
|
||||||
m_Buttons->X = m_CurrentCoordinate.x;
|
m_Buttons->X = m_CurrentCoordinate.x;
|
||||||
m_Buttons->Y = m_CurrentCoordinate.y;
|
m_Buttons->Y = m_CurrentCoordinate.y;
|
||||||
|
|
||||||
|
Events::PlayBGM e;
|
||||||
|
e.Resource = "Sounds/BGM/DiesIrae.mp3";
|
||||||
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(double dt) override
|
void Update(double dt) override
|
||||||
@@ -74,8 +79,11 @@ protected:
|
|||||||
if (m_CurrentSelection == 0)
|
if (m_CurrentSelection == 0)
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
Events::GameStart e;
|
Events::GameStart e1;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e1);
|
||||||
|
Events::PlayBGM e2;
|
||||||
|
e2.Resource = "Sounds/BGM/FlightOfTheBumblebee.mp3";
|
||||||
|
EventBroker->Publish(e2);
|
||||||
}
|
}
|
||||||
// Quit
|
// Quit
|
||||||
else if (m_CurrentSelection == 1)
|
else if (m_CurrentSelection == 1)
|
||||||
|
|||||||
@@ -8,6 +8,13 @@ void GameWorld::Initialize()
|
|||||||
ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/Plane.obj");
|
ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/Plane.obj");
|
||||||
ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/ArrowCube.obj");
|
ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/ArrowCube.obj");
|
||||||
|
|
||||||
|
//Background Music
|
||||||
|
{
|
||||||
|
Events::PlayBGM e;
|
||||||
|
e.Resource = "Sounds/SFX/WUB.mp3";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
BindKey(GLFW_KEY_A, "interface_horizontal", -1.f);
|
BindKey(GLFW_KEY_A, "interface_horizontal", -1.f);
|
||||||
BindKey(GLFW_KEY_D, "interface_horizontal", 1.f);
|
BindKey(GLFW_KEY_D, "interface_horizontal", 1.f);
|
||||||
|
|||||||
@@ -85,6 +85,28 @@ void InputManager::Update(double dt)
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(m_CurrentKeyState[GLFW_KEY_P])
|
||||||
|
{
|
||||||
|
Events::StopSound e;
|
||||||
|
e.Emitter = 1;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
if(m_CurrentKeyState[GLFW_KEY_L])
|
||||||
|
{
|
||||||
|
Events::PlayBGM e;
|
||||||
|
e.Resource = "Sounds/BGM/WilliamTellOverture.mp3";
|
||||||
|
e.Loop = true;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
if(m_CurrentKeyState[GLFW_KEY_O])
|
||||||
|
{
|
||||||
|
Events::PlayBGM e;
|
||||||
|
e.Resource = "Sounds/BGM/DiesIrae.mp3";
|
||||||
|
e.Loop = true;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Lock mouse while holding LMB
|
// // Lock mouse while holding LMB
|
||||||
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#include "Events/GamepadAxis.h"
|
#include "Events/GamepadAxis.h"
|
||||||
#include "Events/GamepadButton.h"
|
#include "Events/GamepadButton.h"
|
||||||
|
|
||||||
|
#include "Events/StopSound.h"
|
||||||
|
#include "Events/PlayBGM.h"
|
||||||
|
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event)
|
|||||||
{
|
{
|
||||||
m_InGame = false;
|
m_InGame = false;
|
||||||
|
|
||||||
Events::GameOver e;
|
Events::GameOver e1;
|
||||||
e.Winner = event.Player;
|
e1.Winner = event.Player;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e1);
|
||||||
|
Events::PlayBGM e2;
|
||||||
|
e2.Resource = "Sounds/BGM/WilliamTellOverture.mp3";
|
||||||
|
EventBroker->Publish(e2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
#include "Events/FlagCaptured.h"
|
#include "Events/FlagCaptured.h"
|
||||||
#include "Events/GameOver.h"
|
#include "Events/GameOver.h"
|
||||||
|
#include "Events/PlayBGM.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
|
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(car);
|
||||||
|
vehicleComponent->currentRPM = m_Vehicles[car]->calcRPM();
|
||||||
|
|
||||||
|
|
||||||
m_Vehicles[car]->getChassis()->activate();
|
m_Vehicles[car]->getChassis()->activate();
|
||||||
|
|||||||
+38
-22
@@ -2,13 +2,18 @@
|
|||||||
#include "SoundSystem.h"
|
#include "SoundSystem.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
|
Systems::SoundSystem::~SoundSystem()
|
||||||
|
{
|
||||||
|
FMOD_System_Release(m_System);
|
||||||
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::Initialize()
|
void Systems::SoundSystem::Initialize()
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EComponentCreated, &SoundSystem::OnComponentCreated);
|
EVENT_SUBSCRIBE_MEMBER(m_EComponentCreated, &SoundSystem::OnComponentCreated);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::PlaySFX);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::PlaySFX);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayBGM, &SoundSystem::PlayBGM);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayBGM, &SoundSystem::PlayBGM);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::StopSound);
|
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::StopSound);
|
||||||
|
m_isPlaying = false;
|
||||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||||
FMOD_System_Create(&m_System);
|
FMOD_System_Create(&m_System);
|
||||||
FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_ENABLE_PROFILE, 0);
|
FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_ENABLE_PROFILE, 0);
|
||||||
@@ -44,16 +49,15 @@ void Systems::SoundSystem::Update(double dt)
|
|||||||
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
||||||
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
||||||
{
|
{
|
||||||
FMOD_BOOL isPlaying = false;
|
FMOD_Channel_IsPlaying(it->second, &m_isPlaying);
|
||||||
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
if(m_isPlaying)
|
||||||
if(isPlaying)
|
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
||||||
// m_DeleteSounds.erase(it->first);
|
m_DeleteSounds.erase(it->first);
|
||||||
it = m_DeleteChannels.erase(it);
|
it = m_DeleteChannels.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +66,8 @@ void Systems::SoundSystem::Update(double dt)
|
|||||||
|
|
||||||
for(it = m_Channels.begin(); it != m_Channels.end();)
|
for(it = m_Channels.begin(); it != m_Channels.end();)
|
||||||
{
|
{
|
||||||
FMOD_BOOL isPlaying = false;
|
FMOD_Channel_IsPlaying(it->second, &m_isPlaying);
|
||||||
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
if(!m_isPlaying)
|
||||||
if(!isPlaying)
|
|
||||||
{
|
{
|
||||||
it = m_Channels.erase(it);
|
it = m_Channels.erase(it);
|
||||||
}
|
}
|
||||||
@@ -101,7 +104,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
FMOD_CHANNEL* channel = m_Channels[entity];
|
FMOD_CHANNEL* channel = m_Channels[entity];
|
||||||
//FMOD_SOUND* sound = m_Sounds[entity];
|
FMOD_SOUND* sound = m_Sounds[entity];
|
||||||
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
|
||||||
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
||||||
@@ -134,9 +137,9 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev
|
|||||||
float maxDist = emitter->MaxDistance;
|
float maxDist = emitter->MaxDistance;
|
||||||
float minDist = emitter->MinDistance;
|
float minDist = emitter->MinDistance;
|
||||||
float pitch = emitter->Pitch;
|
float pitch = emitter->Pitch;
|
||||||
//LoadSound(sound, path, maxDist, minDist);
|
LoadSound(sound, path, maxDist, minDist);
|
||||||
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
||||||
// m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -154,7 +157,7 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
|||||||
|
|
||||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
||||||
//m_Sounds[eEntity] = *sound;
|
m_Sounds[eEntity] = *sound;
|
||||||
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
|
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
|
||||||
|
|
||||||
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
|
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
|
||||||
@@ -163,21 +166,34 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
|||||||
|
|
||||||
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
||||||
{
|
{
|
||||||
auto emitter = m_World->CreateEntity();
|
FMOD_RESULT result;
|
||||||
auto eTransform = m_World->AddComponent<Components::Transform>(emitter);
|
result = FMOD_Channel_Stop(m_BGMChannel);
|
||||||
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(emitter);
|
if(result != FMOD_OK)
|
||||||
m_Channels[emitter] = m_BGMChannel;
|
LOG_INFO("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
||||||
//m_Sounds[emitter] = *sound;
|
|
||||||
|
|
||||||
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
result = FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_BGMChannel);
|
||||||
|
if(result != FMOD_OK)
|
||||||
|
LOG_INFO("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||||
|
FMOD_Channel_SetMode(m_BGMChannel, FMOD_LOOP_NORMAL);
|
||||||
|
FMOD_Sound_SetLoopCount(*sound, -1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Systems::SoundSystem::StopSound(const Events::StopSound &event)
|
bool Systems::SoundSystem::StopSound(const Events::StopSound &event)
|
||||||
{
|
{
|
||||||
FMOD_Channel_Stop(m_Channels[event.Emitter]);
|
auto eComp = m_World->GetComponent<Components::SoundEmitter>(event.Emitter);
|
||||||
|
if(eComp)
|
||||||
|
{
|
||||||
|
FMOD_Channel_Stop(m_Channels[event.Emitter]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FMOD_Channel_Stop(m_BGMChannel);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +224,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type,
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
||||||
//m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
||||||
m_Channels.erase(entity);
|
m_Channels.erase(entity);
|
||||||
//m_Sounds.erase(entity);
|
m_Sounds.erase(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,13 +24,12 @@ public:
|
|||||||
SoundSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
SoundSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||||
: System(world, eventBroker, resourceManager)
|
: System(world, eventBroker, resourceManager)
|
||||||
{ }
|
{ }
|
||||||
|
~SoundSystem();
|
||||||
void RegisterComponents(ComponentFactory* cf) override;
|
void RegisterComponents(ComponentFactory* cf) override;
|
||||||
void RegisterResourceTypes(std::shared_ptr<::ResourceManager> rm) override;
|
void RegisterResourceTypes(std::shared_ptr<::ResourceManager> rm) override;
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
void Update(double dt) override;
|
void Update(double dt) override;
|
||||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
//void OnComponentRemoved(std::string type, Component* component);
|
|
||||||
void OnComponentRemoved(EntityID entity, std::string type, Component* component) override;
|
void OnComponentRemoved(EntityID entity, std::string type, Component* component) override;
|
||||||
FMOD_SYSTEM* GetFMODSystem() const { return m_System; }
|
FMOD_SYSTEM* GetFMODSystem() const { return m_System; }
|
||||||
private:
|
private:
|
||||||
@@ -48,12 +47,13 @@ private:
|
|||||||
void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop);
|
void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop);
|
||||||
|
|
||||||
FMOD_SYSTEM* m_System;
|
FMOD_SYSTEM* m_System;
|
||||||
|
FMOD_BOOL m_isPlaying;
|
||||||
FMOD_CHANNEL* m_BGMChannel;
|
FMOD_CHANNEL* m_BGMChannel;
|
||||||
std::vector<EntityID> m_Listeners;
|
std::vector<EntityID> m_Listeners;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
||||||
//std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
|
||||||
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
||||||
|
std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
||||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,6 +30,32 @@ void Systems::TankSteeringSystem::Update(double dt)
|
|||||||
|
|
||||||
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
auto pEmitter = m_World->GetComponent<Components::ParticleEmitter>(entity);
|
||||||
|
if(pEmitter)
|
||||||
|
{
|
||||||
|
if(!m_World->GetComponent<Components::TankSteering>(parent))
|
||||||
|
return;
|
||||||
|
auto tankTransform = m_World->GetComponent<Components::Transform>(parent);
|
||||||
|
glm::vec2 velXZ = glm::vec2(tankTransform->Velocity.x, tankTransform->Velocity.z);
|
||||||
|
float speedMPDT = glm::length(velXZ);
|
||||||
|
if(speedMPDT < 1)
|
||||||
|
{
|
||||||
|
pEmitter->Emitting = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pEmitter->Emitting = true;
|
||||||
|
pEmitter->ScaleSpectrum.erase(pEmitter->ScaleSpectrum.begin());
|
||||||
|
float scale = speedMPDT / 20;
|
||||||
|
scale = glm::clamp(scale, 0.3f, 20.f);
|
||||||
|
pEmitter->ScaleSpectrum.push_back(glm::vec3(speedMPDT / 20));
|
||||||
|
float spawnFrequency = 1 / speedMPDT;
|
||||||
|
spawnFrequency = glm::clamp(spawnFrequency, 0.1f, 2.f);
|
||||||
|
pEmitter->SpawnFrequency = 1 / speedMPDT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
||||||
if(!tankSteeringComponent)
|
if(!tankSteeringComponent)
|
||||||
return;
|
return;
|
||||||
@@ -146,15 +172,6 @@ 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)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||||
@@ -226,33 +243,63 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
/*Events::CreateExplosion e;
|
/*Events::CreateExplosion e;
|
||||||
e.LifeTime = 1.5;
|
|
||||||
e.ParticleScale.push_back(1);
|
|
||||||
e.ParticleScale.push_back(6);
|
|
||||||
e.ParticlesToSpawn = 20;
|
e.ParticlesToSpawn = 20;
|
||||||
e.Position = shellTransform->Position;
|
e.Position = shellTransform->Position;
|
||||||
e.SpreadAngle = glm::radians<float>(180) / 4;
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
e.Speed = 3;
|
||||||
e.UseGoalVector = true;
|
e.SpreadAngle = glm::pi<float>();
|
||||||
e.GoalVelocity = glm::vec3(0,-12,0);
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
e.Speed = 12;
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
e.spritePath = "Textures/Sprites/Splash.png";
|
|
||||||
e.Color = glm::vec4(5.f,5.f,5.f,1);
|
|
||||||
|
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
e.LifeTime = 1.5;
|
e.LifeTime = 0.7;
|
||||||
e.ParticleScale.push_back(1);
|
e.ParticleScale.push_back(12);
|
||||||
e.ParticleScale.push_back(6);
|
e.ParticlesToSpawn = 10;
|
||||||
e.ParticlesToSpawn = 20;
|
|
||||||
e.Position = shellTransform->Position;
|
e.Position = shellTransform->Position;
|
||||||
e.SpreadAngle = glm::radians<float>(180)/ 4;
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
e.Speed = 17;
|
||||||
e.UseGoalVector = true;
|
e.SpreadAngle = glm::pi<float>();
|
||||||
e.GoalVelocity = glm::vec3(0,-12,0);
|
e.spritePath = "Textures/Sprites/Fire.png";
|
||||||
e.Speed = 12;
|
EventBroker->Publish(e);
|
||||||
e.spritePath = "Textures/Sprites/Splash.png";
|
e.LifeTime = 0.2;
|
||||||
e.Color = glm::vec4(1.f,1.f,1.f,1);
|
e.ParticleScale.push_back(1);
|
||||||
|
e.ParticleScale.push_back(15);
|
||||||
|
e.ParticlesToSpawn = 5;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 6;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/Blast1.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
EventBroker->Publish(e);*/
|
EventBroker->Publish(e);*/
|
||||||
|
|
||||||
|
// Events::CreateExplosion e;
|
||||||
|
// e.LifeTime = 1.5;
|
||||||
|
// e.ParticleScale.push_back(1);
|
||||||
|
// e.ParticleScale.push_back(6);
|
||||||
|
// e.ParticlesToSpawn = 20;
|
||||||
|
// e.Position = shellTransform->Position;
|
||||||
|
// e.SpreadAngle = glm::radians<float>(180) / 4;
|
||||||
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
// e.UseGoalVector = true;
|
||||||
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(5.f,5.f,5.f,1);
|
||||||
|
//
|
||||||
|
// EventBroker->Publish(e);
|
||||||
|
// e.LifeTime = 1.5;
|
||||||
|
// e.ParticleScale.push_back(1);
|
||||||
|
// e.ParticleScale.push_back(6);
|
||||||
|
// e.ParticlesToSpawn = 20;
|
||||||
|
// e.Position = shellTransform->Position;
|
||||||
|
// e.SpreadAngle = glm::radians<float>(180)/ 4;
|
||||||
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
// e.UseGoalVector = true;
|
||||||
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(1.f,1.f,1.f,1);
|
||||||
|
// EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Events::PlaySFX e;
|
Events::PlaySFX e;
|
||||||
@@ -460,10 +507,14 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
player->ID = playerID;
|
player->ID = playerID;
|
||||||
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
|
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
|
||||||
m_World->AddComponent<Components::Input>(tank);
|
m_World->AddComponent<Components::Input>(tank);
|
||||||
|
m_World->AddComponent<Components::Listener>(tank);
|
||||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||||
health->Amount = 100.f;
|
health->Amount = 100.f;
|
||||||
m_World->AddComponent<Components::Listener>(tank);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(tank);
|
auto shape = m_World->CreateEntity(tank);
|
||||||
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
@@ -549,6 +600,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f));
|
transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f));
|
||||||
auto cameraComp = m_World->AddComponent<Components::Camera>(cameraTower);
|
auto cameraComp = m_World->AddComponent<Components::Camera>(cameraTower);
|
||||||
cameraComp->FarClip = 2000.f;
|
cameraComp->FarClip = 2000.f;
|
||||||
|
|
||||||
|
|
||||||
/*auto follow = m_World->AddComponent<Components::Follow>(cameraTower);
|
/*auto follow = m_World->AddComponent<Components::Follow>(cameraTower);
|
||||||
follow->Entity = barrel;
|
follow->Entity = barrel;
|
||||||
follow->Distance = 15.f;
|
follow->Distance = 15.f;
|
||||||
@@ -597,31 +650,43 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, 2.375), 1, false);
|
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, 2.375), 1, false);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region DustParticles
|
||||||
|
|
||||||
|
std::vector<glm::vec3> ePos;
|
||||||
|
ePos.push_back(glm::vec3(-2, -1.7, 2.0));
|
||||||
|
ePos.push_back(glm::vec3(2, -1.7, 2.0));
|
||||||
|
ePos.push_back(glm::vec3(2, -1.7, -2.0));
|
||||||
|
ePos.push_back(glm::vec3(-2, -1.7, -2.0));
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
auto entity = m_World->CreateEntity(tank);
|
auto entity = m_World->CreateEntity(tank);
|
||||||
auto transformComponent = m_World->AddComponent<Components::Transform>(entity);
|
auto transformComponent = m_World->AddComponent<Components::Transform>(entity);
|
||||||
transformComponent->Position = glm::vec3(-2, -1.7, 2.0);
|
transformComponent->Position = ePos[i];
|
||||||
transformComponent->Scale = glm::vec3(3, 3, 3);
|
transformComponent->Scale = glm::vec3(3, 3, 3);
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
transformComponent->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||||
auto emitterComponent = m_World->AddComponent<Components::ParticleEmitter>(entity);
|
auto emitterComponent = m_World->AddComponent<Components::ParticleEmitter>(entity);
|
||||||
emitterComponent->SpawnCount = 2;
|
emitterComponent->SpawnCount = 1;
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
emitterComponent->SpawnFrequency = 0.1;
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
emitterComponent->SpreadAngle = glm::pi<float>();
|
||||||
emitterComponent->UseGoalVelocity = false;
|
emitterComponent->UseGoalVelocity = false;
|
||||||
emitterComponent->LifeTime = 0.5;
|
emitterComponent->LifeTime = 0.3;
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
emitterComponent->Speed = 3;
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
emitterComponent->Emitting = true;
|
||||||
m_World->CommitEntity(entity);
|
emitterComponent->Fade = true;
|
||||||
|
emitterComponent->ScaleSpectrum.push_back(glm::vec3(1));
|
||||||
|
//emitterComponent->Color = glm::vec4(1);
|
||||||
auto particleEntity = m_World->CreateEntity(entity);
|
auto particleEntity = m_World->CreateEntity(entity);
|
||||||
auto TEMP = m_World->AddComponent<Components::Transform>(particleEntity);
|
m_World->AddComponent<Components::Template>(particleEntity);
|
||||||
TEMP->Scale = glm::vec3(0);
|
m_World->AddComponent<Components::Transform>(particleEntity);
|
||||||
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEntity);
|
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEntity);
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
spriteComponent->SpriteFile = "Textures/Sprites/Dirt.png";
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
m_World->CommitEntity(particleEntity);
|
m_World->CommitEntity(particleEntity);
|
||||||
|
emitterComponent->ParticleTemplate = particleEntity;
|
||||||
|
m_World->CommitEntity(entity);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
m_World->CommitEntity(tank);
|
m_World->CommitEntity(tank);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Events/TankSteer.h"
|
#include "Events/TankSteer.h"
|
||||||
#include "Events/SetVelocity.h"
|
#include "Events/SetVelocity.h"
|
||||||
@@ -24,6 +23,7 @@
|
|||||||
#include "Components/TankShell.h"
|
#include "Components/TankShell.h"
|
||||||
#include "Components/SphereShape.h"
|
#include "Components/SphereShape.h"
|
||||||
#include "Components/Listener.h"
|
#include "Components/Listener.h"
|
||||||
|
#include "Components/SoundEmitter.h"
|
||||||
|
|
||||||
#include "Events/EnableCollisions.h"
|
#include "Events/EnableCollisions.h"
|
||||||
#include "Events/DisableCollisions.h"
|
#include "Events/DisableCollisions.h"
|
||||||
|
|||||||
@@ -650,6 +650,8 @@
|
|||||||
<ClInclude Include="..\..\src\Components\DamageModel.h">
|
<ClInclude Include="..\..\src\Components\DamageModel.h">
|
||||||
<Filter>Rendering\Components</Filter>
|
<Filter>Rendering\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||||
|
|||||||
Reference in New Issue
Block a user