4#include "Components/AudioComponent.h"
19 AudioComponent = CreateDefaultSubobject<UAudioComponent>(
"Audio Component");
25 static const FString ContextString(TEXT(
"Sound"));
28 TArray<FName> rowNames = DataTable->GetRowNames();
29 if (rowNames.Num() == 0)
31 UE_LOG(LogTemp,
Error, TEXT(
"Voice over DataTable is empty!"))
34 for (
const auto rowName : rowNames)
36 FStepVO* findedSound = DataTable->FindRow<
FStepVO>(rowName, ContextString);
37 if (findedSound->
StepName.EqualTo(stepName))
44 UE_LOG(LogTemp,
Error, TEXT(
"Voice over DataTable is invalid!"));
69 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue,
"UPlaySoundEvent");
100 for (
auto StoryParameter : StoryParameters)
104 if (StoryParameter.EqualTo(SoundManagerParameter.ParameterName) && StoryIndex == SoundManagerParameter.StoryIndex)
122 UE_LOG(LogTemp,
Warning, TEXT(
"SoundManager - StepVODataTablesArray didn't have StoryIndex value, zero array element is selected"));
125 UE_LOG(LogTemp,
Error, TEXT(
"SoundManager - CurrentStepVODataTable wasn't set up"));
128 UE_LOG(LogTemp,
Error, TEXT(
"SoundManager - StepVODataTablesArray is empty!"));
139 UE_LOG(LogTemp,
Warning, TEXT(
"SoundManager - StepVODataTablesArray didn't have StoryIndex value, zero array element is selected"));
142 UE_LOG(LogTemp,
Error, TEXT(
"SoundManager - CurrentStepHintVODataTable wasn't set up"));
145 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.
void OnStepChange(FText stepName)
Play sound based on the new step.
void PlaySound(USoundCue *soundToPlay)
UFUNCTION(BlueprintCallable)
TArray< UDataTable * > StepVODataTablesArray
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
USoundCue * GetSoundBasedOnStep(FText stepName, UDataTable *DataTable)
Retrieves a sound cue based on the step name.
FOnVOEndPlaying OnVoEndPlaying
UPROPERTY(BlueprintAssignable)
UAudioComponent * AudioComponent
UPROPERTY(BlueprintReadWrite, Category = "Components")
UDataTable * CurrentStepHintVODataTable
UPROPERTY(BlueprintReadWrite, Category = "Components")
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")
static int GetNextStoryIndex()
UFUNCTION(BlueprintCallable)
static TArray< FText > GetStoryParameters()
UFUNCTION(BlueprintCallable)
Represents a Step Value Object used for storing step data in a data table.
USoundCue * SoundCue
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FText StepName
UPROPERTY(EditAnywhere, BlueprintReadOnly)