9#include "Components/AudioComponent.h"
10#include "Kismet/GameplayStatics.h"
14#define SOUND_DATA_PATH TEXT("/Game/CustomContents/MasterData/DA_Sound.DA_Sound")
21 for (
const auto& Pair : LoadedAsset->SoundData)
26 TSoftObjectPtr<USoundBase> SoundAssetPtr = Pair.Value;
27 if (!SoundAssetPtr.IsNull()) {
28 SoundData.Add(Pair.Key, SoundAssetPtr.LoadSynchronous());
35 UE_LOG(LogTemp, Error, TEXT(
"UGameSoundManager failed to load USoundData at path: %s"),
SOUND_DATA_PATH);
41 Super::Initialize(Collection);
63 UE_LOG(LogTemp, Error, TEXT(
"Failed to load SoundDataAsset from path"));
69 if (TObjectPtr<USoundBase>* FoundSound =
SoundData.Find(Type))
73 UGameplayStatics::PlaySoundAtLocation(GetWorld(), *FoundSound, Location);
81 if (TObjectPtr<USoundBase>* FoundSound =
SoundData.Find(Type))
86 if (UAudioComponent* ExistingComp =
ActiveSounds.FindRef(Type))
93 if (UAudioComponent* NewComp = UGameplayStatics::SpawnSound2D(GetWorld(), *FoundSound))
152 if (TObjectPtr<USoundBase>* FoundSound =
SoundData.Find(Type))
FComponentHelper 구조체를 선언합니다.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
UGameSoundManager 클래스를 선언합니다.
TMap< EGameSoundType, UAudioComponent * > ActiveSounds
TMap< EGameSoundType, TObjectPtr< class USoundBase > > SoundData
void StopSound2D(const EGameSoundType Type)
virtual void Initialize(FSubsystemCollectionBase &Collection) override
void StopConversationVoice()
void PlayBGM(EGameSoundType Type)
BGM을 재생합니다.
void PlaySound(EGameSoundType Type, FVector Location)
TObjectPtr< class USoundData > SoundAsset
UAudioComponent * PlayConversationVoice(USoundBase *Sound)
void StopBGM()
현재 재생 중인 BGM을 중지합니다.
TObjectPtr< UAudioComponent > CurrentBGM
void PlaySound2D(EGameSoundType Type)
bool IsConversationVoicePlaying() const
TObjectPtr< UAudioComponent > ConversationVoice
EGameSoundType CurrentBGMType
static T * LoadAsset(const TCHAR *Path)