| 215 | } |
| 216 | |
| 217 | UFlowAsset* 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 | |
| 248 | void UFlowSubsystem::AddInstancedTemplate(UFlowAsset* Template) |
| 249 | { |
nothing calls this directly
no test coverage detected