4#include "Components/AudioComponent.h"
10#include "Kismet/GameplayStatics.h"
20 AudioComponent = CreateDefaultSubobject<UAudioComponent>(
"Audio Component");
26 static const FString ContextString(TEXT(
"Sound"));
29 TArray<FName> rowNames = DataTable->GetRowNames();
30 if (rowNames.Num() == 0)
32 UE_LOG(LogTemp, Error, TEXT(
"Voice over DataTable is empty!"))
35 for (
const auto rowName : rowNames)
37 FStepVO* findedSound = DataTable->FindRow<
FStepVO>(rowName, ContextString);
38 if (findedSound->
StepName.EqualTo(stepName))
45 UE_LOG(LogTemp, Error, TEXT(
"Voice over DataTable is invalid!"));
59 USoundBase* soundToPlay,
60 float volumeMultiplier,
61 float pitchMultiplier,
63 USoundConcurrency* concurrencySettings,
69 UGameplayStatics::PlaySound2D(
78 UE_LOG(LogTemp, Log, TEXT(
"USoundManager::PlayBackgroundSound: Playing - %s"), *soundToPlay->GetName());
87 UE_LOG(LogTemp, Log, TEXT(
"USoundManager::PlaySFXSound: Playing - %s"), *soundToPlay->GetName());
103 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue,
"UPlaySoundEvent");
163 UE_LOG(LogTemp, Warning, TEXT(
"SoundManager - StepVODataTablesArray didn't have StoryIndex value, zero array element is selected"));
166 UE_LOG(LogTemp, Error, TEXT(
"SoundManager - CurrentStepVODataTable wasn't set up"));
169 UE_LOG(LogTemp, Error, TEXT(
"SoundManager - StepVODataTablesArray is empty!"));
180 UE_LOG(LogTemp, Warning, TEXT(
"SoundManager - StepVODataTablesArray didn't have StoryIndex value, zero array element is selected"));
183 UE_LOG(LogTemp, Error, TEXT(
"SoundManager - CurrentStepHintVODataTable wasn't set up"));
186 UE_LOG(LogTemp, Warning, TEXT(
"SoundManager - StepHintVODataTablesArray is empty!"));
#define DEFINE_EVENT_HANDLER(TEventType)
void HandleEvent_Impl(class UBaseEvent *Event)
Event used to call when hint activated or deactivated.
Event called when we on init experience.
Event called when new step is loaded.
Event called when new story is loaded.
Event used to call to play sound.
TArray< FBackgroundSound > BackgroundSounds
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (EditCondition="bPlayBackgroundSound",...
float GeneralSoundVolumeMultiplier
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (ClampMin = 0.f), Category = "SoundManager")
void OnStepChange(FText stepName)
Play SFX sound (don't interrupt others)
void PlaySound(USoundCue *soundToPlay)
UFUNCTION(BlueprintCallable, Category = "Play Sound")
TArray< UDataTable * > StepVODataTablesArray
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
USoundCue * GetSoundBasedOnStep(FText stepName, UDataTable *DataTable)
Retrieves a sound cue based on the step name.
float SFXVolumeMultiplier
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (ClampMin = 0.f), Category = "SoundManager")
float BackgroundVolumeMultiplier
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (ClampMin = 0.f, EditCondition="bPlayBackground...
FOnVOEndPlaying OnVoEndPlaying
UPROPERTY(BlueprintAssignable)
void PlayBackgroundSound(USoundBase *soundToPlay, float volumeMultiplier=1.f, float pitchMultiplier=1.f, float startTime=0.f, USoundConcurrency *concurrencySettings=nullptr, AActor *owningActor=nullptr, bool bIsUISound=false)
Play sound based on the new step.
UAudioComponent * AudioComponent
UPROPERTY(BlueprintReadWrite, Category = "Components")
UDataTable * CurrentStepHintVODataTable
UPROPERTY(BlueprintReadWrite, Category = "Components")
bool bPlayBackgroundSound
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SoundManager")
TArray< UDataTable * > StepHintVODataTablesArray
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
USoundManagerParametersData * SoundManagerParametersData
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SoundManager")
void OnAudioEndPlaying()
Called when audio playback ends.
UDataTable * CurrentStepVODataTable
UPROPERTY(BlueprintReadWrite, Category = "Components")
void PlaySFXSound(USoundBase *soundToPlay)
Play independent background sound (don't interrupt others)
static int GetNextStoryIndex()
UFUNCTION(BlueprintCallable)
static bool IsSpecificParametersExist(TArray< FText > SpecificParameters)
UFUNCTION(BlueprintCallable)
Represents a parameter used by the Background Sound.
Represents a Step Value Object used for storing step data in a data table.
USoundCue * SoundCue
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FText StepName
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FText StepName
UPROPERTY(BlueprintReadWrite, EditAnywhere)