All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.harium.etyl.loader.Assets Maven / Gradle / Ivy

The newest version!
package com.harium.etyl.loader;

import com.badlogic.gdx.assets.AssetManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.harium.etyl.loader.async.AsyncResource;

public class Assets extends AssetManager {

    Map> resources = new HashMap<>();

    public void addResource(String path, AsyncResource resource) {
        List list = resources.get(path);

        if (list == null) {
            list = new ArrayList<>();
            resources.put(path, list);
        }

        list.add(resource);
    }

    public void checkResources() {
        for (Map.Entry> entry : resources.entrySet()) {
            String path = entry.getKey();
            // Check if asset is in the queue to be loaded
            if (isLoaded(path)) {
                for (AsyncResource resource : entry.getValue()) {
                    resource.onLoad(get(path, resource.resourceClass()));
                }
                //Stop checking loaded resources
                entry.getValue().clear();
            }
        }
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy