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"
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "StateTreeExecutionContext.h"
|
2022-09-19 19:47:11 -04:00
|
|
|
#include "BlueprintNodeHelpers.h"
|
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)
|
|
|
|
|
{
|
|
|
|
|
FScopedCurrentContext(*this, Context);
|
|
|
|
|
return ReceiveTestCondition();
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|