-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13d354b
commit 77197b1
Showing
58 changed files
with
3,987 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.Net.Component.4.6.2.TargetingPack", | ||
"Microsoft.VisualStudio.Component.VC.14.34.17.4.x86.x64", | ||
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64", | ||
"Microsoft.VisualStudio.Component.Windows10SDK", | ||
"Microsoft.VisualStudio.Workload.CoreEditor", | ||
"Microsoft.VisualStudio.Workload.ManagedDesktop", | ||
"Microsoft.VisualStudio.Workload.NativeDesktop", | ||
"Microsoft.VisualStudio.Workload.NativeGame" | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
Plugins/AdvancedTrafficSystem/AdvancedTrafficSystem.uplugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.0", | ||
"FriendlyName": "AdvancedTrafficSystem", | ||
"Description": "Custom traffic implementation usings Epic Games' ZoneGraph system", | ||
"Category": "Other", | ||
"CreatedBy": "Jonas Samyn", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"CanContainContent": true, | ||
"IsBetaVersion": false, | ||
"IsExperimentalVersion": false, | ||
"Installed": false, | ||
"Modules": [ | ||
{ | ||
"Name": "AdvancedTrafficSystem", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
} | ||
] | ||
} |
Binary file added
BIN
+119 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/BP_ATS_AgentSpawner.uasset
Binary file not shown.
Binary file added
BIN
+21.6 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/BP_ATS_CityManager.uasset
Binary file not shown.
Binary file added
BIN
+85.1 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/BP_ATS_NavigationGoal.uasset
Binary file not shown.
Binary file added
BIN
+67.6 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/BP_ATS_TrafficLight.uasset
Binary file not shown.
Binary file added
BIN
+21.6 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/BP_ATS_TrafficManager.uasset
Binary file not shown.
Binary file added
BIN
+81.4 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/Vehicles/BP_ATS_PhysicsVehicle.uasset
Binary file not shown.
Binary file added
BIN
+31.4 KB
Plugins/AdvancedTrafficSystem/Content/Blueprints/Vehicles/BP_ATS_SimpleVehicle.uasset
Binary file not shown.
Binary file added
BIN
+8.02 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor.uasset
Binary file not shown.
Binary file added
BIN
+9.17 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor_Blue.uasset
Binary file not shown.
Binary file added
BIN
+9.06 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor_Green.uasset
Binary file not shown.
Binary file added
BIN
+9.21 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor_Orange.uasset
Binary file not shown.
Binary file added
BIN
+8.62 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor_Red.uasset
Binary file not shown.
Binary file added
BIN
+8.28 KB
Plugins/AdvancedTrafficSystem/Content/Materials/Mat_SolidColor_White.uasset
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions
57
Plugins/AdvancedTrafficSystem/Source/AdvancedTrafficSystem/AdvancedTrafficSystem.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright Epic Games, Inc. All Rights Reserved. | ||
|
||
using UnrealBuildTool; | ||
|
||
public class AdvancedTrafficSystem : ModuleRules | ||
{ | ||
public AdvancedTrafficSystem(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicIncludePaths.AddRange( | ||
new string[] { | ||
// ... add public include paths required here ... | ||
} | ||
); | ||
|
||
|
||
PrivateIncludePaths.AddRange( | ||
new string[] { | ||
// ... add other private include paths required here ... | ||
} | ||
); | ||
|
||
|
||
PublicDependencyModuleNames.AddRange( | ||
new string[] | ||
{ | ||
"Core", | ||
"Engine", | ||
"InputCore" , | ||
"ChaosVehicles" | ||
// ... add other public dependencies that you statically link with here ... | ||
} | ||
); | ||
|
||
|
||
PrivateDependencyModuleNames.AddRange( | ||
new string[] | ||
{ | ||
"CoreUObject", | ||
"Engine", | ||
"Slate", | ||
"SlateCore", | ||
"ZoneGraph" | ||
// ... add private dependencies that you statically link with here ... | ||
} | ||
); | ||
|
||
|
||
DynamicallyLoadedModuleNames.AddRange( | ||
new string[] | ||
{ | ||
// ... add any modules that your module loads dynamically here ... | ||
} | ||
); | ||
} | ||
} |
154 changes: 154 additions & 0 deletions
154
Plugins/AdvancedTrafficSystem/Source/AdvancedTrafficSystem/Private/ATS_AgentActor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
|
||
#include "../Public/ATS_AgentActor.h" | ||
#include "../Public/ATS_AgentNavigation.h" | ||
#include "../Public/ATS_AgentMain.h" | ||
|
||
// Sets default values | ||
AATS_AgentActor::AATS_AgentActor() | ||
{ | ||
// 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; | ||
|
||
} | ||
|
||
// Called when the game starts or when spawned | ||
void AATS_AgentActor::BeginPlay() | ||
{ | ||
Super::BeginPlay(); | ||
SpawnActor(); | ||
SwitchToActor(false); | ||
} | ||
|
||
// Called every frame | ||
void AATS_AgentActor::Tick(float DeltaTime) | ||
{ | ||
Super::Tick(DeltaTime); | ||
|
||
m_ElapsedTime += DeltaTime; | ||
if (m_ElapsedTime > m_DistanceCheckInterval) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Distance check")); | ||
m_ElapsedTime = 0.f; | ||
DistanceToMainAgentCheck(); | ||
} | ||
} | ||
|
||
void AATS_AgentActor::SwitchToActor(bool bPhysics) | ||
{ | ||
if(bPhysics == bIsPhysicsActor) | ||
{ | ||
return; | ||
} | ||
|
||
|
||
if (m_PhysicsActor == nullptr || m_SimpleActor == nullptr) | ||
{ | ||
return; | ||
} | ||
|
||
EnableActor(m_PhysicsActor, bPhysics); | ||
EnableActor(m_SimpleActor, !bPhysics); | ||
|
||
if (bPhysics) | ||
{ | ||
CompareAgentData(m_PhysicsActor, m_SimpleActor); | ||
} | ||
else | ||
{ | ||
CompareAgentData(m_SimpleActor, m_PhysicsActor); | ||
} | ||
|
||
bIsPhysicsActor = bPhysics; | ||
} | ||
|
||
void AATS_AgentActor::EnableActor(AActor* actor, bool bEnable) | ||
{ | ||
actor->SetActorHiddenInGame(!bEnable); | ||
actor->SetActorTickEnabled(bEnable); | ||
actor->SetActorEnableCollision(bEnable); | ||
} | ||
|
||
void AATS_AgentActor::CompareAgentData(AActor* receiver, AActor* sender) | ||
{ | ||
UATS_AgentNavigation* receiverNavigation = receiver->FindComponentByClass<UATS_AgentNavigation>(); | ||
UATS_AgentNavigation* senderNavigation = sender->FindComponentByClass<UATS_AgentNavigation>(); | ||
|
||
if (receiverNavigation == nullptr || senderNavigation == nullptr) | ||
{ | ||
return; | ||
} | ||
|
||
receiverNavigation->SetAgentData(senderNavigation->GetAgentData()); | ||
|
||
receiverNavigation->EnableAgent(); | ||
senderNavigation->DissableAgent(); | ||
|
||
// Assuming `sender` is the actor you want to move | ||
FTransform SenderOriginalTransform = sender->GetActorTransform(); | ||
|
||
FVector SenderLocation = SenderOriginalTransform.GetLocation(); | ||
SenderLocation.Z = -1000.0f; // Move the actor 1000 units down on the Z-axis | ||
|
||
// Use SetActorLocation with the Teleport flag set to true | ||
sender->SetActorLocation(SenderLocation, false, nullptr, ETeleportType::ResetPhysics); | ||
|
||
// If you want to set the entire transform, including rotation and scale, use SetActorTransform | ||
receiver->SetActorTransform(SenderOriginalTransform, true, nullptr, ETeleportType::ResetPhysics); | ||
|
||
} | ||
|
||
void AATS_AgentActor::DistanceToMainAgentCheck() | ||
{ | ||
if (m_AgentMain == nullptr) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Main agent is null")); | ||
return; | ||
} | ||
|
||
if (m_PhysicsActor == nullptr || m_SimpleActor == nullptr) | ||
{ | ||
return; | ||
} | ||
|
||
float distance{ 0.f }; | ||
if (bIsPhysicsActor) | ||
{ | ||
distance = m_PhysicsActor->GetSquaredDistanceTo(m_AgentMain->GetOwner()); | ||
} | ||
else | ||
{ | ||
distance = m_SimpleActor->GetSquaredDistanceTo(m_AgentMain->GetOwner()); | ||
} | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Distance to main agent: %f"), distance); | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Distance to LowDetail Distance: %f"), m_AgentMain->GetLowDetailSquaredDistance()); | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Distance to HighDetail Distance: %f"), m_AgentMain->GetHighDetailSquaredDistance()); | ||
|
||
if (distance > m_AgentMain->GetLowDetailSquaredDistance()) | ||
{ | ||
//To far away -- nothing to show | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Too far away -- remove")); | ||
|
||
m_PhysicsActor->Destroy(); | ||
m_SimpleActor->Destroy(); | ||
Destroy(); | ||
} | ||
else | ||
{ | ||
//Show high detail | ||
SwitchToActor(true); | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Switch to high detail")); | ||
} | ||
} | ||
|
||
void AATS_AgentActor::SetMainAgent(UATS_AgentMain* pAgentMain) | ||
{ | ||
if (pAgentMain == nullptr) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentActor::Main agent is null")); | ||
return; | ||
} | ||
|
||
m_AgentMain = pAgentMain; | ||
} |
69 changes: 69 additions & 0 deletions
69
Plugins/AdvancedTrafficSystem/Source/AdvancedTrafficSystem/Private/ATS_AgentLifeTime.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
|
||
#include "../Public/ATS_AgentLifeTime.h" | ||
#include "../Public/ATS_AgentMain.h" | ||
|
||
|
||
UATS_AgentLifeTime::UATS_AgentLifeTime() | ||
{ | ||
PrimaryComponentTick.bCanEverTick = true; | ||
} | ||
|
||
|
||
void UATS_AgentLifeTime::BeginPlay() | ||
{ | ||
Super::BeginPlay(); | ||
} | ||
|
||
|
||
// Called every frame | ||
void UATS_AgentLifeTime::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | ||
{ | ||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction); | ||
|
||
if (bIsDisabled) | ||
{ | ||
return; | ||
} | ||
|
||
m_ElapsedTime += DeltaTime; | ||
if (m_ElapsedTime > m_DistanceCheckInterval) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Distance check")); | ||
m_ElapsedTime = 0.f; | ||
DistanceToMainAgentCheck(); | ||
} | ||
} | ||
|
||
void UATS_AgentLifeTime::DistanceToMainAgentCheck() | ||
{ | ||
if (m_AgentMain == nullptr) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Main agent is null")); | ||
return; | ||
} | ||
|
||
float distance = GetOwner()->GetSquaredDistanceTo(m_AgentMain->GetOwner()); | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Distance to main agent: %f"), distance); | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Distance to LowDetail Distance: %f"), m_AgentMain->GetLowDetailSquaredDistance()); | ||
|
||
if (distance > m_AgentMain->GetHighDetailSquaredDistance()) | ||
{ | ||
//To far away -- nothing to show | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Too far away -- remove")); | ||
GetOwner()->Destroy(); | ||
m_AgentMain->RegisterAgentLoss(); | ||
} | ||
} | ||
|
||
void UATS_AgentLifeTime::SetMainAgent(UATS_AgentMain* pAgentMain) | ||
{ | ||
if (pAgentMain == nullptr) | ||
{ | ||
UE_LOG(LogTemp, Warning, TEXT("AgentLifeTime::Main agent is null")); | ||
return; | ||
} | ||
|
||
m_AgentMain = pAgentMain; | ||
} |
34 changes: 34 additions & 0 deletions
34
Plugins/AdvancedTrafficSystem/Source/AdvancedTrafficSystem/Private/ATS_AgentMain.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
|
||
#include "../Public/ATS_AgentMain.h" | ||
|
||
UATS_AgentMain::UATS_AgentMain() | ||
{ | ||
PrimaryComponentTick.bCanEverTick = true; | ||
} | ||
|
||
|
||
// Called when the game starts | ||
void UATS_AgentMain::BeginPlay() | ||
{ | ||
Super::BeginPlay(); | ||
|
||
m_HighDetailDistanceSquared = m_HighDetailDistance * m_HighDetailDistance; | ||
m_LowDetailDistanceSquared = m_LowDetailDistance * m_LowDetailDistance; | ||
} | ||
|
||
|
||
// Called every frame | ||
void UATS_AgentMain::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | ||
{ | ||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction); | ||
|
||
// ... | ||
} | ||
|
||
void UATS_AgentMain::RegisterAgentLoss() | ||
{ | ||
++m_AgentLoss; | ||
} | ||
|
Oops, something went wrong.