2021-12-01 10:50:36 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2021-11-24 04:26:29 -05:00
|
|
|
|
|
|
|
|
#include "Blueprint/StateTreeConditionBlueprintBase.h"
|
2023-01-19 00:48:07 -05:00
|
|
|
#include "Blueprint/StateTreeNodeBlueprintBase.h"
|
2021-11-24 04:26:29 -05:00
|
|
|
#include "StateTreeExecutionContext.h"
|
2022-09-19 19:47:11 -04:00
|
|
|
#include "BlueprintNodeHelpers.h"
|
2021-11-24 04:26:29 -05:00
|
|
|
|
2022-09-28 01:06:15 -04:00
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeConditionBlueprintBase)
|
|
|
|
|
|
2021-11-24 04:26:29 -05:00
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// UStateTreeConditionBlueprintBase
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
|
2022-09-19 19:47:11 -04:00
|
|
|
UStateTreeConditionBlueprintBase::UStateTreeConditionBlueprintBase(const FObjectInitializer& ObjectInitializer)
|
|
|
|
|
: Super(ObjectInitializer)
|
|
|
|
|
{
|
|
|
|
|
bHasTestCondition = BlueprintNodeHelpers::HasBlueprintFunction(TEXT("ReceiveTestCondition"), *this, *StaticClass());
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 04:04:58 -04:00
|
|
|
bool UStateTreeConditionBlueprintBase::TestCondition(FStateTreeExecutionContext& Context) const
|
2021-11-24 04:26:29 -05:00
|
|
|
{
|
2022-09-19 19:47:11 -04:00
|
|
|
if (bHasTestCondition)
|
|
|
|
|
{
|
2022-12-05 09:16:37 -05:00
|
|
|
// Cache the owner and event queue for the duration the condition is evaluated.
|
2023-01-23 12:48:04 -05:00
|
|
|
SetCachedInstanceDataFromContext(Context);
|
2022-12-05 09:16:37 -05:00
|
|
|
|
|
|
|
|
const bool bResult = ReceiveTestCondition();
|
|
|
|
|
|
2023-01-23 12:48:04 -05:00
|
|
|
ClearCachedInstanceData();
|
2022-12-05 09:16:37 -05:00
|
|
|
|
|
|
|
|
return bResult;
|
2022-09-19 19:47:11 -04:00
|
|
|
}
|
|
|
|
|
return false;
|
2021-11-24 04:26:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// FStateTreeBlueprintConditionWrapper
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
bool FStateTreeBlueprintConditionWrapper::TestCondition(FStateTreeExecutionContext& Context) const
|
|
|
|
|
{
|
2022-09-19 19:47:11 -04:00
|
|
|
UStateTreeConditionBlueprintBase* Condition = Context.GetInstanceDataPtr<UStateTreeConditionBlueprintBase>(*this);
|
|
|
|
|
check(Condition);
|
|
|
|
|
return Condition->TestCondition(Context);
|
2021-11-24 04:26:29 -05:00
|
|
|
}
|
2021-12-01 03:42:52 -05:00
|
|
|
|
2022-09-28 01:06:15 -04:00
|
|
|
|