Merge branch 'Music-System' into dev

This commit is contained in:
Philip W 2024-04-17 02:25:15 +01:00
commit 50605f7d8e
5 changed files with 131 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,75 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "CombatAudioAutomation.h"
#include "Components/AudioComponent.h"
#include "Kismet/GameplayStatics.h"
// Sets default values for this component's properties
UCombatAudioAutomation::UCombatAudioAutomation()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UCombatAudioAutomation::BeginPlay()
{
Super::BeginPlay();
for (USoundBase* Track : StealthTracks)
{
UAudioComponent* AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), Track);
AllAudioComponents.Add(AudioComponent);
StealthTracksAudioComponents.Add(AudioComponent);
}
UAudioComponent* AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), InvestigatedTrack);
AllAudioComponents.Add(AudioComponent);
InvestigatedTrackAudioComponent = AudioComponent;
AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), CombatStartTrack);
AllAudioComponents.Add(AudioComponent);
CombatStartTrackAudioComponent = AudioComponent;
AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), CombatContinuousTrack);
AllAudioComponents.Add(AudioComponent);
CombatContinuousTrackAudioComponent = AudioComponent;
}
// Called every frame
void UCombatAudioAutomation::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UCombatAudioAutomation::StartStealthTrack()
{
// Play the stealth tracks in order after the previous one has finished
}
void UCombatAudioAutomation::StartCombatTrack()
{
}
void UCombatAudioAutomation::StartInvestigatedTrack()
{
}
void UCombatAudioAutomation::StopTracks()
{
for (UAudioComponent* AudioComponent : AllAudioComponents)
{
AudioComponent->Stop();
}
}

View File

@ -0,0 +1,47 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "CombatAudioAutomation.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class ENDLESSVENDETTA_API UCombatAudioAutomation : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UCombatAudioAutomation();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
TArray<USoundBase*> StealthTracks;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundBase* InvestigatedTrack;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundBase* CombatStartTrack;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundBase* CombatContinuousTrack;
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
TArray<UAudioComponent*> AllAudioComponents;
TArray<UAudioComponent*> StealthTracksAudioComponents;
UAudioComponent* InvestigatedTrackAudioComponent;
UAudioComponent* CombatStartTrackAudioComponent;
UAudioComponent* CombatContinuousTrackAudioComponent;
void StartStealthTrack();
void StartCombatTrack();
void StartInvestigatedTrack();
void StopTracks();
};