Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Private/Blueprint/StateTreeNodeBlueprintBase.cpp
mikko mononen 0d47d49765 StateTree: Context Objects
- Cleaned up Blueprint nodes from deprecated functions
- Added call guards for BP implemented events on BP nodes
- Renamed Named External Data to Context (Object/Data)
- Added automatic binding for Context objects
- Added UI visualization for Context properties and cleaned up the Input/Ouput visualization
- Added compiler errors for missing Input and Context properties

#jira UE-156544 UE-147509
#rb Stephen.Holmes

[CL 22084585 by mikko mononen in ue5-main branch]
2022-09-19 19:47:11 -04:00

43 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Blueprint/StateTreeNodeBlueprintBase.h"
#include "AIController.h"
#include "StateTreeExecutionContext.h"
#include "StateTreeLinker.h"
#include "VisualLogger/VisualLogger.h"
UWorld* UStateTreeNodeBlueprintBase::GetWorld() const
{
// 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;
}
AActor* UStateTreeNodeBlueprintBase::GetOwnerActor(const FStateTreeExecutionContext& Context) const
{
if (const AAIController* Controller = Cast<AAIController>(Context.GetOwner()))
{
return Controller->GetPawn();
}
return Cast<AActor>(Context.GetOwner());
}
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);
}