Skip to content
Snippets Groups Projects
Commit 22e55153 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

allow the entity factory to provided at calltime

parent 53e0b2f4
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ namespace demo {
// asset loader
auto* assetLoader = m_owner.service<fggl::assets::Loader>();
assetLoader->load("rollball.yml", fggl::entity::PROTOTYPE_ASSET);
assetLoader->load("rollball.yml", fggl::entity::PROTOTYPE_ASSET, entFactory);
assetLoader->load("rollball.yml", fggl::entity::SCENE, this);
// collectable callbacks
......
......@@ -77,7 +77,7 @@ namespace fggl::entity {
return nullptr;
}
assets::AssetRefRaw load_prototype(assets::Loader* loader, EntityFactory *factory, const assets::AssetGUID &guid, assets::AssetData data) {
assets::AssetRefRaw load_prototype(assets::Loader* loader, const assets::AssetGUID &guid, assets::AssetData data, EntityFactory* factory) {
auto *filePath = std::get<assets::AssetPath *>(data);
// We need to process the prototypes, and load them into the asset system.
......
......@@ -45,7 +45,11 @@ namespace fggl::entity {
// we are responsible for prefabs...
auto *assetLoader = services.get<assets::Loader>();
assetLoader->setFactory(PROTOTYPE_ASSET, [factory](assets::Loader* loader, const assets::AssetGUID &a, assets::AssetData b, void* ptr) {
return load_prototype(loader, factory, a, b);
EntityFactory* facPtr = factory;
if ( ptr != nullptr ) {
facPtr = (EntityFactory*)ptr;
}
return load_prototype(loader, a, b, facPtr);
}, assets::LoadType::PATH);
assetLoader->setFactory(SCENE, load_scene, assets::LoadType::PATH);
......
......@@ -173,7 +173,7 @@ namespace fggl::entity {
}
};
assets::AssetRefRaw load_prototype(assets::Loader* loader, EntityFactory *factory, const assets::AssetGUID &guid, assets::AssetData data);
assets::AssetRefRaw load_prototype(assets::Loader* loader, const assets::AssetGUID &guid, assets::AssetData data, EntityFactory* factory);
assets::AssetRefRaw load_scene(assets::Loader* loader, const assets::AssetGUID& asset, assets::AssetData data, void* ptr);
} // namespace fggl::entity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment