You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
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]
94 lines
2.8 KiB
C++
94 lines
2.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "BehaviorTree/TestBTTask_LatentWithFlags.h"
|
|
#include "BehaviorTree/BlackboardComponent.h"
|
|
#include "MockAI_BT.h"
|
|
|
|
UTestBTTask_LatentWithFlags::UTestBTTask_LatentWithFlags()
|
|
{
|
|
INIT_TASK_NODE_NOTIFY_FLAGS();
|
|
}
|
|
|
|
EBTNodeResult::Type UTestBTTask_LatentWithFlags::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
|
|
{
|
|
FBTLatentTaskMemory* MyMemory = CastInstanceNodeMemory<FBTLatentTaskMemory>(NodeMemory);
|
|
MyMemory->FlagFrameIdx = ExecuteHalfTicks + FAITestHelpers::FramesCounter();
|
|
MyMemory->EndFrameIdx = MyMemory->FlagFrameIdx + ExecuteHalfTicks;
|
|
MyMemory->bFlagSet = false;
|
|
MyMemory->bIsAborting = false;
|
|
|
|
LogExecution(OwnerComp, LogIndexExecuteStart);
|
|
if (ExecuteHalfTicks == 0)
|
|
{
|
|
OwnerComp.GetBlackboardComponent()->SetValueAsBool(KeyNameExecute, true);
|
|
MyMemory->bFlagSet = true;
|
|
|
|
LogExecution(OwnerComp, LogIndexExecuteFinish);
|
|
return LogResult;
|
|
}
|
|
|
|
return EBTNodeResult::InProgress;
|
|
}
|
|
|
|
EBTNodeResult::Type UTestBTTask_LatentWithFlags::AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
|
|
{
|
|
FBTLatentTaskMemory* MyMemory = CastInstanceNodeMemory<FBTLatentTaskMemory>(NodeMemory);
|
|
MyMemory->FlagFrameIdx = AbortHalfTicks + FAITestHelpers::FramesCounter();
|
|
MyMemory->EndFrameIdx = MyMemory->FlagFrameIdx + AbortHalfTicks;
|
|
MyMemory->bFlagSet = false;
|
|
MyMemory->bIsAborting = true;
|
|
|
|
LogExecution(OwnerComp, LogIndexAbortStart);
|
|
if (AbortHalfTicks == 0)
|
|
{
|
|
OwnerComp.GetBlackboardComponent()->SetValueAsBool(KeyNameAbort, true);
|
|
MyMemory->bFlagSet = true;
|
|
|
|
LogExecution(OwnerComp, LogIndexAbortFinish);
|
|
return EBTNodeResult::Aborted;
|
|
}
|
|
|
|
return EBTNodeResult::InProgress;
|
|
}
|
|
|
|
void UTestBTTask_LatentWithFlags::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
|
|
{
|
|
FBTLatentTaskMemory* MyMemory = CastInstanceNodeMemory<FBTLatentTaskMemory>(NodeMemory);
|
|
|
|
LogExecution(OwnerComp, MyMemory->bIsAborting ? LogIndexAborting : LogIndexExecuting);
|
|
|
|
if (!MyMemory->bFlagSet && FAITestHelpers::FramesCounter() >= MyMemory->FlagFrameIdx)
|
|
{
|
|
MyMemory->bFlagSet = true;
|
|
OwnerComp.GetBlackboardComponent()->SetValueAsBool(
|
|
MyMemory->bIsAborting ? KeyNameAbort : KeyNameExecute,
|
|
true);
|
|
}
|
|
|
|
if (FAITestHelpers::FramesCounter() >= MyMemory->EndFrameIdx)
|
|
{
|
|
if (MyMemory->bIsAborting)
|
|
{
|
|
LogExecution(OwnerComp, LogIndexAbortFinish);
|
|
FinishLatentAbort(OwnerComp);
|
|
}
|
|
else
|
|
{
|
|
LogExecution(OwnerComp, LogIndexExecuteFinish);
|
|
FinishLatentTask(OwnerComp, LogResult);
|
|
}
|
|
}
|
|
}
|
|
|
|
uint16 UTestBTTask_LatentWithFlags::GetInstanceMemorySize() const
|
|
{
|
|
return sizeof(FBTLatentTaskMemory);
|
|
}
|
|
|
|
void UTestBTTask_LatentWithFlags::LogExecution(UBehaviorTreeComponent& OwnerComp, int32 LogNumber)
|
|
{
|
|
if (LogNumber >= 0)
|
|
{
|
|
UMockAI_BT::ExecutionLog.Add(LogNumber);
|
|
}
|
|
} |