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()
|
||||
{
|
||||
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||
//default setup
|
||||
isMoveKeyPress = false;
|
||||
holdItem = false;
|
||||
|
@ -135,6 +136,7 @@ public class PlayerController : Script
|
|||
{
|
||||
//Rotation();
|
||||
|
||||
|
||||
MoveKey();
|
||||
Move();
|
||||
Sprint();
|
||||
|
|
|
@ -84,12 +84,32 @@ namespace SHADE
|
|||
LoadBank((AUDIO_FOLDER_PATH + "Master.bank").data());
|
||||
LoadBank((AUDIO_FOLDER_PATH + "Master.strings.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");
|
||||
//clip->Play();
|
||||
//PlayEventOnce("event:/Characters/sfx_footsteps_raccoon");
|
||||
//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)
|
||||
|
@ -179,7 +199,6 @@ namespace SHADE
|
|||
it->second->createInstance(&event);
|
||||
if (event)
|
||||
{
|
||||
|
||||
event->setVolume(masterVolume * (isSFX ? sfxVolume : bgmVolume));
|
||||
if (spatial)
|
||||
{
|
||||
|
@ -285,6 +304,7 @@ namespace SHADE
|
|||
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
|
||||
channel->stop();
|
||||
}
|
||||
masterGroup->stop();
|
||||
}
|
||||
|
||||
std::optional<FMOD_GUID> SHAudioSystem::GetEventGUID(const char* path)
|
||||
|
@ -410,6 +430,7 @@ namespace SHADE
|
|||
void SHAudioSystem::SetPaused(bool pause)
|
||||
{
|
||||
paused = pause;
|
||||
masterGroup->setPaused(pause);
|
||||
for (auto const& channel : audioChannels)
|
||||
{
|
||||
channel->setPaused(paused);
|
||||
|
@ -552,6 +573,27 @@ namespace SHADE
|
|||
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)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "Math/Vector/SHVec3.h"
|
||||
#include <optional>
|
||||
#include <FMOD/fmod_studio.hpp>
|
||||
#include "Events/SHEvent.h"
|
||||
|
||||
#include "SH_API.h"
|
||||
#define AUDIO_SYS_MAX_CHANNELS 1024
|
||||
|
||||
|
@ -104,6 +106,10 @@ namespace SHADE
|
|||
|
||||
std::vector<SHAudioListenerComponent>* denseListener;
|
||||
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/SHCameraArmComponent.h"
|
||||
#include "SHEditorComponentView.h"
|
||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -128,10 +129,16 @@ namespace SHADE
|
|||
if (auto cameraComponent = SHComponentManager::GetComponent_s<SHCameraComponent>(eid))
|
||||
{
|
||||
DrawComponent(cameraComponent);
|
||||
}if (auto cameraArmComponent = SHComponentManager::GetComponent_s<SHCameraArmComponent>(eid))
|
||||
}
|
||||
if (auto cameraArmComponent = SHComponentManager::GetComponent_s<SHCameraArmComponent>(eid))
|
||||
{
|
||||
DrawComponent(cameraArmComponent);
|
||||
}
|
||||
if (auto listenerComponent = SHComponentManager::GetComponent_s<SHAudioListenerComponent>(eid))
|
||||
{
|
||||
DrawComponent(listenerComponent);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
// Render Scripts
|
||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||
|
@ -143,6 +150,7 @@ namespace SHADE
|
|||
DrawAddComponentButton<SHCameraComponent>(eid);
|
||||
DrawAddComponentButton<SHCameraArmComponent>(eid);
|
||||
DrawAddComponentButton<SHLightComponent>(eid);
|
||||
DrawAddComponentButton<SHAudioListenerComponent>(eid);
|
||||
|
||||
// Components that require Transforms
|
||||
|
||||
|
|
Loading…
Reference in New Issue