MCPcopy Create free account
hub / github.com/defold/defold / CompFactoryLoad

Function CompFactoryLoad

engine/gamesys/src/gamesys/components/comp_factory.cpp:298–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296 }
297
298 bool CompFactoryLoad(HFactoryWorld world, HFactoryComponent component, int callback_ref, int self_ref, int url_ref)
299 {
300 component->m_PreloaderCallbackRef = callback_ref;
301 component->m_PreloaderSelfRef = self_ref;
302 component->m_PreloaderURLRef = url_ref;
303
304 FactoryResource* resource = CompFactoryGetResource(world, component);
305 if(!resource->m_LoadDynamically)
306 {
307 // set as loading without preloader so complete callback is invoked as should be by design.
308 component->m_Loading = 1;
309 return true;
310 }
311 if(component->m_Loading)
312 {
313 dmLogError("Trying to load factory prototype resource when already loading.");
314 ResetCallbacks(component);
315 return false;
316 }
317 if(resource->m_Prototype)
318 {
319 // If loaded, complete callback is invoked.
320 component->m_Loading = 1;
321 return true;
322 }
323
324 component->m_Preloader = dmResource::NewPreloader(world->m_Factory, resource->m_PrototypePath);
325 if(!component->m_Preloader)
326 {
327 ResetCallbacks(component);
328 return false;
329 }
330 component->m_Loading = 1;
331 return true;
332 }
333
334 bool CompFactoryUnload(HFactoryWorld world, HFactoryComponent component)
335 {

Callers 1

FactoryComp_LoadFunction · 0.85

Calls 3

CompFactoryGetResourceFunction · 0.85
ResetCallbacksFunction · 0.85
NewPreloaderFunction · 0.85

Tested by

no test coverage detected