-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathFlowNodeAddOn.cpp
More file actions
172 lines (138 loc) · 3.27 KB
/
FlowNodeAddOn.cpp
File metadata and controls
172 lines (138 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Copyright https://github.com/MothCocoon/FlowGraph/graphs/contributors
#include "AddOns/FlowNodeAddOn.h"
#include "FlowLogChannels.h"
#include "Nodes/FlowNode.h"
#include "Misc/RuntimeErrors.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(FlowNodeAddOn)
UFlowNodeAddOn::UFlowNodeAddOn()
{
#if WITH_EDITOR
NodeDisplayStyle = FlowNodeStyle::AddOn;
#endif
}
void UFlowNodeAddOn::InitializeInstance()
{
CacheFlowNode();
Super::InitializeInstance();
}
void UFlowNodeAddOn::DeinitializeInstance()
{
Super::DeinitializeInstance();
FlowNode = nullptr;
}
void UFlowNodeAddOn::TriggerFirstOutput(const bool bFinish)
{
if (ensure(FlowNode))
{
FlowNode->TriggerFirstOutput(bFinish);
}
}
void UFlowNodeAddOn::TriggerOutput(const FName PinName, const bool bFinish, const EFlowPinActivationType ActivationType)
{
if (ensure(FlowNode))
{
FlowNode->TriggerOutput(PinName, bFinish, ActivationType);
}
}
void UFlowNodeAddOn::Finish()
{
if (ensure(FlowNode))
{
FlowNode->Finish();
}
}
EFlowAddOnAcceptResult UFlowNodeAddOn::AcceptFlowNodeAddOnParent_Implementation(
const UFlowNodeBase* ParentTemplate,
const TArray<UFlowNodeAddOn*>& AdditionalAddOnsToAssumeAreChildren) const
{
// Subclasses may override this function to opt in to parent classes
return EFlowAddOnAcceptResult::Undetermined;
}
void UFlowNodeAddOn::NotifyPreloadComplete()
{
if (ensure(FlowNode))
{
FlowNode->NotifyPreloadComplete();
}
}
UFlowNode* UFlowNodeAddOn::GetFlowNode() const
{
// We are making the assumption that this would always be known during runtime
// and that we are not calling this method before the addon has been initialized.
ensure(FlowNode);
return FlowNode;
}
UFlowNode* UFlowNodeAddOn::FindOwningFlowNode() const
{
UObject* OuterObject = GetOuter();
UFlowNode* ParentFlowNode = nullptr;
while (IsValid(OuterObject))
{
ParentFlowNode = Cast<UFlowNode>(OuterObject);
if (ParentFlowNode)
{
break;
}
OuterObject = OuterObject->GetOuter();
}
return ParentFlowNode;
}
int32 UFlowNodeAddOn::GetRandomSeed() const
{
if (ensure(FlowNode))
{
return FlowNode->GetRandomSeed();
}
return 0;
}
bool UFlowNodeAddOn::IsSupportedInputPinName(const FName& PinName) const
{
if (InputPins.IsEmpty())
{
return true;
}
if (const FFlowPin* FoundFlowPin = FindFlowPinByName(PinName, InputPins))
{
return true;
}
else
{
return false;
}
}
void UFlowNodeAddOn::CacheFlowNode()
{
FlowNode = FindOwningFlowNode();
ensureAsRuntimeWarning(FlowNode);
}
#if WITH_EDITOR
TArray<FFlowPin> UFlowNodeAddOn::GetPinsForContext(const TArray<FFlowPin>& Context) const
{
TArray<FFlowPin> ContextPins = Super::GetContextInputs();
ContextPins.Reserve(ContextPins.Num() + Context.Num());
for (const FFlowPin& InputPin : Context)
{
if (InputPin.IsValid())
{
ContextPins.Add(InputPin);
}
else
{
UE_LOG(LogFlow, Warning, TEXT("Addon %s has invalid pins (name: None), you should clean these up."), *GetName());
}
}
return ContextPins;
}
TArray<FFlowPin> UFlowNodeAddOn::GetContextInputs() const
{
return GetPinsForContext(InputPins);
}
TArray<FFlowPin> UFlowNodeAddOn::GetContextOutputs() const
{
return GetPinsForContext(OutputPins);
}
void UFlowNodeAddOn::RequestReconstructionOnOwningFlowNode() const
{
(void)OnAddOnRequestedParentReconstruction.ExecuteIfBound();
}
#endif // WITH_EDITOR