remove audiosourcecomponent

This commit is contained in:
Glence 2022-09-26 15:50:07 +08:00
parent 65a6014b1c
commit d0d796781b
6 changed files with 45 additions and 85 deletions

View File

@ -34,7 +34,8 @@ project "SHADE_Application"
"%{IncludeDir.VULKAN}/include",
"%{IncludeDir.VMA}/include",
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
"%{IncludeDir.fmod}/include"
"%{IncludeDir.fmod}/include",
"%{IncludeDir.RTTR}\\include"
}
externalwarnings "Off"

View File

@ -25,7 +25,6 @@
#include "Math/Transform/SHTransformSystem.h"
#include "Input/SHInputManagerSystem.h"
#include "AudioSystem/SHAudioSystem.h"
#include "AudioSystem/SHAudioSourceComponent.h"
#include "AudioSystem/SHAudioListenerComponent.h"
#include "Scenes/SBTestScene.h"
@ -81,7 +80,7 @@ namespace Sandbox
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHInputManagerSystem, SHADE::SHInputManagerSystem::InputManagerRoutine>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHAudioSystem, SHADE::SHAudioSystem::AudioRoutine>();
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHAudioSourceComponent>();
//SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHAudioSourceComponent>();
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHAudioListenerComponent>();
// Set up graphics system and windows

View File

@ -10,7 +10,7 @@
#include "SHpch.h"
#include "SHAudioListenerComponent.h"
//#include "ECS_Base/System/SHSystemManager.h"
#include "ECS_Base/Managers/SHSystemManager.h"
namespace SHADE
{
@ -34,22 +34,22 @@ namespace SHADE
return up;
}
void SHAudioListenerComponent::SetPos(SHVec3 p)
void SHAudioListenerComponent::SetPos(const SHVec3 p)
{
pos = p;
}
void SHAudioListenerComponent::SetVel(SHVec3 v)
void SHAudioListenerComponent::SetVel(const SHVec3 v)
{
vel = v;
}
void SHAudioListenerComponent::SetForward(SHVec3 f)
void SHAudioListenerComponent::SetForward(const SHVec3 f)
{
forward = f;
}
void SHAudioListenerComponent::SetUp(SHVec3 u)
void SHAudioListenerComponent::SetUp(const SHVec3 u)
{
up = u;
}

View File

@ -24,16 +24,15 @@ namespace SHADE
~SHAudioListenerComponent() = default;
const SHVec3 GetPos() const;
void SetPos(const SHVec3 p);
const SHVec3 GetVel() const;
const SHVec3 GetForward() const;
const SHVec3 GetUp() const;
void SetPos(SHVec3 p);
void SetVel(SHVec3 v);
void SetForward(SHVec3 f);
void SetUp(SHVec3 u);
void SetVel(const SHVec3 v);
void SetForward(const SHVec3 f);
void SetUp(const SHVec3 u);
private:
SHVec3 pos{}, vel{}, forward{}, up{ 0.f,1.f,0.f };

View File

@ -15,75 +15,39 @@
namespace SHADE
{
/**
* @brief play the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::PlaySoundSFX(EntityID id, bool loop, bool spatial, float min , float max )
{
SHSystemManager::GetSystem<SHAudioSystem>()->PlaySFX(id, GetEID(),loop,spatial, min, max);
}
/**
* @brief play the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::PlaySoundSFX(EntityID id, bool loop, bool spatial, float min , float max )
{
SHSystemManager::GetSystem<SHAudioSystem>()->PlaySFX(id, GetEID(),loop,spatial, min, max);
}
//void SHAudioSourceComponent::PlayOneShot(const char* path, bool isSFX, bool spatial)
//{
// auto AudioSystem = dynamic_cast<SHAudioSystem*>(SHSystemManager::GetSystem("Audio"));
// AudioSystem->PlayEventOnce(path, isSFX, spatial ? GetEID() : MAX_EID, spatial);
//}
void SHAudioSourceComponent::PlaySoundBGM(EntityID id, bool loop, bool spatial, float min, float max)
{
SHSystemManager::GetSystem<SHAudioSystem>()->PlayBGM(id, GetEID(), loop, spatial, min, max);
}
//void SHAudioSourceComponent::PlayEvent(const char* path, bool isSFX, bool spatial)
//{
// auto AudioSystem = dynamic_cast<SHAudioSystem*>(SHSystemManager::GetSystem("Audio"));
/**
* @brief Stop the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::StopSound(EntityID id)
{
SHSystemManager::GetSystem<SHAudioSystem>()->StopSound(id);
}
// auto guid = AudioSystem->GetEventGUID(path);
// if (guid.has_value())
// {
// if (FMOD::Studio::EventInstance* instance = AudioSystem->CreateEventInstance(guid.value()))
// {
// eventInstances.push_back(instance);
// AudioSystem->PlayEventInstance(instance, isSFX, GetEID(), spatial);
// }
// }
//}
void SHAudioSourceComponent::PlaySoundBGM(EntityID id, bool loop, bool spatial, float min, float max)
{
SHSystemManager::GetSystem<SHAudioSystem>()->PlayBGM(id, GetEID(), loop, spatial, min, max);
}
/**
* @brief Stop the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::StopSound(EntityID id)
{
SHSystemManager::GetSystem<SHAudioSystem>()->StopSound(id);
}
/**
* @brief Mute the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::SetMute(EntityID id, bool mute)
{
SHSystemManager::GetSystem<SHAudioSystem>()->SetMute(id, mute);
}
//void SHAudioSourceComponent::PlayEventInstance(size_t index, bool isSFX, bool spatial)
//{
// if (index < eventInstances.size())
// {
// eventInstances[index]->start();
// dynamic_cast<SHAudioSystem*>(SHSystemManager::GetSystem("Audio"))->PlayEventInstance(eventInstances[index], isSFX, GetEID(), spatial);
// }
//}
//void SHAudioSourceComponent::StopEventInstance(size_t index)
//{
// if(index < eventInstances.size())
// eventInstances[index]->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
//}
/**
* @brief Mute the sound
*
* @param index where the sound is in the index
*/
void SHAudioSourceComponent::SetMute(EntityID id, bool mute)
{
SHSystemManager::GetSystem<SHAudioSystem>()->SetMute(id, mute);
}
}

View File

@ -1,5 +1,4 @@
#include "SHpch.h"
//#include "ECS_Base/System/SHSystemManager.h"
#include "SHAudioSystem.h"
#include "Scene/SHSceneManager.h"
#include "ECS_Base/Managers/SHComponentManager.h"
@ -10,8 +9,6 @@
#include "AudioSystem/SHAudioListenerComponent.h"
#include "AudioSystem/SHAudioSourceComponent.h"
//#include "ECS_Base/System/SHComponentManager.h"
//#include "Resource Manager/SHResourceManager.h"
#include "Math/Transform/SHTransformComponent.h"
#pragma warning(push)
#pragma warning(disable:26812) //disable warning about preference of enum class over enum as ImGuizmo uses enums
@ -29,7 +26,7 @@ namespace SHADE
, masterGroup(nullptr)
, audioChannels()
, result(FMOD_RESULT_FORCEINT)
, bgmVolume(0.5F)
, bgmVolume(1.F)
, sfxVolume(1.F)
, masterVolume(1.0F)
, version(0)