Files
UnrealEngineUWP/Engine/Source/Developer/AITestSuite/Private/BehaviorTree/TestBTService_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

75 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BehaviorTree/TestBTService_Log.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "MockAI_BT.h"
UTestBTService_Log::UTestBTService_Log(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
NodeName = "LogService";
INIT_SERVICE_NODE_NOTIFY_FLAGS();
LogActivation = INDEX_NONE;
LogDeactivation = INDEX_NONE;
KeyNameTick = NAME_None;
LogTick = INDEX_NONE;
KeyNameBecomeRelevant = NAME_None;
KeyNameCeaseRelevant = NAME_None;
// Force the service to tick every frame
Interval = 0.0f;
RandomDeviation = 0.0f;
}
void UTestBTService_Log::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::OnBecomeRelevant(OwnerComp, NodeMemory);
if (KeyNameBecomeRelevant != NAME_None)
{
OwnerComp.GetBlackboardComponent()->SetValueAsBool(KeyNameBecomeRelevant, true);
}
if (LogActivation >= 0)
{
UMockAI_BT::ExecutionLog.Add(LogActivation);
}
}
void UTestBTService_Log::OnCeaseRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::OnCeaseRelevant(OwnerComp, NodeMemory);
if (KeyNameCeaseRelevant != NAME_None)
{
OwnerComp.GetBlackboardComponent()->SetValueAsBool(KeyNameCeaseRelevant, true);
}
if (LogDeactivation >= 0)
{
UMockAI_BT::ExecutionLog.Add(LogDeactivation);
}
}
void UTestBTService_Log::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
if (KeyNameTick != NAME_None)
{
OwnerComp.GetBlackboardComponent()->SetValueAsBool(KeyNameTick, true);
}
if (LogTick >= 0)
{
UMockAI_BT::ExecutionLog.Add(LogTick);
}
}
void UTestBTService_Log::SetFlagOnTick(FName InKeyNameTick, bool bInCallTickOnSearchStart /* = false */)
{
KeyNameTick = InKeyNameTick;
bCallTickOnSearchStart = bInCallTickOnSearchStart;
}