Fixed prefab assets
This commit is contained in:
		@@ -13,7 +13,8 @@
 | 
			
		||||
  "components": {
 | 
			
		||||
    "mat": {
 | 
			
		||||
      "type": "SimpleTexturedMaterial",
 | 
			
		||||
      "color": "blue"
 | 
			
		||||
      "color": "blue",
 | 
			
		||||
      "texture": "rosa"
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    "renderer": {
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ void PrefabLoader::updateSync() {
 | 
			
		||||
      assertNotNull(this->jsonLoader, "JSON Loader is NULL?");
 | 
			
		||||
      if(!this->jsonLoader->loaded) return;
 | 
			
		||||
      this->state = PrefabLoaderState::LOADING_DEPENDENCIES;
 | 
			
		||||
      this->setupDependencies();
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case PrefabLoaderState::LOADING_DEPENDENCIES:
 | 
			
		||||
@@ -46,8 +47,6 @@ void PrefabLoader::updateSync() {
 | 
			
		||||
 | 
			
		||||
      this->state = PrefabLoaderState::DEPENDENCIES_LOADED;
 | 
			
		||||
      this->loaded = true;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
 
 | 
			
		||||
@@ -41,13 +41,10 @@ void IGame::init() {
 | 
			
		||||
  this->initManagers();
 | 
			
		||||
 | 
			
		||||
  // TEST
 | 
			
		||||
  auto scene = this->assetManager->get<SceneLoader>("test_scene.json");
 | 
			
		||||
  auto scene = this->assetManager->get<SceneLoader>(this->getInitialScene());
 | 
			
		||||
  while(!this->assetManager->isEverythingLoaded()) {
 | 
			
		||||
    this->assetManager->update();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // auto initialScene = this->getInitialScene();
 | 
			
		||||
  // nextFrameScene = std::make_shared<Scene>(selfAsGame, initialScene);
 | 
			
		||||
  nextFrameScene = scene->getScene();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ namespace Dawn {
 | 
			
		||||
       * 
 | 
			
		||||
       * @return The initial scene.
 | 
			
		||||
       */
 | 
			
		||||
      // virtual std::function<void(Scene&)> getInitialScene() = 0;
 | 
			
		||||
      virtual std::string getInitialScene() = 0;
 | 
			
		||||
      
 | 
			
		||||
      /**
 | 
			
		||||
       * Initializes the game managers.
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ namespace Dawn {
 | 
			
		||||
    template<class T>
 | 
			
		||||
    std::shared_ptr<T> getAsset(const std::string &j) const {
 | 
			
		||||
      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);
 | 
			
		||||
      assertNotNull(asset, "Asset is not of the correct type.");
 | 
			
		||||
      return asset;
 | 
			
		||||
 
 | 
			
		||||
@@ -12,9 +12,9 @@ Game::Game() : IGame() {
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// std::function<void(Scene&)> Game::getInitialScene() {
 | 
			
		||||
//   return rpgScene;
 | 
			
		||||
// }
 | 
			
		||||
std::string Game::getInitialScene() {
 | 
			
		||||
  return "test_scene.json";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Game::initManagers() {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
namespace Dawn {
 | 
			
		||||
  class Game : public IGame {
 | 
			
		||||
    protected:
 | 
			
		||||
      // std::function<void(Scene&)> getInitialScene() override;
 | 
			
		||||
      std::string getInitialScene() override;
 | 
			
		||||
      void initManagers() override;
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user