mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 08:02:23 -07:00
83 lines
2.4 KiB
C++
83 lines
2.4 KiB
C++
#include "CogSamplePlayerController.h"
|
|
|
|
#include "CogDefines.h"
|
|
#include "CogSampleCharacter.h"
|
|
#include "CogSampleTargetAcquisition.h"
|
|
#include "Net/UnrealNetwork.h"
|
|
|
|
#if USE_COG
|
|
#include "CogAbilityReplicator.h"
|
|
#include "CogDebugDefines.h"
|
|
#include "CogDebugReplicator.h"
|
|
#include "CogEngineReplicator.h"
|
|
#endif //USE_COG
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
ACogSamplePlayerController::ACogSamplePlayerController()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
void ACogSamplePlayerController::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
#if USE_COG
|
|
ACogDebugReplicator::Create(this);
|
|
ACogAbilityReplicator::Create(this);
|
|
ACogEngineReplicator::Create(this);
|
|
#endif //USE_COG
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
void ACogSamplePlayerController::AcknowledgePossession(APawn* P)
|
|
{
|
|
Super::AcknowledgePossession(P);
|
|
|
|
if (ACogSampleCharacter* PossessedCharacter = Cast<ACogSampleCharacter>(P))
|
|
{
|
|
PossessedCharacter->OnAcknowledgePossession(this);
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
void ACogSamplePlayerController::Tick(float DeltaSeconds)
|
|
{
|
|
Super::Tick(DeltaSeconds);
|
|
|
|
if (TargetAcquisition != nullptr)
|
|
{
|
|
TArray<AActor*> TagretToIgnore;
|
|
FCogSampleTargetAcquisitionResult Result;
|
|
TargetAcquisition->FindBestTarget(this, TagretToIgnore, nullptr, true, FVector2D::ZeroVector, false, Result);
|
|
SetTarget(Result.Target);
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
void ACogSamplePlayerController::SetTarget(AActor* Value)
|
|
{
|
|
if (Value == Target)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AActor* OldTarget = Target.Get();
|
|
|
|
Target = Value;
|
|
|
|
if (GetLocalRole() == ROLE_AutonomousProxy)
|
|
{
|
|
Server_SetTarget(Value);
|
|
}
|
|
|
|
OnTargetChanged.Broadcast(this, Target.Get(), OldTarget);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
void ACogSamplePlayerController::Server_SetTarget_Implementation(AActor* Value)
|
|
{
|
|
Target = Value;
|
|
}
|