Merge remote-tracking branch 'origin/master' into havok
Conflicts: vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
@@ -20,7 +20,7 @@ bool Systems::DebugSystem::OnKeyDown(const Events::KeyDown &event)
|
||||
if (event.KeyCode == GLFW_KEY_ENTER)
|
||||
{
|
||||
Events::PlaySFX e;
|
||||
e.Emitter = 0;
|
||||
e.Position = glm::vec3(0);
|
||||
e.Resource = "Sounds/korvring.wav";
|
||||
EventBroker->Publish<Events::PlaySFX>(e);
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||
transformComponent->Position -= absoluteTransformParent.Position;
|
||||
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
|
||||
transformComponent->Orientation = absoluteTransformParent.Orientation * glm::inverse(transformComponent->Orientation);
|
||||
transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-28
@@ -20,7 +20,7 @@ void Systems::SoundSystem::Initialize()
|
||||
{
|
||||
LOG_INFO("FMOD initialized successfully");
|
||||
}
|
||||
FMOD_System_Set3DSettings(m_System, 1.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
||||
FMOD_System_Set3DSettings(m_System, 0.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
||||
|
||||
}
|
||||
|
||||
@@ -44,20 +44,31 @@ void Systems::SoundSystem::Update(double dt)
|
||||
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
||||
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
||||
{
|
||||
FMOD_BOOL *isPlaying = false;
|
||||
FMOD_Channel_IsPlaying(it->second, isPlaying);
|
||||
FMOD_BOOL isPlaying = false;
|
||||
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
||||
if(isPlaying)
|
||||
{
|
||||
it++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
||||
m_DeleteSounds.erase(it->first);
|
||||
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
||||
// m_DeleteSounds.erase(it->first);
|
||||
it = m_DeleteChannels.erase(it);
|
||||
}
|
||||
|
||||
}
|
||||
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
||||
for (auto channel : m_Channels)
|
||||
{
|
||||
FMOD_BOOL isPlaying = false;
|
||||
FMOD_Channel_IsPlaying(channel.second, &isPlaying);
|
||||
if(!isPlaying)
|
||||
{
|
||||
m_Channels.erase(channel.first);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
@@ -86,7 +97,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
||||
if(emitter)
|
||||
{
|
||||
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);
|
||||
|
||||
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
||||
@@ -121,34 +132,28 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev
|
||||
float pitch = emitter->Pitch;
|
||||
//LoadSound(sound, path, maxDist, minDist);
|
||||
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;
|
||||
}
|
||||
|
||||
bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
||||
{
|
||||
auto emitter = m_World->GetComponent<Components::SoundEmitter>(event.Emitter);
|
||||
if(!emitter)
|
||||
{
|
||||
LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter];
|
||||
return false;
|
||||
}
|
||||
auto eEntity = m_World->CreateEntity();
|
||||
auto eTransform = m_World->AddComponent<Components::Transform>(eEntity);
|
||||
eTransform->Position = event.Position;
|
||||
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(eEntity);
|
||||
eComponent->MinDistance = event.MinDistance;
|
||||
eComponent->MaxDistance= event.MaxDistance;
|
||||
eComponent->Loop = event.Loop;
|
||||
eComponent->Gain = event.Volume;
|
||||
|
||||
emitter->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
||||
m_Sounds[event.Emitter] = *sound;
|
||||
FMOD_Sound_Set3DMinMaxDistance(*sound, emitter->MinDistance, emitter->MaxDistance);
|
||||
//m_Sounds[eEntity] = *sound;
|
||||
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
|
||||
|
||||
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
||||
FMOD_System_Update(m_System);
|
||||
|
||||
FMOD_BOOL isPlaying = false;
|
||||
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
||||
if(!isPlaying)
|
||||
LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str());
|
||||
else
|
||||
LOG_INFO("Now playing sound %s", event.Resource.c_str());
|
||||
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,7 +165,7 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
||||
m_Channels[emitter] = m_BGMChannel;
|
||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
||||
m_Sounds[emitter] = *sound;
|
||||
//m_Sounds[emitter] = *sound;
|
||||
|
||||
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
||||
return true;
|
||||
@@ -199,8 +204,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type,
|
||||
if(emitter)
|
||||
{
|
||||
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_Sounds.erase(entity);
|
||||
//m_Sounds.erase(entity);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
std::vector<EntityID> m_Listeners;
|
||||
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
||||
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
||||
std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
||||
//std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
||||
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
|
||||
|
||||
@@ -90,12 +90,48 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
||||
cloneTransform->Position = templateAbsoluteTransform.Position;
|
||||
cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation;
|
||||
|
||||
Events::SetVelocity eSetVelocity;
|
||||
eSetVelocity.Entity = clone;
|
||||
eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed);
|
||||
EventBroker->Publish(eSetVelocity);
|
||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0;
|
||||
|
||||
{
|
||||
Events::CreateExplosion e;
|
||||
e.LifeTime = 1.5;
|
||||
e.ParticleScale.push_back(0.6);
|
||||
e.ParticleScale.push_back(1.8);
|
||||
e.ParticlesToSpawn = 5;
|
||||
e.Position = cloneTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 1.7;
|
||||
e.SpreadAngle = glm::pi<float>()/10;
|
||||
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
Events::CreateExplosion e;
|
||||
e.LifeTime = 0.2;
|
||||
e.ParticleScale.push_back(1);
|
||||
//e.ParticleScale.push_back(2);
|
||||
e.ParticlesToSpawn = 1;
|
||||
e.Position = cloneTransform->Position;
|
||||
e.Speed = 0;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/MuzzleFlash.png";
|
||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
{
|
||||
Events::PlaySFX e;
|
||||
e.Resource = "Sounds/SFX/TankShot.mp3";
|
||||
e.Position = cloneTransform->Position;
|
||||
e.Loop = false;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
auto clonePhysicsComponent = m_World->GetComponent<Components::Physics>(clone);
|
||||
//1,670m/s
|
||||
@@ -109,6 +145,15 @@ 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)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||
@@ -179,6 +224,13 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
Events::PlaySFX e;
|
||||
e.MinDistance = 150.f;
|
||||
e.Position = shellTransform->Position;
|
||||
e.Resource = "Sounds/SFX/Explosion.wav";
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
for (auto &physComponent : *physicsComponents)
|
||||
{
|
||||
@@ -300,11 +352,11 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto &spawnPointComponent : *spawnPointComponents)
|
||||
for (auto &component : *spawnPointComponents)
|
||||
{
|
||||
auto spawnPoint = spawnPointComponent->Entity;
|
||||
auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint);
|
||||
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointBaseParent);
|
||||
auto spawnPoint = component->Entity;
|
||||
auto spawnPointComponent = std::dynamic_pointer_cast<Components::SpawnPoint>(component);
|
||||
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointComponent->Player);
|
||||
if (!playerComponent || playerComponent->ID != event.PlayerID)
|
||||
continue;
|
||||
|
||||
@@ -359,6 +411,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
||||
m_World->AddComponent<Components::Input>(tank);
|
||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||
health->Amount = 100.f;
|
||||
m_World->AddComponent<Components::Listener>(tank);
|
||||
|
||||
{
|
||||
auto shape = m_World->CreateEntity(tank);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Components/Health.h"
|
||||
#include "Components/TankShell.h"
|
||||
#include "Components/SphereShape.h"
|
||||
#include "Components/Listener.h"
|
||||
|
||||
#include "Events/EnableCollisions.h"
|
||||
#include "Events/DisableCollisions.h"
|
||||
@@ -29,6 +30,9 @@
|
||||
#include "Components/TriggerExplosion.h"
|
||||
#include "Components/FrameTimer.h"
|
||||
|
||||
#include "Events/PlaySFX.h"
|
||||
#include "Events/PlayBGM.h"
|
||||
|
||||
#include "Events/Damage.h"
|
||||
#include "Components/Vehicle.h"
|
||||
#include "Components/Player.h"
|
||||
|
||||
Reference in New Issue
Block a user