diff --git a/EndlessVendetta/Content/Levels/OpenWorldRework.umap b/EndlessVendetta/Content/Levels/OpenWorldRework.umap index a0e3502d..b7a2bbd3 100644 --- a/EndlessVendetta/Content/Levels/OpenWorldRework.umap +++ b/EndlessVendetta/Content/Levels/OpenWorldRework.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e719dd99537b64a8d56a64b3b9d5a61edb8c5adc5cd7822d54202c21aba86687 -size 45627027 +oid sha256:3be501c981823f3aa249d1006410abd991b09e8f4800e5214dd02ff532b05c50 +size 45627777 diff --git a/EndlessVendetta/Content/Levels/TempLevels/NewTutorialMap.umap b/EndlessVendetta/Content/Levels/TempLevels/NewTutorialMap.umap index ceb84814..29ef503b 100644 --- a/EndlessVendetta/Content/Levels/TempLevels/NewTutorialMap.umap +++ b/EndlessVendetta/Content/Levels/TempLevels/NewTutorialMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ec6b4ab13b4573a4a4a01d7ea992afa07695f4f9b82d0c1a4c80f761aa4f2a9 -size 1979023 +oid sha256:d4efbb1b881119db75ccbee8773d6c073cb5d8679be838b0d08c1b605dabb014 +size 1979164 diff --git a/EndlessVendetta/Content/NPC/BP_NPC_Manager.uasset b/EndlessVendetta/Content/NPC/BP_NPC_Manager.uasset index 1b8fdab9..d8b66fbe 100644 --- a/EndlessVendetta/Content/NPC/BP_NPC_Manager.uasset +++ b/EndlessVendetta/Content/NPC/BP_NPC_Manager.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:86987c9bdd1a2707a515186793698bc07d938101b1de0b500286cc16629e9359 -size 22534 +oid sha256:ca12e2004403a8ce0dfec5274e3b0ac13896cd6ad60932db1a1601469ffea0f6 +size 22656 diff --git a/EndlessVendetta/Content/NPC/Custom_NPC_Stations/NPCs_Argueing.uasset b/EndlessVendetta/Content/NPC/Custom_NPC_Stations/NPCs_Argueing.uasset new file mode 100644 index 00000000..27055494 --- /dev/null +++ b/EndlessVendetta/Content/NPC/Custom_NPC_Stations/NPCs_Argueing.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ea4c7725b4114e66152f59eabb0ee14ad9924dfb754bc29c0d81ef8fe676a19 +size 88907 diff --git a/EndlessVendetta/Content/NPC/NPCStation_Test1.uasset b/EndlessVendetta/Content/NPC/NPCStation_Test1.uasset deleted file mode 100644 index 3e2cc318..00000000 --- a/EndlessVendetta/Content/NPC/NPCStation_Test1.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b049e683fe37a8cc646bbb5d5181a5fac5bb1f4be1accf14e2cc42102b32ce58 -size 33754 diff --git a/EndlessVendetta/Content/NPC/NPCStation_Test2.uasset b/EndlessVendetta/Content/NPC/NPCStation_Test2.uasset deleted file mode 100644 index 84c8b589..00000000 --- a/EndlessVendetta/Content/NPC/NPCStation_Test2.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6181121e680650a713fd6faa5be4bde5b96ed85921fc5bf76c55f7fd7baa8071 -size 35338 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index a9df2646..0f990580 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c094c5b655843685164dd0c03980000af4131a8c41cd84e2788b763d8298cd0 -size 66790690 +oid sha256:bc35eb2d43a47427d30aba0196f9eac90d089dd3abca319528c5d25c83510d0d +size 72364642 diff --git a/EndlessVendetta/Content/StarterContent/Materials/M_Concrete_Poured.uasset b/EndlessVendetta/Content/StarterContent/Materials/M_Concrete_Poured.uasset index b2d18c9b..604f8675 100644 --- a/EndlessVendetta/Content/StarterContent/Materials/M_Concrete_Poured.uasset +++ b/EndlessVendetta/Content/StarterContent/Materials/M_Concrete_Poured.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1305e8d693a1ec4eab7eae1e318cc549603410a436588407d9e9d7f8a0020a9b -size 31000 +oid sha256:69d453cc3372ddb78381716e4eafa298a39c10564cd6bf4ce6f269f8d5c5001e +size 30606 diff --git a/EndlessVendetta/Content/StarterContent/Materials/M_Rock_Sandstone.uasset b/EndlessVendetta/Content/StarterContent/Materials/M_Rock_Sandstone.uasset index 83f555ef..f19b524f 100644 --- a/EndlessVendetta/Content/StarterContent/Materials/M_Rock_Sandstone.uasset +++ b/EndlessVendetta/Content/StarterContent/Materials/M_Rock_Sandstone.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e4d68d897b3ac9087999fc177988c5d236527ac051dac4458b17a353a052d56 -size 36842 +oid sha256:3206845341fd89bf1e51a23599d504eea53ea289f6e066df32def3a603095bb3 +size 36603 diff --git a/EndlessVendetta/Content/StarterContent/Props/SM_GlassWindow.uasset b/EndlessVendetta/Content/StarterContent/Props/SM_GlassWindow.uasset index be754c1a..5d566289 100644 --- a/EndlessVendetta/Content/StarterContent/Props/SM_GlassWindow.uasset +++ b/EndlessVendetta/Content/StarterContent/Props/SM_GlassWindow.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd20df63c678e5b60a333b3fb03f0907b2380cc9c312f6361fea7b13165c97c5 -size 35984 +oid sha256:006ac3da047529479d0af8768be4d9bc85f81f0f88d48a8a952eebde69b4b10f +size 36547 diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.cpp b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.cpp new file mode 100644 index 00000000..2215eacb --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.cpp @@ -0,0 +1,6 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "NPC_InfoStruct.h" + + diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.h b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.h new file mode 100644 index 00000000..b49ca99b --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_InfoStruct.h @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "NPC_InfoStruct.generated.h" + +USTRUCT(BlueprintType) +struct FNPC_InfoStruct +{ + GENERATED_BODY(); + + UPROPERTY(BlueprintReadWrite, VisibleAnywhere) + FVector NPC_Location; + + UPROPERTY(BlueprintReadWrite, VisibleAnywhere) + TArray BarkLines; + + UPROPERTY(BlueprintReadWrite, VisibleAnywhere) + UAudioComponent* VoiceComp; +}; + + diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp index 79f2b0f0..949b914a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp @@ -10,7 +10,7 @@ ANPC_Manager::ANPC_Manager() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; - + } void ANPC_Manager::UpdateNPC_Stations() @@ -40,11 +40,12 @@ void ANPC_Manager::BeginPlay() FRotator DefaultRot = FRotator(0, 0, 0); for (FVector StationPoint : StationPoints) { - int RandInt = FMath::RandRange(0, NPC_StationClasses.Num() - 1);// make station points be relative to world - ANPC_Station* NPC_Station = GetWorld()->SpawnActor(NPC_StationClasses[RandInt], StationPoint, DefaultRot); + int RandInt = FMath::RandRange(0, NPC_StationClasses.Num() - 1); + FVector StationPointWorldLocation = StationPoint + GetActorLocation(); + ANPC_Station* NPC_Station = GetWorld()->SpawnActor(NPC_StationClasses[RandInt], StationPointWorldLocation, DefaultRot); if (IsValid(NPC_Station)) NPC_Stations.Add(NPC_Station); } - + SetActorTickInterval(1); } // Called every frame diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.cpp b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.cpp index 25795168..47995a1e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.cpp @@ -3,6 +3,44 @@ #include "NPC_Station.h" +#include "Components/AudioComponent.h" +#include "Kismet/GameplayStatics.h" + +void ANPC_Station::SetupNPCs(TArray NPC_Info_Array) +{ + NPCs = NPC_Info_Array; +} + +void ANPC_Station::Interact() +{ + if (NPCs.IsEmpty() || !IsValid(PlayersPawn)) return; + + // Find closest NPC to the player + int ClosestIndex = 0; + float Distance = 999999999; + for (int i = 0; i < NPCs.Num(); i++) + { + float CheckDistance = FVector::Distance(PlayersPawn->GetActorLocation(), NPCs[i].NPC_Location); + if (CheckDistance <= Distance) + { + ClosestIndex = i; + Distance = CheckDistance; + } + } + // Get a random voice line and play if it's valid + if (NPCs[ClosestIndex].BarkLines.IsEmpty() || NPCs[ClosestIndex].VoiceComp == nullptr) return; + int RandomVoiceLineIndex = FMath::RandRange(0, NPCs[ClosestIndex].BarkLines.Num() - 1); + if (!IsValid(NPCs[ClosestIndex].BarkLines[RandomVoiceLineIndex])) return; + NPCs[ClosestIndex].VoiceComp->Sound = NPCs[ClosestIndex].BarkLines[RandomVoiceLineIndex]; + NPCs[ClosestIndex].VoiceComp->Play(); +} + +void ANPC_Station::BeginPlay() +{ + Super::BeginPlay(); + PlayersPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0); +} + // Sets default values ANPC_Station::ANPC_Station() { @@ -11,5 +49,21 @@ ANPC_Station::ANPC_Station() } +void ANPC_Station::EnableStation() +{ + if (bIsEnabled) return; + GetRootComponent()->SetVisibility(true, true); + GetRootComponent()->SetActive(true); + bIsEnabled = true; +} + +void ANPC_Station::DisableStation() +{ + if (!bIsEnabled) return; + GetRootComponent()->SetVisibility(false, true); + GetRootComponent()->SetActive(false); + bIsEnabled = false; +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.h b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.h index 68f98d59..b3da436b 100644 --- a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.h +++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Station.h @@ -3,24 +3,39 @@ #pragma once #include "CoreMinimal.h" +#include "NPC_InfoStruct.h" +#include "EndlessVendetta/InteractionInterface.h" #include "GameFramework/Actor.h" #include "NPC_Station.generated.h" + + UCLASS() -class ENDLESSVENDETTA_API ANPC_Station : public AActor +class ENDLESSVENDETTA_API ANPC_Station : public AActor, public IInteractionInterface { GENERATED_BODY() + bool bIsEnabled = false; + + // Contains infor about individual NPC locations and Voices + TArray NPCs; + + AActor* PlayersPawn; + protected: + UFUNCTION(BlueprintCallable) + void SetupNPCs(TArray NPC_Info_Array); + + void Interact() override; + + void BeginPlay() override; public: // Sets default values for this actor's properties ANPC_Station(); - - UFUNCTION(BlueprintImplementableEvent) + void EnableStation(); - - UFUNCTION(BlueprintImplementableEvent) + void DisableStation();