mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-26 13:45:00 -07:00
simplify integration
This commit is contained in:
@@ -8,8 +8,8 @@ public class CogSample : ModuleRules
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"CogDebug",
|
||||
"Core",
|
||||
"CogCommon",
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"EnhancedInput",
|
||||
@@ -25,8 +25,8 @@ public class CogSample : ModuleRules
|
||||
{
|
||||
PublicDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"CogDebug",
|
||||
"CogImgui",
|
||||
"CogInterface",
|
||||
"CogWindow",
|
||||
"CogEngine",
|
||||
"CogInput",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "CogSampleCharacter.h"
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "CogDebugLogMacros.h"
|
||||
#include "CogDebugMetric.h"
|
||||
#include "CogCommon.h"
|
||||
#include "CogSampleAttributeSet_Health.h"
|
||||
#include "CogSampleAttributeSet_Misc.h"
|
||||
#include "CogSampleCharacterMovementComponent.h"
|
||||
@@ -24,10 +23,11 @@
|
||||
#include "Net/Core/PushModel/PushModel.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugMetric.h"
|
||||
#include "CogDebugPlot.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ACogSampleCharacter::ACogSampleCharacter(const FObjectInitializer& ObjectInitializer)
|
||||
@@ -476,18 +476,18 @@ void ACogSampleCharacter::Look(const FInputActionValue& Value)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogInterfacesAllegiance ACogSampleCharacter::GetAllegianceWithOtherActor(const AActor* OtherActor) const
|
||||
ECogCommonAllegiance ACogSampleCharacter::GetAllegianceWithOtherActor(const AActor* OtherActor) const
|
||||
{
|
||||
ECogSampleAllegiance Allegiance = UCogSampleFunctionLibrary_Team::GetActorsAllegiance(this, OtherActor);
|
||||
|
||||
switch (Allegiance)
|
||||
{
|
||||
case ECogSampleAllegiance::Enemy: return ECogInterfacesAllegiance::Enemy;
|
||||
case ECogSampleAllegiance::Friendly: return ECogInterfacesAllegiance::Friendly;
|
||||
case ECogSampleAllegiance::Neutral: return ECogInterfacesAllegiance::Neutral;
|
||||
case ECogSampleAllegiance::Enemy: return ECogCommonAllegiance::Enemy;
|
||||
case ECogSampleAllegiance::Friendly: return ECogCommonAllegiance::Friendly;
|
||||
case ECogSampleAllegiance::Neutral: return ECogCommonAllegiance::Neutral;
|
||||
}
|
||||
|
||||
return ECogInterfacesAllegiance::Neutral;
|
||||
return ECogCommonAllegiance::Neutral;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -495,9 +495,9 @@ void ACogSampleCharacter::HandleDamageReceived(const FCogSampleDamageEventParams
|
||||
{
|
||||
OnDamageReceived.Broadcast(Params);
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
FCogDebugMetric::AddMetric(this, "Damage Received", Params.MitigatedDamage, Params.UnmitigatedDamage, false);
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -505,9 +505,9 @@ void ACogSampleCharacter::HandleDamageDealt(const FCogSampleDamageEventParams& P
|
||||
{
|
||||
OnDamageDealt.Broadcast(Params);
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
FCogDebugMetric::AddMetric(this, "Damage Dealt", Params.MitigatedDamage, Params.UnmitigatedDamage, false);
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -553,21 +553,21 @@ void ACogSampleCharacter::OnRevived(AActor* InInstigator, AActor* InCauser, cons
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleCharacter::OnGameplayEffectAdded(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& GameplayEffectSpec, FActiveGameplayEffectHandle Handle)
|
||||
{
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
FCogDebugPlot::PlotEvent(this, "Effects", GameplayEffectSpec.Def->GetFName(), GameplayEffectSpec.GetDuration() == 0.0f)
|
||||
.AddParam("Name", AbilitySystemComponent->CleanupName(GetNameSafe(GameplayEffectSpec.Def)))
|
||||
.AddParam("Effect Instigator", GetNameSafe(GameplayEffectSpec.GetEffectContext().GetInstigator()))
|
||||
.AddParam("Effect Level", GameplayEffectSpec.GetLevel())
|
||||
.AddParam("Effect Duration", GameplayEffectSpec.GetDuration());
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleCharacter::OnGameplayEffectRemoved(const FActiveGameplayEffect& RemovedGameplayEffect)
|
||||
{
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
FCogDebugPlot::PlotEventStop(this, "Effects", RemovedGameplayEffect.Spec.Def->GetFName());
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "ActiveGameplayEffectHandle.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "CogSampleDefines.h"
|
||||
#include "CogInterfaceAllegianceActor.h"
|
||||
#include "CogInterfaceDebugFilteredActor.h"
|
||||
#include "CogCommonAllegianceActorInterface.h"
|
||||
#include "CogCommonDebugFilteredActorInterface.h"
|
||||
#include "CogSampleDamageEvent.h"
|
||||
#include "CogSampleDefines.h"
|
||||
#include "CogSampleTargetableInterface.h"
|
||||
#include "CogSampleTeamInterface.h"
|
||||
#include "GameFramework/Character.h"
|
||||
@@ -65,8 +65,8 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleCharacterEventDelegate, AC
|
||||
UCLASS(config=Game)
|
||||
class ACogSampleCharacter : public ACharacter
|
||||
, public IAbilitySystemInterface
|
||||
, public ICogInterfacesDebugFilteredActor
|
||||
, public ICogInterfacesAllegianceActor
|
||||
, public ICogCommonDebugFilteredActorInterface
|
||||
, public ICogCommonAllegianceActorInterface
|
||||
, public ICogSampleTeamInterface
|
||||
, public ICogSampleTargetableInterface
|
||||
{
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
// ICogInterfacesAllegianceActor overrides
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
ECogInterfacesAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const override;
|
||||
ECogCommonAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const override;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// ICogSampleTargetInterface overrides
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugPlot.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// UCogSampleCharacterMovementComponent::FCogSampleSavedMove
|
||||
@@ -209,17 +209,17 @@ void UCogSampleCharacterMovementComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
const ACharacter* Character = GetCharacterOwner();
|
||||
const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent();
|
||||
DebugLastBottomLocation = Character->GetActorLocation() - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight();
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
const ACharacter* Character = GetCharacterOwner();
|
||||
const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent();
|
||||
@@ -232,11 +232,11 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E
|
||||
FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input Local Y", FVector::DotProduct(GetPawnOwner()->GetActorForwardVector(), GetPendingInputVector()));
|
||||
}
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
const FVector DebugLocation = Character->GetActorLocation();
|
||||
const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight();
|
||||
@@ -294,7 +294,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E
|
||||
DebugLastVelocity = Velocity;
|
||||
DebugIsPositionCorrected = false;
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
}
|
||||
|
||||
@@ -303,9 +303,9 @@ bool UCogSampleCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate
|
||||
{
|
||||
bool Result = Super::ClientUpdatePositionAfterServerUpdate();
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
DebugIsPositionCorrected = true;
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
|
||||
bool bWasAvoidanceEnabled = false;
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
FVector DebugLastBottomLocation = FVector::ZeroVector;
|
||||
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
|
||||
bool DebugIsPositionCorrected = false;
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommon.h"
|
||||
|
||||
#ifndef USE_COG
|
||||
#define USE_COG (ENABLE_DRAW_DEBUG && !NO_LOGGING)
|
||||
#endif
|
||||
#if ENABLE_COG
|
||||
|
||||
#if USE_COG
|
||||
|
||||
#include "CogDebugLogMacros.h"
|
||||
#include "CogDebugSettings.h"
|
||||
|
||||
#define IF_COG(expr) { expr; }
|
||||
#define COG_LOG_CATEGORY FLogCategoryBase
|
||||
|
||||
#define COG_LOG_ABILITY(Verbosity, Ability, Format, ...) \
|
||||
if (Ability != nullptr) \
|
||||
{ \
|
||||
@@ -28,10 +21,8 @@
|
||||
} \
|
||||
} \
|
||||
|
||||
#else //USE_COG
|
||||
#else //ENABLE_COG
|
||||
|
||||
#define IF_COG(expr) (0)
|
||||
#define COG_LOG_CATEGORY FNoLoggingCategory
|
||||
#define COG_LOG_ABILITY(...) (0)
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include "Particles/ParticleSystemComponent.h"
|
||||
#include "ScalableFloat.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugLog.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleFunctionLibrary_Gameplay::AdjustAttributeForMaxChange(UAbilitySystemComponent* AbilityComponent, FGameplayAttributeData& AffectedAttribute, float OldValue, float NewMaxValue, const FGameplayAttribute& AffectedAttributeProperty)
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
#include "AssetRegistry/AssetRegistryModule.h"
|
||||
#include "AssetRegistry/IAssetRegistry.h"
|
||||
#include "CogSampleDefines.h"
|
||||
#include "CogCommon.h"
|
||||
#include "CogSampleFunctionLibrary_Tag.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "GameFramework/GameState.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogAbilityDataAsset_Abilities.h"
|
||||
#include "CogAbilityDataAsset_Cheats.h"
|
||||
#include "CogAbilityDataAsset_Pools.h"
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "CogAbilityWindow_Pools.h"
|
||||
#include "CogAbilityWindow_Tags.h"
|
||||
#include "CogAbilityWindow_Tweaks.h"
|
||||
#include "CogDebugDefines.h"
|
||||
#include "CogDebugDrawImGui.h"
|
||||
#include "CogDebugPlot.h"
|
||||
#include "CogEngineDataAsset_Collisions.h"
|
||||
@@ -47,7 +46,7 @@
|
||||
#include "CogInputWindow_Actions.h"
|
||||
#include "CogInputWindow_Gamepad.h"
|
||||
#include "CogWindowManager.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -82,6 +81,10 @@ ACogSampleGameState::ACogSampleGameState(const FObjectInitializer & ObjectInitia
|
||||
void ACogSampleGameState::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
#if ENABLE_COG
|
||||
InitializeCog();
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -89,12 +92,12 @@ void ACogSampleGameState::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
{
|
||||
Super::EndPlay(EndPlayReason);
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
if (CogWindowManager != nullptr)
|
||||
{
|
||||
CogWindowManager->Shutdown();
|
||||
}
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -102,48 +105,28 @@ void ACogSampleGameState::Tick(float DeltaSeconds)
|
||||
{
|
||||
Super::Tick(DeltaSeconds);
|
||||
|
||||
#if USE_COG
|
||||
TickCog(DeltaSeconds);
|
||||
#endif //USE_COG
|
||||
}
|
||||
|
||||
#if USE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleGameState::TickCog(float DeltaSeconds)
|
||||
{
|
||||
//---------------------------------------
|
||||
// Wait for the viewport to be set
|
||||
//---------------------------------------
|
||||
if (GEngine->GameViewport != nullptr)
|
||||
{
|
||||
if (CogWindowManager == nullptr)
|
||||
{
|
||||
InitializeCog();
|
||||
}
|
||||
else
|
||||
{
|
||||
CogWindowManager->Tick(DeltaSeconds);
|
||||
}
|
||||
}
|
||||
#if ENABLE_COG
|
||||
|
||||
extern ENGINE_API float GAverageFPS;
|
||||
extern ENGINE_API float GAverageMS;
|
||||
FCogDebugPlot::PlotValue(this, "Frame Rate", GAverageFPS);
|
||||
FCogDebugPlot::PlotValue(this, "Frame Time", GAverageMS);
|
||||
|
||||
CogWindowManager->Tick(DeltaSeconds);
|
||||
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
#if ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleGameState::InitializeCog()
|
||||
{
|
||||
RegisterCommand(TEXT("Cog.ToggleInput"), TEXT(""), FConsoleCommandWithArgsDelegate::CreateUObject(this, &ACogSampleGameState::CogToggleInput));
|
||||
|
||||
TSharedPtr<SCogImguiWidget> Widget = FCogImguiModule::Get().CreateImGuiViewport(GEngine->GameViewport, [this](float DeltaTime) { RenderCog(DeltaTime); });
|
||||
FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert));
|
||||
RegisterCommand(TEXT("Cog.ToggleInput"), TEXT(""), FConsoleCommandWithArgsDelegate::CreateUObject(this, &ACogSampleGameState::CogToggleInput));
|
||||
|
||||
CogWindowManager = NewObject<UCogWindowManager>(this);
|
||||
CogWindowManagerRef = CogWindowManager;
|
||||
CogWindowManager->Initialize(GetWorld(), Widget);
|
||||
|
||||
//---------------------------------------
|
||||
// Engine
|
||||
@@ -174,7 +157,7 @@ void ACogSampleGameState::InitializeCog()
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Skeleton>("Engine.Skeleton");
|
||||
|
||||
UCogEngineWindow_Spawns* SpawnWindow =CogWindowManager->CreateWindow<UCogEngineWindow_Spawns>("Engine.Spawns");
|
||||
UCogEngineWindow_Spawns* SpawnWindow = CogWindowManager->CreateWindow<UCogEngineWindow_Spawns>("Engine.Spawns");
|
||||
SpawnWindow->SetSpawnsAsset(GetFirstAssetByClass<UCogEngineDataAsset_Spawns>());
|
||||
|
||||
UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow<UCogEngineWindow_Stats>("Engine.Stats");
|
||||
@@ -220,13 +203,6 @@ void ACogSampleGameState::InitializeCog()
|
||||
CogWindowManager->AddMainMenuWidget(StatsWindow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleGameState::RenderCog(float DeltaTime)
|
||||
{
|
||||
CogWindowManager->Render(DeltaTime);
|
||||
FCogDebugDrawImGui::Draw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleGameState::RegisterCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command)
|
||||
{
|
||||
@@ -244,4 +220,4 @@ void ACogSampleGameState::CogToggleInput(const TArray<FString>& Args)
|
||||
}
|
||||
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
@@ -25,19 +25,15 @@ private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<UObject> CogWindowManagerRef = nullptr;
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
void InitializeCog();
|
||||
|
||||
void TickCog(float DeltaTime);
|
||||
|
||||
void RenderCog(float DeltaTime);
|
||||
|
||||
void RegisterCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command);
|
||||
|
||||
void CogToggleInput(const TArray<FString>& Args);
|
||||
|
||||
TObjectPtr<UCogWindowManager> CogWindowManager = nullptr;
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include "AbilitySystemLog.h"
|
||||
#include "CogSampleDefines.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogDebugLog.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogCogAlways);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace CogSampleLog
|
||||
{
|
||||
void RegiterAllLogCategories()
|
||||
{
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
FCogDebugLog::AddLogCategory(LogCogAlways, "Always", false);
|
||||
|
||||
FCogDebugLog::AddLogCategory(LogCogAbility, "Ability");
|
||||
@@ -39,7 +39,7 @@ namespace CogSampleLog
|
||||
FCogDebugLog::AddLogCategory(LogCogSkeleton, "Skeleton");
|
||||
FCogDebugLog::AddLogCategory(LogCogTargetAcquisition, "Target Acquisition");
|
||||
FCogDebugLog::AddLogCategory(LogGameplayEffects, "Gameplay Effects");
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
#include "CogSamplePlayerController.h"
|
||||
|
||||
#include "CogDebugLogMacros.h"
|
||||
#include "CogCommon.h"
|
||||
#include "CogSampleDefines.h"
|
||||
#include "CogSampleCharacter.h"
|
||||
#include "CogSampleLogCategories.h"
|
||||
#include "CogSampleTargetAcquisition.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogDebugDefines.h"
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugReplicator.h"
|
||||
#include "CogEngineReplicator.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ACogSamplePlayerController::ACogSamplePlayerController()
|
||||
@@ -25,11 +24,11 @@ void ACogSamplePlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
ACogDebugReplicator::Spawn(this);
|
||||
ACogAbilityReplicator::Spawn(this);
|
||||
ACogEngineReplicator::Spawn(this);
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -169,12 +168,12 @@ void ACogSamplePlayerController::TickTargeting(float DeltaSeconds)
|
||||
SetTarget(Result.Target);
|
||||
}
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
if (Target != nullptr && PossessedCharacter != nullptr)
|
||||
{
|
||||
FCogDebugDraw::Segment(LogCogTargetAcquisition, PossessedCharacter.Get(), PossessedCharacter->GetActorLocation(), Target->GetActorLocation(), FColor::White, false);
|
||||
}
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "CogInterfacePossessor.h"
|
||||
#include "CogCommonPossessorInterface.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "CogSamplePlayerController.generated.h"
|
||||
|
||||
@@ -18,7 +18,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FCogSampleControlledCharacterChan
|
||||
UCLASS(config=Game)
|
||||
class ACogSamplePlayerController
|
||||
: public APlayerController
|
||||
, public ICogInterfacePossessor
|
||||
, public ICogCommonPossessorInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogDebugLog.h"
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogSampleTargetTargetAcquisitionParams
|
||||
@@ -125,13 +125,13 @@ void UCogSampleTargetAcquisition::FindBestTarget(
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// Draw the ScreenSearchDirection if valid
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
const FVector2D SearchDirectionNormalized = (TargetSwitchSearchDirection.IsNearlyZero() == false) ? TargetSwitchSearchDirection.GetSafeNormal() : FVector2D::ZeroVector;
|
||||
if (SearchDirectionNormalized.IsNearlyZero() == false)
|
||||
{
|
||||
FCogDebugDraw::Segment2D(LogCogTargetAcquisition, Controller, FVector2D::ZeroVector, FVector2D(SearchDirectionNormalized.X, -SearchDirectionNormalized.Y), FColor(255, 255, 0, 255), bIsDebugPersistent);
|
||||
}
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
static const FName TraceTag(TEXT("FindLockTarget_GatherTargets"));
|
||||
FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogSampleTargetAcquisition), false);
|
||||
@@ -285,7 +285,7 @@ void UCogSampleTargetAcquisition::FindBestTargetInCandidates(
|
||||
// Draw screen limits
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
FCogDebugDraw::Circle2D(LogCogTargetAcquisition, Controller, ScreenCrosshairPosition, 5.0f, FColor(255, 255, 255, 255), bIsDebugPersistent);
|
||||
|
||||
@@ -312,7 +312,7 @@ void UCogSampleTargetAcquisition::FindBestTargetInCandidates(
|
||||
bIsDebugPersistent);
|
||||
}
|
||||
}
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
const FRotator YawRotation = GetReferentialRotation(Character, YawReferential);
|
||||
const FVector YawDirection = YawRotation.Vector();
|
||||
@@ -545,7 +545,7 @@ bool UCogSampleTargetAcquisition::EvaluateCandidate(
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Draw the score of each candidate
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
|
||||
if (FCogDebugLog::IsLogCategoryActive(LogCogTargetAcquisition))
|
||||
{
|
||||
@@ -597,7 +597,7 @@ bool UCogSampleTargetAcquisition::EvaluateCandidate(
|
||||
FCogDebugDraw::String(LogCogTargetAcquisition, EvalParams.Controller, Text, CandidateTargetLocation, FColor::White, EvalParams.IsDebugPersistent);
|
||||
}
|
||||
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -669,13 +669,13 @@ bool UCogSampleTargetAcquisition::ComputeCandidateScreenLocation(
|
||||
bFoundValidCandidate = true;
|
||||
}
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
const FColor CapsuleColor = (ScreenCenterToCapsuleDistance > 0.0f) ? FColor(255, 255, 255, 100) : FColor(0, 255, 0, 200);
|
||||
FCogDebugDraw::Segment2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D + FVector2D(CapsuleRadius2D, 0), CapsuleTop2D + FVector2D(CapsuleRadius2D, 0), CapsuleColor, Params.IsDebugPersistent);
|
||||
FCogDebugDraw::Segment2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D - FVector2D(CapsuleRadius2D, 0), CapsuleTop2D - FVector2D(CapsuleRadius2D, 0), CapsuleColor, Params.IsDebugPersistent);
|
||||
FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CapsuleTop2D, CapsuleRadius2D, CapsuleColor, Params.IsDebugPersistent);
|
||||
FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D, CapsuleRadius2D, CapsuleColor, Params.IsDebugPersistent);
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -688,12 +688,12 @@ bool UCogSampleTargetAcquisition::ComputeCandidateScreenLocation(
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_COG
|
||||
#if ENABLE_COG
|
||||
if (bFoundValidCandidate)
|
||||
{
|
||||
FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CandidateClosestScreenLocation, 2.0f, FColor(0, 255, 0, 255), Params.IsDebugPersistent);
|
||||
}
|
||||
#endif //USE_COG
|
||||
#endif //ENABLE_COG
|
||||
|
||||
return bFoundValidCandidate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user