diff --git a/EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset b/EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
index f418982f..c5c3b84e 100644
--- a/EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
+++ b/EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:8f9af32c236df4b8a88ba167bd07764871f97e4bca76049e7ae26f08d2754537
-size 43745
+oid sha256:4a60a29ad596546d481e43dfb8698842a78cc07f4a4b1000fa397cfba4e72331
+size 158206
diff --git a/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset b/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset
index bf2e4391..28c08c5d 100644
--- a/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset
+++ b/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:01ef616c7a8bd90cd1b7a13efb18a56f33346efbae51efa31f09804478b7621d
-size 43456
+oid sha256:16f7b538fc11788aeefda67d9ef5cc07dc833571eba689fbafd778f1d309dee8
+size 53268
diff --git a/EndlessVendetta/EndlessVendetta.sln.DotSettings.user b/EndlessVendetta/EndlessVendetta.sln.DotSettings.user
new file mode 100644
index 00000000..2b08f3a1
--- /dev/null
+++ b/EndlessVendetta/EndlessVendetta.sln.DotSettings.user
@@ -0,0 +1,2 @@
+
+ C:\Users\Rafal\AppData\Local\JetBrains\Rider2023.3\resharper-host\temp\Rider\vAny\CoverageData\_EndlessVendetta.-1253833435\Snapshot\snapshot.utdcvr
\ No newline at end of file
diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp
index ad8069e6..57484afe 100644
--- a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp
+++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.cpp
@@ -13,14 +13,58 @@ ANPC_Manager::ANPC_Manager()
}
+void ANPC_Manager::SpawnNPC_Stations()
+{
+ if (NPC_StationClasses.IsEmpty()) return;
+
+ FRotator DefaultRot = FRotator(0, 0, 0);
+ int StationClassIndex = 0;
+ for (FVector StationPoint : StationPoints)
+ {
+ FVector StationPointWorldLocation = StationPoint + GetActorLocation();
+ ANPC_Station* NPC_Station = GetWorld()->SpawnActor(NPC_StationClasses[StationClassIndex], StationPointWorldLocation, DefaultRot);
+ if (IsValid(NPC_Station)) NPC_Stations.Add(NPC_Station);
+ StationClassIndex++;
+ if (StationClassIndex >= NPC_StationClasses.Num())
+ {
+ StationClassIndex = 0;
+ }
+ }
+}
+
+void ANPC_Manager::SpawnNPC_Walkers()
+{
+ if (NPC_WalkerClasses.IsEmpty()) return;
+
+ for (TSubclassOf NPC_Walker : NPC_WalkerClasses)
+ {
+ FTransform WalkersSpawnTransform = NPC_Walker->GetDefaultObject()->SpawnTransform;
+ FVector Loc = WalkersSpawnTransform.GetLocation();
+ FRotator Rot = WalkersSpawnTransform.GetRotation().Rotator();
+ ANPC_WalkerClass* SpawnedWalker = GetWorld()->SpawnActor(NPC_Walker, Loc, Rot);
+ NPC_Walkers.Add(SpawnedWalker);
+ }
+}
+
void ANPC_Manager::UpdateNPC_Stations()
{
for (ANPC_Station* NPC_Station : NPC_Stations)
{
+ if (!IsValid(NPC_Station)) continue;
FVector PlayersLoc = PlayersActor->GetActorLocation();
FVector StationLoc = NPC_Station->GetActorLocation();
float Distance = FVector::Distance(PlayersLoc, StationLoc);
- Distance > NPC_StationRenderDistance ? NPC_Station->DisableStation() : NPC_Station->EnableStation();
+ Distance > NPC_RenderDistance ? NPC_Station->DisableStation() : NPC_Station->EnableStation();
+ }
+}
+
+void ANPC_Manager::UpdateNPC_Walkers()
+{
+ for (ANPC_WalkerClass* Walker : NPC_Walkers)
+ {
+ if (!IsValid(Walker)) continue;
+ float Distance = FVector::Distance(PlayersActor->GetActorLocation(), Walker->GetActorLocation());
+ Distance <= NPC_RenderDistance ? Walker->EnableNPC() : Walker->DisableNPC();
}
}
@@ -35,22 +79,8 @@ void ANPC_Manager::BeginPlay()
SetActorTickEnabled(false);
return;
}
-
- if (NPC_StationClasses.IsEmpty()) return;
-
- FRotator DefaultRot = FRotator(0, 0, 0);
- int StationClassIndex = 0;
- for (FVector StationPoint : StationPoints)
- {
- FVector StationPointWorldLocation = StationPoint + GetActorLocation();
- ANPC_Station* NPC_Station = GetWorld()->SpawnActor(NPC_StationClasses[StationClassIndex], StationPointWorldLocation, DefaultRot);
- if (IsValid(NPC_Station)) NPC_Stations.Add(NPC_Station);
- StationClassIndex++;
- if (StationClassIndex >= NPC_StationClasses.Num())
- {
- StationClassIndex = 0;
- }
- }
+ SpawnNPC_Stations();
+ SpawnNPC_Walkers();
SetActorTickInterval(1);
}
@@ -59,5 +89,6 @@ void ANPC_Manager::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UpdateNPC_Stations();
+ UpdateNPC_Walkers();
}
diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.h b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.h
index aa072e5c..baf6036b 100644
--- a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.h
+++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_Manager.h
@@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "NPC_Station.h"
+#include "NPC_WalkerClass.h"
#include "GameFramework/Actor.h"
#include "NPC_Manager.generated.h"
@@ -20,13 +21,29 @@ class ENDLESSVENDETTA_API ANPC_Manager : public AActor
// How far can the station be from the player before it's diabled
UPROPERTY(EditDefaultsOnly, Category = "NPC")
- float NPC_StationRenderDistance = 5000;
+ float NPC_RenderDistance = 6000;
// references to All Spawned NPC Stations
TArray NPC_Stations;
+ // Used for Spawning walking NPCs
+ UPROPERTY(EditDefaultsOnly, Category = "NPC")
+ TArray> NPC_WalkerClasses;
+
+ // Reference to Walking NPCs
+ TArray NPC_Walkers;
+
+ // Spawn NPC Stations
+ void SpawnNPC_Stations();
+
+ // Spawn NPC Walkers
+ void SpawnNPC_Walkers();
+
// Dynamically Enables/Disables Stations based on distance to player
void UpdateNPC_Stations();
+
+ // Dynamically Enables/Disables Walking NPCs based on distance to player
+ void UpdateNPC_Walkers();
protected:
// Spawn points for NPC Stations
UPROPERTY(EditAnywhere, Category = "NPC", meta = (MakeEditWidget = "true"))
diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.cpp b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.cpp
new file mode 100644
index 00000000..9479e4a2
--- /dev/null
+++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.cpp
@@ -0,0 +1,37 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+
+#include "NPC_WalkerClass.h"
+
+// Sets default values
+ANPC_WalkerClass::ANPC_WalkerClass()
+{
+ // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
+ PrimaryActorTick.bCanEverTick = true;
+
+}
+
+FVector ANPC_WalkerClass::UpdateWalkingTarget()
+{
+ int BoundsCheck = WalkingSpotIndex + Polarity;
+ if (BoundsCheck < 0 || BoundsCheck >= WalkingSpots.Num()) Polarity *= -1;
+ WalkingSpotIndex += Polarity;
+ return WalkingSpots[WalkingSpotIndex];
+}
+
+void ANPC_WalkerClass::EnableNPC()
+{
+ if (bIsEnabled) return;
+ GetRootComponent()->SetVisibility(true, true);
+ bIsEnabled = true;
+}
+
+void ANPC_WalkerClass::DisableNPC()
+{
+ if (!bIsEnabled) return;
+ GetRootComponent()->SetVisibility(false, true);
+ bIsEnabled = false;
+}
+
+
+
diff --git a/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.h b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.h
new file mode 100644
index 00000000..1a350e6b
--- /dev/null
+++ b/EndlessVendetta/Source/EndlessVendetta/NPC/NPC_WalkerClass.h
@@ -0,0 +1,36 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+#pragma once
+
+#include "CoreMinimal.h"
+#include "GameFramework/Character.h"
+#include "NPC_WalkerClass.generated.h"
+
+UCLASS()
+class ENDLESSVENDETTA_API ANPC_WalkerClass : public ACharacter
+{
+ GENERATED_BODY()
+
+ int WalkingSpotIndex = 0;
+ int Polarity = 1;
+ bool bIsEnabled = true;
+
+protected:
+ UPROPERTY(VisibleAnywhere, Category = "NPC", meta = (MakeEditWidget = "true"))
+ TArray WalkingSpots;
+
+public:
+ UPROPERTY(EditDefaultsOnly, Category = "NPC")
+ const FTransform SpawnTransform;
+
+ // Sets default values for this character's properties
+ ANPC_WalkerClass();
+
+ UFUNCTION(BlueprintCallable)
+ FVector UpdateWalkingTarget();
+
+ void EnableNPC();
+
+ void DisableNPC();
+
+};