diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp index cd04f841..a31383fb 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp @@ -368,6 +368,19 @@ namespace SHADE sfxChannelGroup->addGroup(channelGroup); } + void SHAudioSystem::AttachAudioClipToObject(Handle handle, EntityID eid) + { + if (auto transform = SHComponentManager::GetComponent_s(eid)) + { + handle->transformRef = transform; + } + } + + void SHAudioSystem::DetachAudioClipToObject(Handle handle, EntityID eid) + { + handle->transformRef = nullptr; + } + //AudioClip* SHAudioSystem::CreateAudioClip(const char* path) //{ // AudioClipID newID{}; diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h index 08505ea9..153ec86a 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h @@ -26,6 +26,7 @@ namespace SHADE class AudioClip { public: + //expose to sxripting void Play(); //void Play(SHVec3 position); void Stop(bool fadeOut = true); @@ -38,7 +39,7 @@ namespace SHADE friend class SHAudioSystem; private: FMOD::Studio::EventInstance* instance = nullptr; - //SHTransformComponent* transformRef; + SHTransformComponent* transformRef = nullptr; }; class SH_API SHAudioSystem : public SHSystem @@ -68,10 +69,14 @@ namespace SHADE std::optional GetEventGUID(const char* path); //AudioClip* CreateAudioClip(const char* path); + //AUDIO CLIP Handle CreateAudioClip(const char* path); void AddAudioClipToBGMChannelGroup(Handle handle); void AddAudioClipToSFXChannelGroup(Handle handle); + void AttachAudioClipToObject(Handle handle, EntityID eid); + void DetachAudioClipToObject(Handle handle, EntityID eid); + /// float GetBgmVolume(); float GetSfxVolume(); float GetMasterVolume();