Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Private/StateTreeReference.cpp
mikko mononen 0d1ace8323 StateTree: StateTreeComponent improvements
- Added option to start the StateTree automatically on BeginPlay
- StateTreeComponentSchema: allow to specify which actor class to expect the StateTree to run on (allows to bind to Actor specific data directly)
- Fixed FStateTreeReference parameter update on BP instance (the struct gets copied, which cause issues with the delegate handle)

#rb Mieszko.Zielinski
#preflight 630c70bb0345de4ccf7c8b51

[CL 21685020 by mikko mononen in ue5-main branch]
2022-08-29 14:47:43 -04:00

33 lines
988 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "StateTreeReference.h"
#include "StateTree.h"
void FStateTreeReference::SyncParametersToMatchStateTree(FInstancedPropertyBag& ParametersToSync) const
{
if (StateTree == nullptr)
{
ParametersToSync.Reset();
}
else
{
ParametersToSync.MigrateToNewBagInstance(StateTree->GetDefaultParameters());
}
}
bool FStateTreeReference::RequiresParametersSync() const
{
return (StateTree == nullptr && Parameters.IsValid())
|| (StateTree != nullptr && StateTree->GetDefaultParameters().GetPropertyBagStruct() != Parameters.GetPropertyBagStruct());
}
void FStateTreeReference::ConditionallySyncParameters() const
{
if (RequiresParametersSync())
{
FStateTreeReference* NonConstThis = const_cast<FStateTreeReference*>(this);
NonConstThis->SyncParameters();
UE_LOG(LogStateTree, Warning, TEXT("Parameters for '%s' stored in StateTreeReference were auto-fixed to be usable at runtime."), *GetNameSafe(StateTree));
}
}