MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / loadModuleAutoLoadAssets

Method loadModuleAutoLoadAssets

Engine/source/assets/assetManager.cpp:223–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bool AssetManager::loadModuleAutoLoadAssets(ModuleDefinition* pModuleDefinition)
224{
225 // Debug Profiling.
226 PROFILE_SCOPE(AssetManager_loadModuleAutoLoadAssets);
227
228 // Sanity!
229 AssertFatal(pModuleDefinition != NULL, "Cannot auto load assets using a NULL module definition");
230
231 // Does the module have any assets associated with it?
232 if (pModuleDefinition->getModuleAssets().empty() && mEchoInfo)
233 {
234 // Yes, so warn.
235 Con::warnf("Asset Manager: Cannot auto load assets to module '%s' as it has no existing assets.", pModuleDefinition->getSignature());
236 return false;
237 }
238
239 U32 assetCount = pModuleDefinition->getModuleAssets().size();
240
241 // Iterate the module definition children.
242 for (SimSet::iterator itr = pModuleDefinition->begin(); itr != pModuleDefinition->end(); ++itr)
243 {
244 // Fetch the declared assets.
245 AutoloadAssets* pAutoloadAssets = dynamic_cast<AutoloadAssets*>(*itr);
246
247 // Skip if it's not a declared assets location.
248 if (pAutoloadAssets == NULL)
249 continue;
250
251 for (U32 i = 0; i < assetCount; ++i)
252 {
253 AssetDefinition* assetDef = pModuleDefinition->getModuleAssets()[i];
254
255 if (assetDef->mAssetType == pAutoloadAssets->getAssetType())
256 {
257 String assetPath = assetDef->mAssetBaseFilePath;
258 assetPath.replace("//", "/");
259
260 String autoLoadPath = pModuleDefinition->getModulePath();
261 autoLoadPath += "/";
262 autoLoadPath += pAutoloadAssets->getPath();
263
264 if (pAutoloadAssets->getPath() == StringTable->EmptyString() || assetPath.startsWith(autoLoadPath.c_str()))
265 {
266 AssetBase* assetBase = dynamic_cast<AssetBase*>(mTaml.read(assetDef->mAssetBaseFilePath));
267
268 //load the asset now if valid
269 if (assetBase)
270 {
271 assetBase->setOwned(this, assetDef);
272 }
273 }
274 }
275 }
276 }
277
278 return true;
279}
280//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 15

replaceMethod · 0.80
getModulePathMethod · 0.80
EmptyStringMethod · 0.80
startsWithMethod · 0.80
setOwnedMethod · 0.80
warnfFunction · 0.50
emptyMethod · 0.45
getSignatureMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getAssetTypeMethod · 0.45

Tested by

no test coverage detected