Fixed prefab assets
This commit is contained in:
		@@ -13,7 +13,8 @@
 | 
				
			|||||||
  "components": {
 | 
					  "components": {
 | 
				
			||||||
    "mat": {
 | 
					    "mat": {
 | 
				
			||||||
      "type": "SimpleTexturedMaterial",
 | 
					      "type": "SimpleTexturedMaterial",
 | 
				
			||||||
      "color": "blue"
 | 
					      "color": "blue",
 | 
				
			||||||
 | 
					      "texture": "rosa"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    "renderer": {
 | 
					    "renderer": {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user