added the new banks
added onplay/onpause/onstop for audiosytem
This commit is contained in:
parent
7d2435131f
commit
0551b1fb8a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -81,6 +81,7 @@ public class PlayerController : Script
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||||
//default setup
|
//default setup
|
||||||
isMoveKeyPress = false;
|
isMoveKeyPress = false;
|
||||||
holdItem = false;
|
holdItem = false;
|
||||||
|
@ -135,6 +136,7 @@ public class PlayerController : Script
|
||||||
{
|
{
|
||||||
//Rotation();
|
//Rotation();
|
||||||
|
|
||||||
|
|
||||||
MoveKey();
|
MoveKey();
|
||||||
Move();
|
Move();
|
||||||
Sprint();
|
Sprint();
|
||||||
|
|
|
@ -84,12 +84,32 @@ namespace SHADE
|
||||||
LoadBank((AUDIO_FOLDER_PATH + "Master.bank").data());
|
LoadBank((AUDIO_FOLDER_PATH + "Master.bank").data());
|
||||||
LoadBank((AUDIO_FOLDER_PATH + "Master.strings.bank").data());
|
LoadBank((AUDIO_FOLDER_PATH + "Master.strings.bank").data());
|
||||||
//LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
|
//LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
|
||||||
LoadBank((AUDIO_FOLDER_PATH + "footsteps.bank").data());
|
//LoadBank((AUDIO_FOLDER_PATH + "footsteps.bank").data());
|
||||||
|
LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
|
||||||
|
LoadBank((AUDIO_FOLDER_PATH + "SFX.bank").data());
|
||||||
|
LoadBank((AUDIO_FOLDER_PATH + "UI.bank").data());
|
||||||
|
|
||||||
//auto clip = CreateAudioClip("event:/Characters/sfx_footsteps_human");
|
//auto clip = CreateAudioClip("event:/Characters/sfx_footsteps_human");
|
||||||
//clip->Play();
|
//clip->Play();
|
||||||
//PlayEventOnce("event:/Characters/sfx_footsteps_raccoon");
|
//PlayEventOnce("event:/Characters/sfx_footsteps_raccoon");
|
||||||
//PlayEventOnce("event:/SFX/Dawn/Dawn_Attack");
|
//PlayEventOnce("event:/SFX/Dawn/Dawn_Attack");
|
||||||
|
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
|
// Subscribe to Editor State Change Events
|
||||||
|
const std::shared_ptr ON_PLAY_RECEIVER{ std::make_shared<SHEventReceiverSpec<SHAudioSystem>>(this, &SHAudioSystem::onPlay) };
|
||||||
|
const ReceiverPtr ON_PLAY_RECEIVER_PTR = std::dynamic_pointer_cast<SHEventReceiver>(ON_PLAY_RECEIVER);
|
||||||
|
SHEventManager::SubscribeTo(SH_EDITOR_ON_PLAY_EVENT, ON_PLAY_RECEIVER_PTR);
|
||||||
|
|
||||||
|
const std::shared_ptr ON_STOP_RECEIVER{ std::make_shared<SHEventReceiverSpec<SHAudioSystem>>(this, &SHAudioSystem::onStop) };
|
||||||
|
const ReceiverPtr ON_STOP_RECEIVER_PTR = std::dynamic_pointer_cast<SHEventReceiver>(ON_STOP_RECEIVER);
|
||||||
|
SHEventManager::SubscribeTo(SH_EDITOR_ON_STOP_EVENT, ON_STOP_RECEIVER_PTR);
|
||||||
|
|
||||||
|
const std::shared_ptr ON_PAUSE_RECEIVER{ std::make_shared<SHEventReceiverSpec<SHAudioSystem>>(this, &SHAudioSystem::onPause) };
|
||||||
|
const ReceiverPtr ON_PAUSE_RECEIVER_PTR = std::dynamic_pointer_cast<SHEventReceiver>(ON_PAUSE_RECEIVER);
|
||||||
|
SHEventManager::SubscribeTo(SH_EDITOR_ON_PAUSE_EVENT, ON_PAUSE_RECEIVER_PTR);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHADE::SHAudioSystem::Run(double dt)
|
void SHADE::SHAudioSystem::Run(double dt)
|
||||||
|
@ -179,7 +199,6 @@ namespace SHADE
|
||||||
it->second->createInstance(&event);
|
it->second->createInstance(&event);
|
||||||
if (event)
|
if (event)
|
||||||
{
|
{
|
||||||
|
|
||||||
event->setVolume(masterVolume * (isSFX ? sfxVolume : bgmVolume));
|
event->setVolume(masterVolume * (isSFX ? sfxVolume : bgmVolume));
|
||||||
if (spatial)
|
if (spatial)
|
||||||
{
|
{
|
||||||
|
@ -285,6 +304,7 @@ namespace SHADE
|
||||||
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
|
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
|
||||||
channel->stop();
|
channel->stop();
|
||||||
}
|
}
|
||||||
|
masterGroup->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<FMOD_GUID> SHAudioSystem::GetEventGUID(const char* path)
|
std::optional<FMOD_GUID> SHAudioSystem::GetEventGUID(const char* path)
|
||||||
|
@ -410,6 +430,7 @@ namespace SHADE
|
||||||
void SHAudioSystem::SetPaused(bool pause)
|
void SHAudioSystem::SetPaused(bool pause)
|
||||||
{
|
{
|
||||||
paused = pause;
|
paused = pause;
|
||||||
|
masterGroup->setPaused(pause);
|
||||||
for (auto const& channel : audioChannels)
|
for (auto const& channel : audioChannels)
|
||||||
{
|
{
|
||||||
channel->setPaused(paused);
|
channel->setPaused(paused);
|
||||||
|
@ -552,6 +573,27 @@ namespace SHADE
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)
|
||||||
|
{
|
||||||
|
StopAllSounds();
|
||||||
|
|
||||||
|
return onStopEvent->handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHAudioSystem::onPause(SHEventPtr onStopEvent)
|
||||||
|
{
|
||||||
|
SetPaused(true);
|
||||||
|
|
||||||
|
return onStopEvent->handle;
|
||||||
|
}
|
||||||
|
SHEventHandle SHAudioSystem::onPlay(SHEventPtr onStopEvent)
|
||||||
|
{
|
||||||
|
if(GetPaused())
|
||||||
|
SetPaused(false);
|
||||||
|
|
||||||
|
return onStopEvent->handle;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "Math/Vector/SHVec3.h"
|
#include "Math/Vector/SHVec3.h"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <FMOD/fmod_studio.hpp>
|
#include <FMOD/fmod_studio.hpp>
|
||||||
|
#include "Events/SHEvent.h"
|
||||||
|
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#define AUDIO_SYS_MAX_CHANNELS 1024
|
#define AUDIO_SYS_MAX_CHANNELS 1024
|
||||||
|
|
||||||
|
@ -104,6 +106,10 @@ namespace SHADE
|
||||||
|
|
||||||
std::vector<SHAudioListenerComponent>* denseListener;
|
std::vector<SHAudioListenerComponent>* denseListener;
|
||||||
AudioClipID clipID = 0;
|
AudioClipID clipID = 0;
|
||||||
|
|
||||||
|
SHEventHandle onPlay(SHEventPtr onStopEvent);
|
||||||
|
SHEventHandle onStop(SHEventPtr onStopEvent);
|
||||||
|
SHEventHandle onPause(SHEventPtr onStopEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Camera/SHCameraComponent.h"
|
#include "Camera/SHCameraComponent.h"
|
||||||
#include "Camera/SHCameraArmComponent.h"
|
#include "Camera/SHCameraArmComponent.h"
|
||||||
#include "SHEditorComponentView.h"
|
#include "SHEditorComponentView.h"
|
||||||
|
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -128,10 +129,16 @@ namespace SHADE
|
||||||
if (auto cameraComponent = SHComponentManager::GetComponent_s<SHCameraComponent>(eid))
|
if (auto cameraComponent = SHComponentManager::GetComponent_s<SHCameraComponent>(eid))
|
||||||
{
|
{
|
||||||
DrawComponent(cameraComponent);
|
DrawComponent(cameraComponent);
|
||||||
}if (auto cameraArmComponent = SHComponentManager::GetComponent_s<SHCameraArmComponent>(eid))
|
}
|
||||||
|
if (auto cameraArmComponent = SHComponentManager::GetComponent_s<SHCameraArmComponent>(eid))
|
||||||
{
|
{
|
||||||
DrawComponent(cameraArmComponent);
|
DrawComponent(cameraArmComponent);
|
||||||
}
|
}
|
||||||
|
if (auto listenerComponent = SHComponentManager::GetComponent_s<SHAudioListenerComponent>(eid))
|
||||||
|
{
|
||||||
|
DrawComponent(listenerComponent);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
// Render Scripts
|
// Render Scripts
|
||||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||||
|
@ -143,6 +150,7 @@ namespace SHADE
|
||||||
DrawAddComponentButton<SHCameraComponent>(eid);
|
DrawAddComponentButton<SHCameraComponent>(eid);
|
||||||
DrawAddComponentButton<SHCameraArmComponent>(eid);
|
DrawAddComponentButton<SHCameraArmComponent>(eid);
|
||||||
DrawAddComponentButton<SHLightComponent>(eid);
|
DrawAddComponentButton<SHLightComponent>(eid);
|
||||||
|
DrawAddComponentButton<SHAudioListenerComponent>(eid);
|
||||||
|
|
||||||
// Components that require Transforms
|
// Components that require Transforms
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue