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

Method GenerateParamsFromStartNode

Source/Flow/Private/FlowAsset.cpp:164–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164UFlowAssetParams* UFlowAsset::GenerateParamsFromStartNode()
165{
166 if (BaseAssetParams.AssetPtr.IsValid())
167 {
168 UE_LOG(LogFlow, Warning, TEXT("BaseAssetParams already exists for %s: %s"), *GetPathName(), *BaseAssetParams.AssetPtr.ToString());
169 return BaseAssetParams.AssetPtr.LoadSynchronous();
170 }
171
172 // Get the Start node
173 IFlowNamedPropertiesSupplierInterface* NamedPropertiesSupplier = Cast<IFlowNamedPropertiesSupplierInterface>(GetDefaultEntryNode());
174 if (!NamedPropertiesSupplier)
175 {
176 UE_LOG(LogFlow, Error, TEXT("No valid Start node found for generating params in %s"), *GetPathName());
177 return nullptr;
178 }
179
180 // Determine the params asset name
181 const FString ParamsAssetName = GenerateParamsAssetName();
182 if (ParamsAssetName.IsEmpty())
183 {
184 UE_LOG(LogFlow, Error, TEXT("Generated empty params asset name for %s"), *GetPathName());
185 return nullptr;
186 }
187
188 // Create the params asset
189 FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
190 const FString PackagePath = FPackageName::GetLongPackagePath(GetPackage()->GetPathName());
191 FString UniquePackageName, UniqueAssetName;
192 AssetToolsModule.Get().CreateUniqueAssetName(PackagePath + TEXT("/") + ParamsAssetName, TEXT(""), UniquePackageName, UniqueAssetName);
193
194 UFlowAssetParams* NewParams = Cast<UFlowAssetParams>(
195 AssetToolsModule.Get().CreateAsset(UniqueAssetName, PackagePath, UFlowAssetParams::StaticClass(), nullptr));
196 if (!IsValid(NewParams))
197 {
198 UE_LOG(LogFlow, Error, TEXT("Failed to create Flow Asset Params: %s"), *UniqueAssetName);
199 return nullptr;
200 }
201
202 // Reconfigure with the new properties
203 NewParams->ConfigureFlowAssetParams(this, nullptr, NamedPropertiesSupplier->GetMutableNamedProperties());
204
205 // Source control integration
206 if (USourceControlHelpers::IsAvailable())
207 {
208 const FString FileName = USourceControlHelpers::PackageFilename(NewParams->GetPathName());
209 if (!USourceControlHelpers::CheckOutOrAddFile(FileName))
210 {
211 UE_LOG(LogFlow, Warning, TEXT("Failed to check out/add %s; saved in-memory only"), *NewParams->GetPathName());
212 }
213 }
214
215 // Assign to BaseAssetParams and sync Content Browser
216 BaseAssetParams.AssetPtr = NewParams;
217
218 FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
219 AssetRegistryModule.Get().AssetCreated(NewParams);
220
221 FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");

Callers 1

HandleCreateNewMethod · 0.80

Calls 6

IsValidFunction · 0.85
IsValidMethod · 0.80
ToStringMethod · 0.80
IsEmptyMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected