| 161 | } |
| 162 | |
| 163 | UFlowAsset* UFlowSubsystem::CreateSubFlow(UFlowNode_SubGraph* SubGraphNode, const FString& SavedInstanceName, const bool bPreloading /* = false */) |
| 164 | { |
| 165 | UFlowAsset* NewInstance = nullptr; |
| 166 | |
| 167 | if (!InstancedSubFlows.Contains(SubGraphNode)) |
| 168 | { |
| 169 | const TWeakObjectPtr<UObject> Owner = SubGraphNode->GetFlowAsset() ? SubGraphNode->GetFlowAsset()->GetOwner() : nullptr; |
| 170 | NewInstance = CreateFlowInstance(Owner, SubGraphNode->Asset.LoadSynchronous(), SavedInstanceName); |
| 171 | |
| 172 | if (NewInstance) |
| 173 | { |
| 174 | InstancedSubFlows.Add(SubGraphNode, NewInstance); |
| 175 | |
| 176 | if (bPreloading) |
| 177 | { |
| 178 | NewInstance->PreloadNodes(); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if (InstancedSubFlows.Contains(SubGraphNode) && !bPreloading) |
| 184 | { |
| 185 | // get instanced asset from map - in case it was already instanced by calling CreateSubFlow() with bPreloading == true |
| 186 | UFlowAsset* AssetInstance = InstancedSubFlows[SubGraphNode]; |
| 187 | |
| 188 | AssetInstance->NodeOwningThisAssetInstance = SubGraphNode; |
| 189 | SubGraphNode->GetFlowAsset()->ActiveSubGraphs.Add(SubGraphNode, AssetInstance); |
| 190 | |
| 191 | // don't activate Start Node if we're loading Sub Graph from SaveGame |
| 192 | if (SavedInstanceName.IsEmpty()) |
| 193 | { |
| 194 | AssetInstance->StartFlow(SubGraphNode); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | return NewInstance; |
| 199 | } |
| 200 | |
| 201 | void UFlowSubsystem::RemoveSubFlow(UFlowNode_SubGraph* SubGraphNode, const EFlowFinishPolicy FinishPolicy) |
| 202 | { |
no test coverage detected