UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BTDecorator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
6#include "BTDecorator.generated.h"
7
8class FBehaviorDecoratorDetails;
9
11{
12 // request execution update when only result of condition changes and active branch of tree can potentially change too
14
15 // request execution update every time as long as condition is still passing
17};
18
36UCLASS(Abstract, MinimalAPI)
38{
40
41
42 AIMODULE_API bool WrappedCanExecute(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const;
43
45 AIMODULE_API void WrappedOnNodeActivation(FBehaviorTreeSearchData& SearchData) const;
46
48 AIMODULE_API void WrappedOnNodeDeactivation(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type NodeResult) const;
49
51 AIMODULE_API void WrappedOnNodeProcessed(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type& NodeResult) const;
52
54 EBTFlowAbortMode::Type GetFlowAbortMode() const;
55
57 bool IsInversed() const;
58
59 AIMODULE_API virtual FString GetStaticDescription() const override;
60
62 AIMODULE_API void UpdateFlowAbortMode();
63
65 AIMODULE_API bool IsFlowAbortModeValid() const;
66
67protected:
68
71
74
77
80
83
86
89
90private:
92 UPROPERTY(Category = Condition, EditAnywhere)
93 uint32 bInverseCondition : 1;
94
95protected:
97 UPROPERTY(Category=FlowControl, EditAnywhere)
98 TEnumAsByte<EBTFlowAbortMode::Type> FlowAbortMode;
99
100 AIMODULE_API void SetIsInversed(bool bShouldBeInversed);
101
106 AIMODULE_API virtual void OnNodeActivation(FBehaviorTreeSearchData& SearchData);
107
112 AIMODULE_API virtual void OnNodeDeactivation(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type NodeResult);
113
118 AIMODULE_API virtual void OnNodeProcessed(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type& NodeResult);
119
121 AIMODULE_API virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const;
122
125 AIMODULE_API void ConditionalFlowAbort(UBehaviorTreeComponent& OwnerComp, EBTDecoratorAbortRequest RequestMode) const;
126
127 friend FBehaviorDecoratorDetails;
128
129 template<typename TickNode, typename OnBecomeRelevant, typename OnCeaseRelevant,
130 typename OnNodeActivation, typename OnNodeDeactivation, typename OnNodeProcessed>
131 void InitNotifyFlags(TickNode, OnBecomeRelevant, OnCeaseRelevant,
132 OnNodeActivation, OnNodeDeactivation, OnNodeProcessed)
133 {
134 bNotifyTick = !std::is_same_v<decltype(&UBTDecorator::TickNode), TickNode>;
135 bNotifyBecomeRelevant = !std::is_same_v<decltype(&UBTDecorator::OnBecomeRelevant), OnBecomeRelevant>;
136 bNotifyCeaseRelevant = !std::is_same_v<decltype(&UBTDecorator::OnCeaseRelevant), OnCeaseRelevant>;
137 bNotifyActivation = !std::is_same_v<decltype(&UBTDecorator::OnNodeActivation), OnNodeActivation>;
138 bNotifyDeactivation = !std::is_same_v<decltype(&UBTDecorator::OnNodeDeactivation), OnNodeDeactivation>;
139 bNotifyProcessed = !std::is_same_v<decltype(&UBTDecorator::OnNodeProcessed), OnNodeProcessed>;
140 }
141};
142
143#define INIT_DECORATOR_NODE_NOTIFY_FLAGS() \
144 do { \
145 using NodeType = TRemovePointer<decltype(this)>::Type; \
146 InitNotifyFlags(&NodeType::TickNode, \
147 &NodeType::OnBecomeRelevant, \
148 &NodeType::OnCeaseRelevant, \
149 &NodeType::OnNodeActivation, \
150 &NodeType::OnNodeDeactivation, \
151 &NodeType::OnNodeProcessed); \
152 } while (false)
153
155// Inlines
156
157inline EBTFlowAbortMode::Type UBTDecorator::GetFlowAbortMode() const
158{
159 return FlowAbortMode;
160}
161
162inline bool UBTDecorator::IsInversed() const
163{
164 return bInverseCondition;
165}
EBTDecoratorAbortRequest
Definition BTDecorator.h:11
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition EnumAsByte.h:22
Definition BTAuxiliaryNode.h:31
virtual AIMODULE_API void TickNode(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds)
Definition BTAuxiliaryNode.cpp:136
virtual AIMODULE_API void OnCeaseRelevant(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory)
Definition BTAuxiliaryNode.cpp:131
virtual AIMODULE_API void OnBecomeRelevant(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory)
Definition BTAuxiliaryNode.cpp:126
Definition BTDecorator.h:38
uint32 bAllowAbortLowerPri
Definition BTDecorator.h:73
uint32 bNotifyDeactivation
Definition BTDecorator.h:82
uint32 bShowInverseConditionDesc
Definition BTDecorator.h:88
uint32 bNotifyProcessed
Definition BTDecorator.h:85
uint32 bAllowAbortNone
Definition BTDecorator.h:70
virtual AIMODULE_API void OnNodeActivation(FBehaviorTreeSearchData &SearchData)
Definition BTDecorator.cpp:34
virtual AIMODULE_API void OnNodeDeactivation(FBehaviorTreeSearchData &SearchData, EBTNodeResult::Type NodeResult)
Definition BTDecorator.cpp:38
uint32 bNotifyActivation
Definition BTDecorator.h:79
TEnumAsByte< EBTFlowAbortMode::Type > FlowAbortMode
Definition BTDecorator.h:98
uint32 bAllowAbortChildNodes
Definition BTDecorator.h:76
virtual AIMODULE_API void OnNodeProcessed(FBehaviorTreeSearchData &SearchData, EBTNodeResult::Type &NodeResult)
Definition BTDecorator.cpp:42
Definition BehaviorTreeComponent.h:105
Definition BehaviorTreeTypes.h:143
Type
Definition BehaviorTreeTypes.h:147
Definition BehaviorTreeTypes.h:84
Type
Definition BehaviorTreeTypes.h:87
Definition BehaviorTreeTypes.h:534