Files
UnrealEngineUWP/Engine/Plugins/Runtime/GameplayStateTree/Source/GameplayStateTreeModule/Private/Components/StateTreeComponentSchema.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

57 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Components/StateTreeComponentSchema.h"
#include "StateTreeConditionBase.h"
#include "StateTreeEvaluatorBase.h"
#include "StateTreeTaskBase.h"
#include "GameFramework/Actor.h"
#include "Components/ActorComponent.h"
#include "Subsystems/WorldSubsystem.h"
UStateTreeComponentSchema::UStateTreeComponentSchema()
: ContextActorClass(AActor::StaticClass())
, ContextActorDataDesc(FName("Actor"), AActor::StaticClass(), FGuid(0x1D971B00, 0x28884FDE, 0xB5436802, 0x36984FD5))
{
}
bool UStateTreeComponentSchema::IsStructAllowed(const UScriptStruct* InScriptStruct) const
{
return InScriptStruct->IsChildOf(FStateTreeConditionCommonBase::StaticStruct())
|| InScriptStruct->IsChildOf(FStateTreeEvaluatorCommonBase::StaticStruct())
|| InScriptStruct->IsChildOf(FStateTreeTaskCommonBase::StaticStruct());
}
bool UStateTreeComponentSchema::IsClassAllowed(const UClass* InClass) const
{
return IsChildOfBlueprintBase(InClass);
}
bool UStateTreeComponentSchema::IsExternalItemAllowed(const UStruct& InStruct) const
{
return InStruct.IsChildOf(AActor::StaticClass())
|| InStruct.IsChildOf(UActorComponent::StaticClass())
|| InStruct.IsChildOf(UWorldSubsystem::StaticClass());
}
TConstArrayView<FStateTreeExternalDataDesc> UStateTreeComponentSchema::GetNamedExternalDataDescs() const
{
return MakeArrayView(&ContextActorDataDesc, 1);
}
void UStateTreeComponentSchema::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent)
{
Super::PostEditChangeChainProperty(PropertyChangedEvent);
FProperty* Property = PropertyChangedEvent.Property;
if (Property)
{
if (Property->GetOwnerClass() == UStateTreeComponentSchema::StaticClass()
&& Property->GetFName() == GET_MEMBER_NAME_CHECKED(UStateTreeComponentSchema, ContextActorClass))
{
ContextActorDataDesc.Struct = ContextActorClass.Get();
}
}
}