Files
UnrealEngineUWP/Engine/Source/Developer/AITestSuite/Private/BehaviorTree/TestBTTask_Log.cpp
charles lefebvre 2bf5a3030e Redo CL18328294, but compare decltype instead of comparing functions addresses as this is an undefined behavior with virtual function
Add a InitNotifyFlags function to UBTAuxiliaryNode, UBTTaskNode, UBTCompositeNode, UBTDecorator and UBTService to setup the various flags that must be set when some functions are overriden.
Add macros to call those functions, this is necessary as those functions are protected.
Use those macros in various nodes (not all of them, this is not possible for some blueprint tasks)
#tests PIE
Maxime.Mercier, Karl.Dubois, Guillaume.Arruda
[FYI] nicolas.bonnelly, Guillaume.Guay, Loic.Devaux,  Mieszko.Zielinski, Guillaume.Morreel
#rnx

#ROBOMERGE-AUTHOR: charles.lefebvre
#ROBOMERGE-SOURCE: CL 18385614 via CL 18385628 via CL 18385644 via CL 18434568 via CL 18435684
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18436637 by charles lefebvre in ue5-release-engine-test branch]
2021-12-10 19:21:13 -05:00

60 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BehaviorTree/TestBTTask_Log.h"
#include "MockAI_BT.h"
UTestBTTask_Log::UTestBTTask_Log(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
NodeName = "Log";
ExecutionTicks = 0;
LogIndex = 0;
LogFinished = -1;
LogResult = EBTNodeResult::Succeeded;
LogTickIndex = -1;
INIT_TASK_NODE_NOTIFY_FLAGS();
}
EBTNodeResult::Type UTestBTTask_Log::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
FBTLogTaskMemory* MyMemory = CastInstanceNodeMemory<FBTLogTaskMemory>(NodeMemory);
MyMemory->EndFrameIdx = ExecutionTicks + FAITestHelpers::FramesCounter();
LogExecution(OwnerComp, LogIndex);
if (ExecutionTicks == 0)
{
return LogResult;
}
return EBTNodeResult::InProgress;
}
void UTestBTTask_Log::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
FBTLogTaskMemory* MyMemory = CastInstanceNodeMemory<FBTLogTaskMemory>(NodeMemory);
if (LogTickIndex != -1)
{
LogExecution(OwnerComp, LogTickIndex);
}
if (FAITestHelpers::FramesCounter() >= MyMemory->EndFrameIdx)
{
LogExecution(OwnerComp, LogFinished);
FinishLatentTask(OwnerComp, LogResult);
}
}
uint16 UTestBTTask_Log::GetInstanceMemorySize() const
{
return sizeof(FBTLogTaskMemory);
}
void UTestBTTask_Log::LogExecution(UBehaviorTreeComponent& OwnerComp, int32 LogNumber)
{
if (LogNumber >= 0)
{
UMockAI_BT::ExecutionLog.Add(LogNumber);
}
}