2022-02-21 02:04:58 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2021-11-24 04:26:12 -05:00
2022-09-01 09:06:53 -04:00
# include "Blueprint/StateTreeNodeBlueprintBase.h"
2021-11-24 04:26:12 -05:00
# include "AIController.h"
# include "StateTreeExecutionContext.h"
2022-04-06 10:04:05 -04:00
# include "StateTreeLinker.h"
2022-09-01 09:06:53 -04:00
# include "VisualLogger/VisualLogger.h"
2021-11-24 04:26:12 -05:00
2022-09-01 09:06:53 -04:00
UWorld * UStateTreeNodeBlueprintBase : : GetWorld ( ) const
2021-11-24 04:26:12 -05:00
{
// The items are duplicated as the StateTreeExecution context as outer, so this should be essentially the same as GetWorld() on StateTree context.
// The CDO is used by the BP editor to check for certain functionality, make it return nullptr so that the GetWorld() passes as overridden.
if ( ! HasAnyFlags ( RF_ClassDefaultObject ) )
{
if ( UObject * Outer = GetOuter ( ) )
{
return Outer - > GetWorld ( ) ;
}
}
return nullptr ;
}
2022-09-01 09:06:53 -04:00
AActor * UStateTreeNodeBlueprintBase : : GetOwnerActor ( const FStateTreeExecutionContext & Context ) const
2021-11-24 04:26:12 -05:00
{
if ( const AAIController * Controller = Cast < AAIController > ( Context . GetOwner ( ) ) )
{
return Controller - > GetPawn ( ) ;
}
return Cast < AActor > ( Context . GetOwner ( ) ) ;
}
2022-09-01 09:06:53 -04:00
void UStateTreeNodeBlueprintBase : : SendEvent ( const FStateTreeEvent & Event )
{
if ( CurrentContext = = nullptr )
{
UE_VLOG_UELOG ( this , LogStateTree , Error , TEXT ( " Trying to call SendEvent() outside StateTree tick. Use SendEvent() on UStateTreeComponent instead for sending signals externally. " ) ) ;
return ;
}
CurrentContext - > SendEvent ( Event ) ;
}