private void loadAllAssets() {
    logger.debug("Loading All Assets");

    loadEntities();
    loadWeapons();
    for (String s : manifest.images) {
      logger.debug("Image: " + s);
      assetManager.load(s, Texture.class);
    }
    for (String s : manifest.textures) {
      assetManager.load(s, TextureAtlas.class);
    }
    for (String s : manifest.particles) {
      assetManager.load(s, ParticleEffect.class);
    }

    logger.debug("AssetManager begin loading...");
    try {
      while (assetManager.update() == false) {
        drawProgress();
        // logger.debug("  " + (int)(assetManager.getProgress()*100) + "% complete");
      }
    } catch (Exception e) {
      logger.error("Some assets failed to load: " + e.getMessage());
    }
  }
 public InputStream getInputStream() {
   try {
     // if (logger.isInfoEnabled())
     if (logger.getLevel() >= Logger.INFO) logger.info("loading stream " + getResourceName());
     return new FileInputStream(new File(path));
   } catch (FileNotFoundException e) {
     throw new RuntimeException("File for " + resourceName + " not found", e);
   }
 }
 private void loadAllAssetsInPath(String folder, Class type, String suffix) {
   logger.debug("Loading '" + folder + "'");
   for (FileHandle f : getAssetsPath(folder).list()) {
     String msg = "  Found: " + f.name();
     if (suffix == null) {
       assetManager.load(folder + "/" + f.name(), type);
     } else if (f.name().toLowerCase().endsWith(suffix))
       assetManager.load(folder + "/" + f.name(), type);
     else msg += " ...ignoring";
     logger.debug(msg);
   }
 }
 private void loadWeapons() {
   logger.debug("Loading Weapons");
   Json json = new Json();
   for (String s : manifest.weapons) {
     try {
       WeaponConfig config = json.fromJson(WeaponConfig.class, Gdx.files.internal(s));
       weaponConfigs.put(config.name, config);
     } catch (SerializationException ex) {
       logger.error("Failed to load weapons file: " + s);
       logger.error(ex.getMessage());
     }
   }
 }
  private void loadEntities() {
    logger.debug("Loading Entities");

    Json json = new Json();
    for (String s : manifest.entities) {
      try {
        EntityConfig config = json.fromJson(EntityConfig.class, Gdx.files.internal(s));
        entityConfigs.put(config.name, config);
      } catch (SerializationException ex) {
        logger.error("Failed to load entity file: " + s);
        logger.error(ex.getMessage());
      }
    }
  }
 public EntityConfig getEntityConfig(String name) {
   if (entityConfigs.containsKey(name)) return entityConfigs.get(name);
   else if (entityConfigs.containsKey("entities/" + name))
     return entityConfigs.get("entities/" + name);
   logger.error("Entity config not found: " + name);
   return null;
 }
 // Create everything from a SceneModel. (SceneModels are easily serialized)
 private void buildFromModel(PhysicsSceneModel physicsModel) {
   logger.debug("Build from physics scene model");
   scene.createFromModel(physicsModel);
   for (Body b : scene.getBodies()) {
     b.setUserData(this);
   }
 }
 // Json read
 @Override
 public void read(Json json, JsonValue jsonData) {
   logger.debug("Deserializing");
   PhysicsConfig config = json.fromJson(PhysicsConfig.class, jsonData.toString());
   collisionEffect = config.collisionEffect;
   this.buildFromModel(config.sceneModel);
 }
 // Json Write
 @Override
 public void write(Json json) {
   logger.debug("Serializing..");
   PhysicsConfig config = new PhysicsConfig();
   config.collisionEffect = collisionEffect;
   config.sceneModel = scene.toSceneModel();
   json.writeFields(config);
 }
  public WeaponConfig getWeaponConfig(String name) {
    if (weaponConfigs.containsKey(name)) return weaponConfigs.get(name);
    else if (weaponConfigs.containsKey("weapons/" + name))
      return weaponConfigs.get("weapons/" + name);

    logger.error("Weapon config not found: " + name);
    return null;
  }
 public Texture getTexture(String name) {
   Texture tex = null;
   String[] possibles = {name, "data/" + name, "data/images/" + name, "data/textures/" + name};
   for (String s : possibles) {
     if (assetManager.isLoaded(s)) tex = assetManager.get(s);
   }
   if (tex == null) logger.error("Texture not found: " + name);
   return tex;
 }
 public ParticleEffect getEffect(String name) {
   ParticleEffect eff = null;
   String[] possibles = {
     name, "data/" + name, "data/particles/" + name,
   };
   for (String s : possibles) {
     if (assetManager.isLoaded(s)) eff = assetManager.get(s);
   }
   if (eff == null) logger.error("ParticleEffect not found: " + name);
   return eff;
 }
 public Assets() {
   logger.debug("Initializing");
   loadManifest();
   loadAllAssets();
 }
 // Destroy specific fixture
 public void destroyFixture(String name) {
   logger.debug("Destroy fixture: " + name);
   scene.destroyFixture(name);
 }
 // Destroy specific body
 public void destroyBody(String name) {
   logger.debug("Destroy body: " + name);
   scene.destroyBody(name);
 }
 public String addJoint(JointModel jm) {
   logger.debug("Add joint model");
   logger.error("addJoint(JointModel jm) may not function correctly");
   scene.createJoint(jm);
   return jm.name;
 }
 // Create and add body using a BodyModel. A unique name is automatically generated and returned
 public String addBody(BodyModel bm) {
   logger.debug("Add body model");
   Body b = scene.createBody(bm);
   b.setUserData(this);
   return bm.name;
 }
 // Add Existing body
 public String addBody(Body b) {
   logger.debug("Add body");
   b.setUserData(this);
   return scene.addBody(b);
 }
 // Destroy everything
 public void destroy() {
   logger.debug("Destroy Everything");
   scene.destroy();
   collisionNormal = 0;
 }
 // Destroy Joint
 public void destroyJoint(String name) {
   logger.debug("Destroy Joint: " + name);
   scene.destroyJoint(name);
 }