diff --git a/src/Components/Vehicle.h b/src/Components/Vehicle.h index 9f6cfac..431d7b4 100644 --- a/src/Components/Vehicle.h +++ b/src/Components/Vehicle.h @@ -12,7 +12,7 @@ struct Vehicle : Component Vehicle() : MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f), MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.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 MinRPM; float OptimalRPM; @@ -29,6 +29,7 @@ struct Vehicle : Component float gearsRatio1; float gearsRatio2; float gearsRatio3; + float currentRPM; Vehicle* Clone() const override { return new Vehicle(*this); } }; diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 3db178b..4633ace 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -253,7 +253,8 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p } }*/ - + auto vehicleComponent = m_World->GetComponent(car); + vehicleComponent->currentRPM = m_Vehicles[car]->calcRPM(); m_Vehicles[car]->getChassis()->activate(); diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index c60a36a..b0cb49e 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -57,7 +57,7 @@ void Systems::SoundSystem::Update(double dt) else { // FMOD_Sound_Release(m_DeleteSounds[it->first]); -// m_DeleteSounds.erase(it->first); + m_DeleteSounds.erase(it->first); it = m_DeleteChannels.erase(it); } @@ -104,7 +104,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(entity); glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity); @@ -137,9 +137,9 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev float maxDist = emitter->MaxDistance; float minDist = emitter->MinDistance; float pitch = emitter->Pitch; - //LoadSound(sound, path, maxDist, minDist); + 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; } @@ -157,7 +157,7 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = ResourceManager->Load("Sound3D", event.Resource); - //m_Sounds[eEntity] = *sound; + m_Sounds[eEntity] = *sound; FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance); PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop); @@ -181,6 +181,8 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event) return true; } + + bool Systems::SoundSystem::StopSound(const Events::StopSound &event) { auto eComp = m_World->GetComponent(event.Emitter); @@ -222,8 +224,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); } } \ No newline at end of file diff --git a/src/Systems/SoundSystem.h b/src/Systems/SoundSystem.h index 6d3b48d..8803e0e 100755 --- a/src/Systems/SoundSystem.h +++ b/src/Systems/SoundSystem.h @@ -53,6 +53,7 @@ private: std::map m_Channels; std::map m_DeleteChannels; std::map m_DeleteSounds; + std::map m_Sounds; std::shared_ptr m_TransformSystem; }; diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 4f8c2b3..dec2d67 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -445,9 +445,12 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) player->ID = playerID; auto tankSteering = m_World->AddComponent(tank); m_World->AddComponent(tank); + m_World->AddComponent(tank); auto health = m_World->AddComponent(tank); health->Amount = 100.f; - m_World->AddComponent(tank); + + + { @@ -535,6 +538,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f)); auto cameraComp = m_World->AddComponent(cameraTower); cameraComp->FarClip = 2000.f; + + /*auto follow = m_World->AddComponent(cameraTower); follow->Entity = barrel; follow->Distance = 15.f;