diff --git a/Plugins/CogAI/Source/CogAI/CogAI.Build.cs b/Plugins/CogAI/Source/CogAI/CogAI.Build.cs index efd8209..5227c1f 100644 --- a/Plugins/CogAI/Source/CogAI/CogAI.Build.cs +++ b/Plugins/CogAI/Source/CogAI/CogAI.Build.cs @@ -2,47 +2,48 @@ using UnrealBuildTool; public class CogAI : ModuleRules { - public CogAI(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", + public CogAI(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicIncludePaths.AddRange( + new string[] { + } + ); + + + PrivateIncludePaths.AddRange( + new string[] { + } + ); + + + PublicDependencyModuleNames.AddRange( + new string[] + { + "Core", + "CogCommon", "CogImgui", "CogDebug", "CogWindow", } ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", + + + PrivateDependencyModuleNames.AddRange( + new string[] + { + "CoreUObject", + "Engine", "AIModule", } ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - } - ); - } + + + DynamicallyLoadedModuleNames.AddRange( + new string[] + { + } + ); + } } diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIModule.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIModule.cpp index adbb216..4d8dad8 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIModule.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIModule.cpp @@ -2,6 +2,8 @@ #define LOCTEXT_NAMESPACE "FCogAIModule" +DEFINE_LOG_CATEGORY(LogCogAI); + //-------------------------------------------------------------------------------------------------------------------------- void FCogAIModule::StartupModule() { diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp index 90d4ff0..edeed03 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp @@ -7,6 +7,8 @@ #include "BehaviorTree/Tasks/BTTask_BlueprintBase.h" #include "BehaviorTree/Tasks/BTTask_Wait.h" #include "BrainComponent.h" +#include "CogAIModule.h" +#include "CogDebugDraw.h" #include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "GameFramework/Pawn.h" @@ -26,12 +28,100 @@ UCogAIWindow_BehaviorTree::UCogAIWindow_BehaviorTree() bHasMenu = true; } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAIWindow_BehaviorTree::GameTick(float DeltaTime) +{ + Super::GameTick(DeltaTime); + +#if ENABLE_COG + + const AActor* Selection = GetSelection(); + if (Selection == nullptr) + { + return; + } + + const APawn* Pawn = Cast(Selection); + if (Pawn == nullptr) + { + return; + } + + const AAIController* AIController = Cast(Pawn->Controller); + if (AIController == nullptr) + { + return; + } + + const UPathFollowingComponent* PathFollowing = AIController->GetPathFollowingComponent(); + if (PathFollowing == nullptr) + { + return; + } + + const FNavigationPath* CurrentPath = PathFollowing->GetPath().Get(); + if (CurrentPath == nullptr) + { + return; + } + + FVector LastLocation; + for (int32 i = 0; i < CurrentPath->GetPathPoints().Num(); i++) + { + const FVector& Location = CurrentPath->GetPathPoints()[i].Location; + + if (i > 0) + { + FCogDebugDraw::Arrow(LogCogAI, this, LastLocation, Location, FColor::White, false, 0); + FCogDebugDraw::Point(LogCogAI, this, LastLocation, 10.0f, FColor::White, false, 0); + FCogDebugDraw::Point(LogCogAI, this, Location, 10.0f, FColor::White, false, 0); + } + + LastLocation = Location; + } + + //TArray Tokens; + //TArray Flags; + //PathFollowing->GetDebugStringTokens(Tokens, Flags); + + //for (int32 Idx = 0; Idx < Tokens.Num(); Idx++) + //{ + // switch (Flags[Idx]) + // { + // case EPathFollowingDebugTokens::Description: + // DataPack.PathFollowingInfo += Tokens[Idx]; + // break; + + // case EPathFollowingDebugTokens::ParamName: + // DataPack.PathFollowingInfo += TEXT(", {yellow}"); + // DataPack.PathFollowingInfo += Tokens[Idx]; + // DataPack.PathFollowingInfo += TEXT(":"); + // break; + + // case EPathFollowingDebugTokens::PassedValue: + // DataPack.PathFollowingInfo += TEXT("{yellow}"); + // DataPack.PathFollowingInfo += Tokens[Idx]; + // break; + + // case EPathFollowingDebugTokens::FailedValue: + // DataPack.PathFollowingInfo += TEXT("{orange}"); + // DataPack.PathFollowingInfo += Tokens[Idx]; + // break; + + // default: + // break; + // } + //} + +#endif //ENABLE_COG + +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogAIWindow_BehaviorTree::RenderContent() { Super::RenderContent(); - if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("Options")) diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index caef3ef..041dda6 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -104,7 +104,6 @@ void UCogAIWindow_Blackboard::RenderContent() }); } - if (ImGui::BeginTable("Blackboard", 3, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIModule.h b/Plugins/CogAI/Source/CogAI/Public/CogAIModule.h index 3347eb1..879184e 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIModule.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIModule.h @@ -3,6 +3,8 @@ #include "CoreMinimal.h" #include "Modules/ModuleManager.h" +COGAI_API DECLARE_LOG_CATEGORY_EXTERN(LogCogAI, Warning, All); + class COGAI_API FCogAIModule : public IModuleInterface { public: diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h index 6fe4778..16bff43 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h @@ -18,7 +18,9 @@ public: protected: - void RenderHelp(); + virtual void GameTick(float DeltaTime) override; + + virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Source/CogSample/CogSampleLogCategories.cpp b/Source/CogSample/CogSampleLogCategories.cpp index 6e3b5b9..8466f30 100644 --- a/Source/CogSample/CogSampleLogCategories.cpp +++ b/Source/CogSample/CogSampleLogCategories.cpp @@ -4,13 +4,13 @@ #include "CogSampleDefines.h" #if ENABLE_COG +#include "CogAIModule.h" #include "CogDebugLog.h" #endif //ENABLE_COG DEFINE_LOG_CATEGORY(LogCogAlways); DEFINE_LOG_CATEGORY(LogCogAbility); -DEFINE_LOG_CATEGORY(LogCogAI); DEFINE_LOG_CATEGORY(LogCogBaseAimRotation); DEFINE_LOG_CATEGORY(LogCogCollision); DEFINE_LOG_CATEGORY(LogCogControlRotation); @@ -26,6 +26,7 @@ namespace CogSampleLog void RegisterAllLogCategories() { #if ENABLE_COG + FCogDebugLog::AddLogCategory(LogCogAlways, "Always", "Debug Category that is always active", false); FCogDebugLog::AddLogCategory(LogCogAbility, "Ability", "Log and debug draw of gameplay abilities"); @@ -41,6 +42,7 @@ namespace CogSampleLog FCogDebugLog::AddLogCategory(LogCogSkeleton, "Skeleton", "Debug Draw a Character Skeleton"); FCogDebugLog::AddLogCategory(LogCogTargetAcquisition, "Target Acquisition", "Debug Draw the target acquisition debug draw"); FCogDebugLog::AddLogCategory(LogGameplayEffects, "Gameplay Effects", "Unreal Gameplay Effect Log"); + #endif //ENABLE_COG } } diff --git a/Source/CogSample/CogSampleLogCategories.h b/Source/CogSample/CogSampleLogCategories.h index 6c2ef09..8d69339 100644 --- a/Source/CogSample/CogSampleLogCategories.h +++ b/Source/CogSample/CogSampleLogCategories.h @@ -5,7 +5,6 @@ DECLARE_LOG_CATEGORY_EXTERN(LogCogAlways, VeryVerbose, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogAbility, Warning, All); -DECLARE_LOG_CATEGORY_EXTERN(LogCogAI, Warning, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogBaseAimRotation, Warning, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogCollision, Warning, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogControlRotation, Warning, All);