Update Combat Audio Automation for Timing Engine & Track Queue
This commit is contained in:
parent
0b9791086e
commit
10938d7b8d
@ -77,11 +77,16 @@ void AAICharacter::SetupStimuliSourceComponent()
|
|||||||
void AAICharacter::OnDeath()
|
void AAICharacter::OnDeath()
|
||||||
{
|
{
|
||||||
AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
||||||
if (UBlackboardComponent* Blackboard = AIController->GetBlackboardComponent(); Blackboard->GetValueAsBool("SeenWithHostilities"))
|
UBlackboardComponent* Blackboard = AIController->GetBlackboardComponent();
|
||||||
{
|
|
||||||
AEndlessVendettaCharacter* PlayerCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
AEndlessVendettaCharacter* PlayerCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||||
|
if (Blackboard->GetValueAsBool("SeenWithHostilities"))
|
||||||
|
{
|
||||||
PlayerCharacter->DecrementSeenHostileCount();
|
PlayerCharacter->DecrementSeenHostileCount();
|
||||||
}
|
}
|
||||||
|
if (Blackboard->GetValueAsBool("IsInvestigating"))
|
||||||
|
{
|
||||||
|
PlayerCharacter->DecrementBeingInvestigatedCount();
|
||||||
|
}
|
||||||
|
|
||||||
this->Tags.Add(FName("Dead"));
|
this->Tags.Add(FName("Dead"));
|
||||||
//Ragdoll
|
//Ragdoll
|
||||||
|
@ -18,6 +18,47 @@ UCombatAudioAutomation::UCombatAudioAutomation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::InCombat()
|
||||||
|
{
|
||||||
|
bInCombat = true;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::CombatStart);
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::CombatContinuous);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::OutOfCombat()
|
||||||
|
{
|
||||||
|
bInCombat = false;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::StopCombat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::Investigated()
|
||||||
|
{
|
||||||
|
if (bInCombat) return;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::Investigated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::NotBeingInvestigated()
|
||||||
|
{
|
||||||
|
if (bInCombat) return;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::StopStealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::InRestrictedArea()
|
||||||
|
{
|
||||||
|
if (bInCombat) return;
|
||||||
|
bInRestrictedArea = true;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::Stealth1);
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::Stealth2);
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::Stealth3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::NotInRestrictedArea()
|
||||||
|
{
|
||||||
|
if (bInCombat) return;
|
||||||
|
bInRestrictedArea = false;
|
||||||
|
AudioTrackQueue.Enqueue(EAudioTrack::StopStealth);
|
||||||
|
}
|
||||||
|
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
void UCombatAudioAutomation::BeginPlay()
|
void UCombatAudioAutomation::BeginPlay()
|
||||||
{
|
{
|
||||||
@ -41,33 +82,69 @@ void UCombatAudioAutomation::BeginPlay()
|
|||||||
AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), CombatContinuousTrack);
|
AudioComponent = UGameplayStatics::SpawnSound2D(GetWorld(), CombatContinuousTrack);
|
||||||
AllAudioComponents.Add(AudioComponent);
|
AllAudioComponents.Add(AudioComponent);
|
||||||
CombatContinuousTrackAudioComponent = AudioComponent;
|
CombatContinuousTrackAudioComponent = AudioComponent;
|
||||||
|
|
||||||
|
GetWorld()->GetTimerManager().SetTimer(AudioSyncTimer, this, &UCombatAudioAutomation::PlayQueued, 5.33333f, true, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UCombatAudioAutomation::PlayQueued()
|
||||||
|
{
|
||||||
|
if (AudioTrackQueue.IsEmpty()) return;
|
||||||
|
|
||||||
|
EAudioTrack AudioTrack;
|
||||||
|
AudioTrackQueue.Dequeue(AudioTrack);
|
||||||
|
|
||||||
|
switch (AudioTrack)
|
||||||
|
{
|
||||||
|
case EAudioTrack::Stealth1:
|
||||||
|
StealthTracksAudioComponents[0]->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::Stealth2:
|
||||||
|
StealthTracksAudioComponents[1]->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::Stealth3:
|
||||||
|
StealthTracksAudioComponents[2]->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::Investigated:
|
||||||
|
StealthTracksAudioComponents[0]->Stop();
|
||||||
|
StealthTracksAudioComponents[1]->Stop();
|
||||||
|
StealthTracksAudioComponents[2]->Stop();
|
||||||
|
InvestigatedTrackAudioComponent->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::CombatStart:
|
||||||
|
CombatStartTrackAudioComponent->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::CombatContinuous:
|
||||||
|
CombatStartTrackAudioComponent->Stop();
|
||||||
|
CombatContinuousTrackAudioComponent->Play();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::StopStealth:
|
||||||
|
for (UAudioComponent* AudioComponent : StealthTracksAudioComponents)
|
||||||
|
{
|
||||||
|
AudioComponent->Stop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EAudioTrack::StopInvestigated:
|
||||||
|
InvestigatedTrackAudioComponent->Stop();
|
||||||
|
break;
|
||||||
|
case EAudioTrack::StopCombat:
|
||||||
|
CombatStartTrackAudioComponent->Stop();
|
||||||
|
CombatContinuousTrackAudioComponent->Stop();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void UCombatAudioAutomation::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
void UCombatAudioAutomation::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, 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()
|
void UCombatAudioAutomation::StopTracks()
|
||||||
{
|
{
|
||||||
|
AudioTrackQueue.Empty();
|
||||||
for (UAudioComponent* AudioComponent : AllAudioComponents)
|
for (UAudioComponent* AudioComponent : AllAudioComponents)
|
||||||
{
|
{
|
||||||
AudioComponent->Stop();
|
AudioComponent->Stop();
|
||||||
|
@ -6,6 +6,19 @@
|
|||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
#include "CombatAudioAutomation.generated.h"
|
#include "CombatAudioAutomation.generated.h"
|
||||||
|
|
||||||
|
UENUM(BlueprintType)
|
||||||
|
enum class EAudioTrack : uint8
|
||||||
|
{
|
||||||
|
Stealth1,
|
||||||
|
Stealth2,
|
||||||
|
Stealth3,
|
||||||
|
Investigated,
|
||||||
|
CombatStart,
|
||||||
|
CombatContinuous,
|
||||||
|
StopStealth,
|
||||||
|
StopInvestigated,
|
||||||
|
StopCombat,
|
||||||
|
};
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class ENDLESSVENDETTA_API UCombatAudioAutomation : public UActorComponent
|
class ENDLESSVENDETTA_API UCombatAudioAutomation : public UActorComponent
|
||||||
@ -25,10 +38,27 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
|
||||||
USoundBase* CombatContinuousTrack;
|
USoundBase* CombatContinuousTrack;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void InCombat();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void OutOfCombat();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void Investigated();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void NotBeingInvestigated();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void InRestrictedArea();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void NotInRestrictedArea();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
TQueue<EAudioTrack> AudioTrackQueue;
|
||||||
|
UFUNCTION()
|
||||||
|
void PlayQueued();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
@ -40,8 +70,11 @@ private:
|
|||||||
UAudioComponent* CombatStartTrackAudioComponent;
|
UAudioComponent* CombatStartTrackAudioComponent;
|
||||||
UAudioComponent* CombatContinuousTrackAudioComponent;
|
UAudioComponent* CombatContinuousTrackAudioComponent;
|
||||||
|
|
||||||
void StartStealthTrack();
|
bool bInCombat = false;
|
||||||
void StartCombatTrack();
|
bool bInRestrictedArea = false;
|
||||||
void StartInvestigatedTrack();
|
|
||||||
void StopTracks();
|
void StopTracks();
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
FTimerHandle AudioSyncTimer;
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "Inventory/InventoryComponent.h"
|
#include "Inventory/InventoryComponent.h"
|
||||||
#include "EndlessVendettaGameMode.h"
|
#include "EndlessVendettaGameMode.h"
|
||||||
#include "EVGameInstance.h"
|
#include "EVGameInstance.h"
|
||||||
|
#include "AI/CombatAudioAutomation.h"
|
||||||
#include "DialogueSystem/AC_Dialogue.h"
|
#include "DialogueSystem/AC_Dialogue.h"
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount()
|
|||||||
if (RestrictedBoundsCount > 0)
|
if (RestrictedBoundsCount > 0)
|
||||||
{
|
{
|
||||||
bIsInRestrictedArea = true;
|
bIsInRestrictedArea = true;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->InRestrictedArea();
|
||||||
RestrictedAreaStatusChanged.Broadcast(true);
|
RestrictedAreaStatusChanged.Broadcast(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,6 +51,7 @@ void AEndlessVendettaCharacter::DecrementRestrictedBoundsCount()
|
|||||||
if (RestrictedBoundsCount <= 0)
|
if (RestrictedBoundsCount <= 0)
|
||||||
{
|
{
|
||||||
bIsInRestrictedArea = false;
|
bIsInRestrictedArea = false;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->NotInRestrictedArea();
|
||||||
RestrictedAreaStatusChanged.Broadcast(false);
|
RestrictedAreaStatusChanged.Broadcast(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,6 +66,7 @@ void AEndlessVendettaCharacter::IncrementSeenHostileCount()
|
|||||||
if (!bIsInCombat)
|
if (!bIsInCombat)
|
||||||
{
|
{
|
||||||
bIsInCombat = true;
|
bIsInCombat = true;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->InCombat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +90,7 @@ void AEndlessVendettaCharacter::IncrementBeingInvestigatedCount()
|
|||||||
if (!bIsBeingInvestigated)
|
if (!bIsBeingInvestigated)
|
||||||
{
|
{
|
||||||
bIsBeingInvestigated = true;
|
bIsBeingInvestigated = true;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->Investigated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +100,7 @@ void AEndlessVendettaCharacter::DecrementBeingInvestigatedCount()
|
|||||||
if (BeingInvestigatedCount <= 0)
|
if (BeingInvestigatedCount <= 0)
|
||||||
{
|
{
|
||||||
bIsBeingInvestigated = false;
|
bIsBeingInvestigated = false;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->NotBeingInvestigated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +243,7 @@ void AEndlessVendettaCharacter::Heal(const float Amount)
|
|||||||
void AEndlessVendettaCharacter::NotInCombat()
|
void AEndlessVendettaCharacter::NotInCombat()
|
||||||
{
|
{
|
||||||
bIsInCombat = false;
|
bIsInCombat = false;
|
||||||
|
Cast<UCombatAudioAutomation>(GetComponentByClass(UCombatAudioAutomation::StaticClass()))->OutOfCombat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
||||||
|
Loading…
Reference in New Issue
Block a user