Fixed prefab assets

This commit is contained in:
2024-12-02 20:10:44 -06:00
parent e660fade95
commit 7989be5fe7
7 changed files with 10 additions and 13 deletions

View File

@ -13,7 +13,8 @@
"components": { "components": {
"mat": { "mat": {
"type": "SimpleTexturedMaterial", "type": "SimpleTexturedMaterial",
"color": "blue" "color": "blue",
"texture": "rosa"
}, },
"renderer": { "renderer": {

View File

@ -34,6 +34,7 @@ void PrefabLoader::updateSync() {
assertNotNull(this->jsonLoader, "JSON Loader is NULL?"); assertNotNull(this->jsonLoader, "JSON Loader is NULL?");
if(!this->jsonLoader->loaded) return; if(!this->jsonLoader->loaded) return;
this->state = PrefabLoaderState::LOADING_DEPENDENCIES; this->state = PrefabLoaderState::LOADING_DEPENDENCIES;
this->setupDependencies();
break; break;
case PrefabLoaderState::LOADING_DEPENDENCIES: case PrefabLoaderState::LOADING_DEPENDENCIES:
@ -46,8 +47,6 @@ void PrefabLoader::updateSync() {
this->state = PrefabLoaderState::DEPENDENCIES_LOADED; this->state = PrefabLoaderState::DEPENDENCIES_LOADED;
this->loaded = true; this->loaded = true;
break; break;
default: default:

View File

@ -41,13 +41,10 @@ void IGame::init() {
this->initManagers(); this->initManagers();
// TEST // TEST
auto scene = this->assetManager->get<SceneLoader>("test_scene.json"); auto scene = this->assetManager->get<SceneLoader>(this->getInitialScene());
while(!this->assetManager->isEverythingLoaded()) { while(!this->assetManager->isEverythingLoaded()) {
this->assetManager->update(); this->assetManager->update();
} }
// auto initialScene = this->getInitialScene();
// nextFrameScene = std::make_shared<Scene>(selfAsGame, initialScene);
nextFrameScene = scene->getScene(); nextFrameScene = scene->getScene();
} }

View File

@ -36,7 +36,7 @@ namespace Dawn {
* *
* @return The initial scene. * @return The initial scene.
*/ */
// virtual std::function<void(Scene&)> getInitialScene() = 0; virtual std::string getInitialScene() = 0;
/** /**
* Initializes the game managers. * Initializes the game managers.

View File

@ -30,7 +30,7 @@ namespace Dawn {
template<class T> template<class T>
std::shared_ptr<T> getAsset(const std::string &j) const { std::shared_ptr<T> getAsset(const std::string &j) const {
auto it = assets.find(j); auto it = assets.find(j);
assertTrue(it != assets.end(), "Asset not found."); assertTrue(it != assets.end(), "Asset %s not found.", j.c_str());
auto asset = std::dynamic_pointer_cast<T>(it->second); auto asset = std::dynamic_pointer_cast<T>(it->second);
assertNotNull(asset, "Asset is not of the correct type."); assertNotNull(asset, "Asset is not of the correct type.");
return asset; return asset;

View File

@ -12,9 +12,9 @@ Game::Game() : IGame() {
} }
// std::function<void(Scene&)> Game::getInitialScene() { std::string Game::getInitialScene() {
// return rpgScene; return "test_scene.json";
// } }
void Game::initManagers() { void Game::initManagers() {

View File

@ -9,7 +9,7 @@
namespace Dawn { namespace Dawn {
class Game : public IGame { class Game : public IGame {
protected: protected:
// std::function<void(Scene&)> getInitialScene() override; std::string getInitialScene() override;
void initManagers() override; void initManagers() override;
public: public: