MCPcopy Create free account
hub / github.com/MothCocoon/FlowGraph / CreateFlowInstance

Method CreateFlowInstance

Source/Flow/Private/FlowSubsystem.cpp:217–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217UFlowAsset* UFlowSubsystem::CreateFlowInstance(const TWeakObjectPtr<UObject> Owner, UFlowAsset* LoadedFlowAsset, FString NewInstanceName)
218{
219 if (LoadedFlowAsset == nullptr)
220 {
221 return nullptr;
222 }
223
224 AddInstancedTemplate(LoadedFlowAsset);
225
226#if WITH_EDITOR
227 if (GetWorld()->WorldType != EWorldType::Game)
228 {
229 // Fix connections - even in packaged game if assets haven't been re-saved in the editor after changing node's definition
230 LoadedFlowAsset->HarvestNodeConnections();
231 }
232#endif
233
234 // it won't be empty, if we're restoring Flow Asset instance from the SaveGame
235 if (NewInstanceName.IsEmpty())
236 {
237 NewInstanceName = MakeUniqueObjectName(this, UFlowAsset::StaticClass(), *FPaths::GetBaseFilename(LoadedFlowAsset->GetPathName())).ToString();
238 }
239
240 UFlowAsset* NewInstance = NewObject<UFlowAsset>(this, LoadedFlowAsset->GetClass(), *NewInstanceName, RF_Transient, LoadedFlowAsset, false, nullptr);
241 NewInstance->InitializeInstance(Owner, *LoadedFlowAsset);
242
243 LoadedFlowAsset->AddInstance(NewInstance);
244
245 return NewInstance;
246}
247
248void UFlowSubsystem::AddInstancedTemplate(UFlowAsset* Template)
249{

Callers

nothing calls this directly

Calls 5

IsEmptyMethod · 0.80
ToStringMethod · 0.80
AddInstanceMethod · 0.80
InitializeInstanceMethod · 0.45

Tested by

no test coverage detected