From da8bacc45c7075ce10b5a0bec0248955750b0797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=88ric=20Canela?= Date: Wed, 22 Apr 2020 16:10:54 +0200 Subject: [PATCH 1/5] scripting changes --- Broken Engine/Source/ScriptingAudio.cpp | 53 ++++++++++++++---------- Broken Engine/Source/ScriptingAudio.h | 10 ++--- Broken Engine/Source/ScriptingScenes.cpp | 2 + 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Broken Engine/Source/ScriptingAudio.cpp b/Broken Engine/Source/ScriptingAudio.cpp index d7d737e31..2b91fe520 100644 --- a/Broken Engine/Source/ScriptingAudio.cpp +++ b/Broken Engine/Source/ScriptingAudio.cpp @@ -6,6 +6,7 @@ #include "ModuleScripting.h" #include "ModuleRenderer3D.h" #include "ModuleAudio.h" +#include "ModuleSceneManager.h" // -- Components -- #include "GameObject.h" @@ -15,6 +16,8 @@ #include "ComponentAnimation.h" #include "ComponentCamera.h" #include "ComponentAudioSource.h" +#include "ResourceScene.h" + #include "../Game/Assets/Sounds/Wwise_IDs.h" @@ -26,9 +29,12 @@ ScriptingAudio::ScriptingAudio() {} ScriptingAudio::~ScriptingAudio() {} -void ScriptingAudio::SetVolume(float volume) +void ScriptingAudio::SetVolume(float volume, uint UID) { - ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); + ComponentAudioSource* sound = nullptr; + if (GO) + sound = GO->GetComponent(); if (sound) sound->SetVolume(volume); @@ -36,18 +42,17 @@ void ScriptingAudio::SetVolume(float volume) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::PlayAudioEvent(std::string event) +void ScriptingAudio::PlayAudioEvent(std::string event, uint UID) { + GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; - sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - + if (GO) + sound = GO->GetComponent(); uint EventId = App->audio->EventMap[event]; - - sound->SetID(EventId); - if (sound) { + sound->SetID(EventId); sound->wwiseGO->PlayEvent(EventId); sound->isPlaying = true; } @@ -55,16 +60,17 @@ void ScriptingAudio::PlayAudioEvent(std::string event) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::StopAudioEvent(std::string event) +void ScriptingAudio::StopAudioEvent(std::string event, uint UID) { - ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - + GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); + ComponentAudioSource* sound = nullptr; + if (GO) + sound = GO->GetComponent(); uint EventId = App->audio->EventMap[event]; - sound->SetID(EventId); - if (sound) { + sound->SetID(EventId); sound->wwiseGO->StopEvent(EventId); sound->isPlaying = false; } @@ -72,16 +78,17 @@ void ScriptingAudio::StopAudioEvent(std::string event) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::PauseAudioEvent(std::string event) +void ScriptingAudio::PauseAudioEvent(std::string event, uint UID) { - ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - + GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); + ComponentAudioSource* sound = nullptr; + if (GO) + sound = GO->GetComponent(); uint EventId = App->audio->EventMap[event]; - sound->SetID(EventId); - if (sound) { + sound->SetID(EventId); sound->wwiseGO->PauseEvent(EventId); sound->isPlaying = false; sound->isPaused = true; @@ -90,16 +97,18 @@ void ScriptingAudio::PauseAudioEvent(std::string event) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::ResumeAudioEvent(std::string event) +void ScriptingAudio::ResumeAudioEvent(std::string event,uint UID) { - ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); + ComponentAudioSource* sound = nullptr; + if(GO) + sound = GO->GetComponent(); uint EventId = App->audio->EventMap[event]; - sound->SetID(EventId); - if (sound) { + sound->SetID(EventId); sound->wwiseGO->ResumeEvent(EventId); sound->isPlaying = true; sound->isPaused = false; diff --git a/Broken Engine/Source/ScriptingAudio.h b/Broken Engine/Source/ScriptingAudio.h index da483bd39..6bb8faa8a 100644 --- a/Broken Engine/Source/ScriptingAudio.h +++ b/Broken Engine/Source/ScriptingAudio.h @@ -10,11 +10,11 @@ class BROKEN_API ScriptingAudio { ~ScriptingAudio(); public: - void SetVolume(float volume); - void PlayAudioEvent(std::string event); - void StopAudioEvent(std::string event); - void PauseAudioEvent(std::string event); - void ResumeAudioEvent(std::string event); + void SetVolume(float volume, uint UID); + void PlayAudioEvent(std::string event, uint UID); + void StopAudioEvent(std::string event, uint UID); + void PauseAudioEvent(std::string event, uint UID); + void ResumeAudioEvent(std::string event,uint UID); }; BE_END_NAMESPACE diff --git a/Broken Engine/Source/ScriptingScenes.cpp b/Broken Engine/Source/ScriptingScenes.cpp index 01692137d..04db6ac4b 100644 --- a/Broken Engine/Source/ScriptingScenes.cpp +++ b/Broken Engine/Source/ScriptingScenes.cpp @@ -19,7 +19,9 @@ ScriptingScenes::~ScriptingScenes() {} void ScriptingScenes::LoadSceneFromScript(uint scene_UUID) { ResourceScene* scene = (ResourceScene*)App->resources->GetResource(scene_UUID, false); + App->GetAppState() = Broken::AppState::PAUSE; App->scene_manager->SetActiveScene(scene); + App->GetAppState() = Broken::AppState::PLAY; } void ScriptingScenes::QuitGame() From a009b629ae66f92a91782327ff1f2929f5034e15 Mon Sep 17 00:00:00 2001 From: Aitor Simona Bouzas Date: Wed, 22 Apr 2020 16:51:01 +0200 Subject: [PATCH 2/5] Added Resume function to Timer --- Broken Engine/Source/Timer.cpp | 6 ++++++ Broken Engine/Source/Timer.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Broken Engine/Source/Timer.cpp b/Broken Engine/Source/Timer.cpp index 3e24848b8..bca0d6252 100644 --- a/Broken Engine/Source/Timer.cpp +++ b/Broken Engine/Source/Timer.cpp @@ -23,6 +23,12 @@ void Timer::Stop() { stopped_at = SDL_GetTicks(); } +void Timer::Resume() +{ + running = true; + started_at += SDL_GetTicks() - stopped_at; +} + // --------------------------------------------- Uint32 Timer::Read() { if (running == true) { diff --git a/Broken Engine/Source/Timer.h b/Broken Engine/Source/Timer.h index 3c4949ecc..2a19d6016 100644 --- a/Broken Engine/Source/Timer.h +++ b/Broken Engine/Source/Timer.h @@ -13,6 +13,7 @@ class BROKEN_API Timer { void Start(); void Stop(); + void Resume(); Uint32 Read(); From 9938d4d3906d47a8d79dd7640c4583876d0dd339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=88ric=20Canela?= Date: Wed, 22 Apr 2020 17:01:09 +0200 Subject: [PATCH 3/5] Fix Physiscs when Loading Scene when characters die, --- Broken Engine/Source/ModulePhysics.cpp | 2 +- Broken Engine/Source/ModulePhysics.h | 2 +- Broken Engine/Source/ModuleTimeManager.h | 3 ++- Broken Engine/Source/ScriptingScenes.cpp | 7 +++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Broken Engine/Source/ModulePhysics.cpp b/Broken Engine/Source/ModulePhysics.cpp index c25d15dcd..b950c4818 100644 --- a/Broken Engine/Source/ModulePhysics.cpp +++ b/Broken Engine/Source/ModulePhysics.cpp @@ -226,7 +226,7 @@ update_status ModulePhysics::Update(float dt) if (App->GetAppState() == AppState::PLAY && !App->time->gamePaused) { // --- Step physics simulation --- - physAccumulatedTime += App->time->GetRealTimeDt(); + physAccumulatedTime += App->time->GetGameDt(); // --- If enough time has elapsed, update --- if (physAccumulatedTime >= physx::fixed_dt) diff --git a/Broken Engine/Source/ModulePhysics.h b/Broken Engine/Source/ModulePhysics.h index b0e374202..b44d54f2e 100644 --- a/Broken Engine/Source/ModulePhysics.h +++ b/Broken Engine/Source/ModulePhysics.h @@ -167,11 +167,11 @@ class BROKEN_API ModulePhysics : public Broken::Module physx::PxVolumeCache* cache; UserIterator iter; + float physAccumulatedTime = 0.0f; FilterCallback filterCallback; private: PhysxSimulationEvents* simulationEventsCallback = nullptr; - float physAccumulatedTime = 0.0f; bool loaded = false; float3 materialDesc = float3(1.0f, 1.0f, 0.0f); float gravity = 9.8; diff --git a/Broken Engine/Source/ModuleTimeManager.h b/Broken Engine/Source/ModuleTimeManager.h index 64647aa15..4431a8b84 100644 --- a/Broken Engine/Source/ModuleTimeManager.h +++ b/Broken Engine/Source/ModuleTimeManager.h @@ -35,7 +35,6 @@ class BROKEN_API ModuleTimeManager : public Module { private: Timer Realtime_clock; - Timer Gametime_clock; float Time_scale = 1.0f; @@ -48,6 +47,8 @@ class BROKEN_API ModuleTimeManager : public Module { int last_fps; uint capped_ms; uint last_frame_ms; +public: + Timer Gametime_clock; }; BE_END_NAMESPACE #endif \ No newline at end of file diff --git a/Broken Engine/Source/ScriptingScenes.cpp b/Broken Engine/Source/ScriptingScenes.cpp index 04db6ac4b..283367552 100644 --- a/Broken Engine/Source/ScriptingScenes.cpp +++ b/Broken Engine/Source/ScriptingScenes.cpp @@ -10,6 +10,8 @@ #include "ResourcePrefab.h" #include "ResourceModel.h" #include "ComponentTransform.h" +#include "ModuleTimeManager.h" +#include "ModulePhysics.h" using namespace Broken; ScriptingScenes::ScriptingScenes() {} @@ -19,9 +21,10 @@ ScriptingScenes::~ScriptingScenes() {} void ScriptingScenes::LoadSceneFromScript(uint scene_UUID) { ResourceScene* scene = (ResourceScene*)App->resources->GetResource(scene_UUID, false); - App->GetAppState() = Broken::AppState::PAUSE; + App->time->Gametime_clock.Stop(); App->scene_manager->SetActiveScene(scene); - App->GetAppState() = Broken::AppState::PLAY; + App->physics->physAccumulatedTime = 0.0f;//Reset Physics + App->time->Gametime_clock.Start(); } void ScriptingScenes::QuitGame() From 1e785bcda7bd6f648ea289970f851dc0f5b3e068 Mon Sep 17 00:00:00 2001 From: sherzock Date: Wed, 22 Apr 2020 18:33:48 +0200 Subject: [PATCH 4/5] Updated Scripting Audio --- Broken Engine/Source/ModuleScripting.cpp | 5 ++ Broken Engine/Source/ScriptingAudio.cpp | 76 ++++++++++++++++++++++-- Broken Engine/Source/ScriptingAudio.h | 13 ++-- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/Broken Engine/Source/ModuleScripting.cpp b/Broken Engine/Source/ModuleScripting.cpp index 7700201df..09e7ae097 100644 --- a/Broken Engine/Source/ModuleScripting.cpp +++ b/Broken Engine/Source/ModuleScripting.cpp @@ -334,6 +334,11 @@ void ModuleScripting::CompileScriptTableClass(ScriptInstance* script) .addFunction("StopAudioEvent", &ScriptingAudio::StopAudioEvent) .addFunction("PauseAudioEvent", &ScriptingAudio::PauseAudioEvent) .addFunction("ResumeAudioEvent", &ScriptingAudio::ResumeAudioEvent) + .addFunction("SetVolume", &ScriptingAudio::SetVolume) + .addFunction("PlayAudioEventGO", &ScriptingAudio::PlayAudioEventGO) + .addFunction("StopAudioEventGO", &ScriptingAudio::StopAudioEventGO) + .addFunction("PauseAudioEventGO", &ScriptingAudio::PauseAudioEventGO) + .addFunction("ResumeAudioEventGO", &ScriptingAudio::ResumeAudioEventGO) .endClass() // ---------------------------------------------------------------------------------- diff --git a/Broken Engine/Source/ScriptingAudio.cpp b/Broken Engine/Source/ScriptingAudio.cpp index 2b91fe520..55e068f18 100644 --- a/Broken Engine/Source/ScriptingAudio.cpp +++ b/Broken Engine/Source/ScriptingAudio.cpp @@ -42,7 +42,7 @@ void ScriptingAudio::SetVolume(float volume, uint UID) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::PlayAudioEvent(std::string event, uint UID) +void ScriptingAudio::PlayAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; @@ -60,7 +60,7 @@ void ScriptingAudio::PlayAudioEvent(std::string event, uint UID) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::StopAudioEvent(std::string event, uint UID) +void ScriptingAudio::StopAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; @@ -78,7 +78,7 @@ void ScriptingAudio::StopAudioEvent(std::string event, uint UID) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::PauseAudioEvent(std::string event, uint UID) +void ScriptingAudio::PauseAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; @@ -97,7 +97,7 @@ void ScriptingAudio::PauseAudioEvent(std::string event, uint UID) ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); } -void ScriptingAudio::ResumeAudioEvent(std::string event,uint UID) +void ScriptingAudio::ResumeAudioEventGO(std::string event,uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; @@ -115,4 +115,70 @@ void ScriptingAudio::ResumeAudioEvent(std::string event,uint UID) } else ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); -} \ No newline at end of file +} + +void ScriptingAudio::PlayAudioEvent(std::string event) +{ + ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + + uint EventId = App->audio->EventMap[event]; + + if (sound) + { + sound->SetID(EventId); + sound->wwiseGO->PlayEvent(EventId); + sound->isPlaying = true; + } + else + ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); +} + +void ScriptingAudio::StopAudioEvent(std::string event) +{ + ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + + uint EventId = App->audio->EventMap[event]; + + if (sound) + { + sound->SetID(EventId); + sound->wwiseGO->StopEvent(EventId); + sound->isPlaying = false; + } + else + ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); +} + +void ScriptingAudio::PauseAudioEvent(std::string event) +{ + ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + + uint EventId = App->audio->EventMap[event]; + if (sound) + { + sound->SetID(EventId); + sound->wwiseGO->PauseEvent(EventId); + sound->isPlaying = false; + sound->isPaused = true; + } + else + ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); +} + +void ScriptingAudio::ResumeAudioEvent(std::string event) +{ + ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); + + uint EventId = App->audio->EventMap[event]; + + if (sound) + { + sound->SetID(EventId); + sound->wwiseGO->ResumeEvent(EventId); + sound->isPlaying = true; + sound->isPaused = false; + } + else + ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); +} + diff --git a/Broken Engine/Source/ScriptingAudio.h b/Broken Engine/Source/ScriptingAudio.h index 6bb8faa8a..26911b425 100644 --- a/Broken Engine/Source/ScriptingAudio.h +++ b/Broken Engine/Source/ScriptingAudio.h @@ -11,10 +11,15 @@ class BROKEN_API ScriptingAudio { public: void SetVolume(float volume, uint UID); - void PlayAudioEvent(std::string event, uint UID); - void StopAudioEvent(std::string event, uint UID); - void PauseAudioEvent(std::string event, uint UID); - void ResumeAudioEvent(std::string event,uint UID); + void PlayAudioEventGO(std::string event, uint UID); + void StopAudioEventGO(std::string event, uint UID); + void PauseAudioEventGO(std::string event, uint UID); + void ResumeAudioEventGO(std::string event,uint UID); + + void PlayAudioEvent(std::string event); + void StopAudioEvent(std::string event); + void PauseAudioEvent(std::string event); + void ResumeAudioEvent(std::string event); }; BE_END_NAMESPACE From 9230a3d402b34a7cd6fcd5547f204260b53e4ec2 Mon Sep 17 00:00:00 2001 From: Sergi PR Date: Wed, 22 Apr 2020 18:50:17 +0200 Subject: [PATCH 5/5] Structural changes to audio scripting --- Broken Engine/Source/ScriptingAudio.cpp | 124 +++++++++++++----------- 1 file changed, 67 insertions(+), 57 deletions(-) diff --git a/Broken Engine/Source/ScriptingAudio.cpp b/Broken Engine/Source/ScriptingAudio.cpp index 55e068f18..5a80689c1 100644 --- a/Broken Engine/Source/ScriptingAudio.cpp +++ b/Broken Engine/Source/ScriptingAudio.cpp @@ -32,153 +32,163 @@ ScriptingAudio::~ScriptingAudio() {} void ScriptingAudio::SetVolume(float volume, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); - ComponentAudioSource* sound = nullptr; - if (GO) - sound = GO->GetComponent(); + if (GO) { + ComponentAudioSource* sound = GO->GetComponent(); - if (sound) - sound->SetVolume(volume); + if (sound) + sound->SetVolume(volume); + else + ENGINE_CONSOLE_LOG("![Script]: (SetVolume) Sound Emmiter component is NULL"); + } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (SetVolume) GameObject with UID %d does not exist", UID); } void ScriptingAudio::PlayAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); - ComponentAudioSource* sound = nullptr; - if (GO) - sound = GO->GetComponent(); - uint EventId = App->audio->EventMap[event]; - - if (sound) + if (GO) { - sound->SetID(EventId); - sound->wwiseGO->PlayEvent(EventId); - sound->isPlaying = true; + ComponentAudioSource* sound = GO->GetComponent(); + + if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); + sound->wwiseGO->PlayEvent(EventId); + sound->isPlaying = true; + } + else + ENGINE_CONSOLE_LOG("![Script]: (PlayAudioEventGO) Component AudioSource does not exist"); } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (StopAudioEventGO) GameObject with UID %d does not exist", UID); } void ScriptingAudio::StopAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); - ComponentAudioSource* sound = nullptr; - if (GO) - sound = GO->GetComponent(); - uint EventId = App->audio->EventMap[event]; - - if (sound) + if (GO) { - sound->SetID(EventId); - sound->wwiseGO->StopEvent(EventId); - sound->isPlaying = false; + ComponentAudioSource* sound = GO->GetComponent(); + + if (sound) + { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); + sound->wwiseGO->StopEvent(EventId); + sound->isPlaying = false; + } + else + ENGINE_CONSOLE_LOG("![Script]: (StopAudioEventGO) Component AudioSource does not exist"); } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (StopAudioEventGO) GameObject with UID %d does not exist", UID); } void ScriptingAudio::PauseAudioEventGO(std::string event, uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); - ComponentAudioSource* sound = nullptr; - if (GO) - sound = GO->GetComponent(); - uint EventId = App->audio->EventMap[event]; - if (sound) + if (GO) { - sound->SetID(EventId); - sound->wwiseGO->PauseEvent(EventId); - sound->isPlaying = false; - sound->isPaused = true; + ComponentAudioSource* sound = GO->GetComponent(); + + if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); + sound->wwiseGO->PauseEvent(EventId); + sound->isPlaying = false; + sound->isPaused = true; + } + else + ENGINE_CONSOLE_LOG("![Script]: (PauseAudioEventGO) Component AudioSource does not exist"); } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (PauseAudioEventGO) GameObject with UID %d does not exist", UID); } void ScriptingAudio::ResumeAudioEventGO(std::string event,uint UID) { GameObject* GO = App->scene_manager->currentScene->GetGOWithUID(UID); ComponentAudioSource* sound = nullptr; - if(GO) + if (GO) { sound = GO->GetComponent(); - uint EventId = App->audio->EventMap[event]; - - if (sound) - { - sound->SetID(EventId); - sound->wwiseGO->ResumeEvent(EventId); - sound->isPlaying = true; - sound->isPaused = false; + if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); + sound->wwiseGO->ResumeEvent(EventId); + sound->isPlaying = true; + sound->isPaused = false; + } + ENGINE_CONSOLE_LOG("![Script]: (ResumeAudioEventGO) Component AudioSource does not exist"); } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (ResumeAudioEventGO) GameObject with UID %d does not exist", UID); } void ScriptingAudio::PlayAudioEvent(std::string event) { ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - uint EventId = App->audio->EventMap[event]; - if (sound) { + uint EventId = App->audio->EventMap[event]; sound->SetID(EventId); sound->wwiseGO->PlayEvent(EventId); sound->isPlaying = true; } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (PlayAudioEvent) Sound Emmiter component is NULL"); } void ScriptingAudio::StopAudioEvent(std::string event) { ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - uint EventId = App->audio->EventMap[event]; - if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); sound->wwiseGO->StopEvent(EventId); sound->isPlaying = false; } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (StopAudioEvent) Sound Emmiter component is NULL"); } void ScriptingAudio::PauseAudioEvent(std::string event) { ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - uint EventId = App->audio->EventMap[event]; if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); sound->wwiseGO->PauseEvent(EventId); sound->isPlaying = false; sound->isPaused = true; } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (PauseAudioEvent) Sound Emmiter component is NULL"); } void ScriptingAudio::ResumeAudioEvent(std::string event) { ComponentAudioSource* sound = App->scripting->current_script->my_component->GetContainerGameObject()->GetComponent(); - uint EventId = App->audio->EventMap[event]; - if (sound) { + uint EventId = App->audio->EventMap[event]; + sound->SetID(EventId); sound->wwiseGO->ResumeEvent(EventId); sound->isPlaying = true; sound->isPaused = false; } else - ENGINE_CONSOLE_LOG("[Script]: Sound Emmiter component is NULL"); + ENGINE_CONSOLE_LOG("![Script]: (ResumeAudioEvent) Sound Emmiter component is NULL"); }