Search in sources :

Example 6 with Asset

use of io.xol.chunkstories.api.content.Asset in project chunkstories by Hugobros3.

the class ConfigurationImplementation method reload.

public void reload() {
    options.clear();
    Iterator<Asset> i = content.modsManager().getAllAssetsByExtension("options");
    while (i.hasNext()) {
        Asset f = i.next();
        logger().debug("Reading options definitions in : " + f);
        readOptionsDefinitions(f);
    }
    options.values().forEach(o -> System.out.println(o.getName()));
    bake();
}
Also used : Asset(io.xol.chunkstories.api.content.Asset)

Example 7 with Asset

use of io.xol.chunkstories.api.content.Asset in project chunkstories by Hugobros3.

the class TexturesHandler method reloadAll.

public static void reloadAll() {
    for (Texture2DGL texture : loadedTextures.values()) {
        if (texture instanceof Texture2DAsset) {
            Asset newAsset = Client.getInstance().getContent().getAsset(((Texture2DAsset) texture).getName());
            if (newAsset != null) {
                ((Texture2DAsset) texture).setAsset(newAsset);
                ((Texture2DAsset) texture).loadTextureFromAsset();
            } else // If the asset is no longer avaible, don't update the texture and delete it
            {
                texture.destroy();
                loadedTextures.remove(((Texture2DAsset) texture).getName());
            }
        } else if (texture instanceof Texture2DFile) {
            ((Texture2DFile) texture).loadTextureFromFile();
        }
    }
    for (CubemapGL cubemap : loadedCubemaps.values()) {
        cubemap.loadCubemapFromDisk();
    // Asset newAsset = Mods.getAsset(cubemap.getName());
    // cubemap.setAsset(newAsset);
    }
}
Also used : Asset(io.xol.chunkstories.api.content.Asset)

Example 8 with Asset

use of io.xol.chunkstories.api.content.Asset in project chunkstories by Hugobros3.

the class ModsManagerImplementation method getAllAssetsByPrefix.

@Override
public Iterator<Asset> getAllAssetsByPrefix(String prefix) {
    return new Iterator<Asset>() {

        Iterator<ModsAssetHierarchy> base = avaibleAssets.values().iterator();

        Asset next = null;

        @Override
        public boolean hasNext() {
            if (next != null)
                return true;
            // If next == null, try to set it
            while (base.hasNext()) {
                AssetHierarchy entry = base.next();
                if (entry.getName().startsWith(prefix)) {
                    next = entry.topInstance();
                    break;
                }
            }
            // Did we suceed etc
            return next != null;
        }

        @Override
        public Asset next() {
            // Try loading
            if (next == null)
                hasNext();
            // Null out reference and return it
            Asset ret = next;
            next = null;
            return ret;
        }
    };
}
Also used : Iterator(java.util.Iterator) IterableIterator(io.xol.chunkstories.api.util.IterableIterator) Asset(io.xol.chunkstories.api.content.Asset) AssetHierarchy(io.xol.chunkstories.api.content.mods.AssetHierarchy)

Example 9 with Asset

use of io.xol.chunkstories.api.content.Asset in project chunkstories by Hugobros3.

the class ModsManagerImplementation method getAllAssetsByExtension.

@Override
public Iterator<Asset> getAllAssetsByExtension(String extension) {
    return new Iterator<Asset>() {

        Iterator<ModsAssetHierarchy> base = avaibleAssets.values().iterator();

        Asset next = null;

        @Override
        public boolean hasNext() {
            if (next != null)
                return true;
            // If next == null, try to set it
            while (base.hasNext()) {
                AssetHierarchy entry = base.next();
                if (entry.getName().endsWith(extension)) {
                    next = entry.topInstance();
                    break;
                }
            }
            // Did we suceed etc
            return next != null;
        }

        @Override
        public Asset next() {
            // Try loading
            if (next == null)
                hasNext();
            // Null out reference and return it
            Asset ret = next;
            next = null;
            return ret;
        }
    };
}
Also used : Iterator(java.util.Iterator) IterableIterator(io.xol.chunkstories.api.util.IterableIterator) Asset(io.xol.chunkstories.api.content.Asset) AssetHierarchy(io.xol.chunkstories.api.content.mods.AssetHierarchy)

Example 10 with Asset

use of io.xol.chunkstories.api.content.Asset in project chunkstories by Hugobros3.

the class EntityDefinitionsStore method reload.

public void reload() {
    // EntityDefinitionsById.clear();
    EntityDefinitionsByName.clear();
    Iterator<Asset> i = content.modsManager().getAllAssetsByExtension("entities");
    while (i.hasNext()) {
        Asset f = i.next();
        readEntitiesDefinitions(f);
    }
// this.entityComponents.reload();
}
Also used : Asset(io.xol.chunkstories.api.content.Asset)

Aggregations

Asset (io.xol.chunkstories.api.content.Asset)22 IOException (java.io.IOException)6 AssetHierarchy (io.xol.chunkstories.api.content.mods.AssetHierarchy)5 File (java.io.File)3 ArrayList (java.util.ArrayList)3 IterableIterator (io.xol.chunkstories.api.util.IterableIterator)2 BufferedReader (java.io.BufferedReader)2 Iterator (java.util.Iterator)2 PNGDecoder (de.matthiasmann.twl.utils.PNGDecoder)1 ClientInterface (io.xol.chunkstories.api.client.ClientInterface)1 IllegalVoxelDeclarationException (io.xol.chunkstories.api.exceptions.content.IllegalVoxelDeclarationException)1 MeshLoadException (io.xol.chunkstories.api.exceptions.content.MeshLoadException)1 PluginLoadException (io.xol.chunkstories.api.exceptions.plugins.PluginLoadException)1 AnimatableMesh (io.xol.chunkstories.api.mesh.AnimatableMesh)1 Mesh (io.xol.chunkstories.api.mesh.Mesh)1 VoxelRenderer (io.xol.chunkstories.api.rendering.voxel.VoxelRenderer)1 ForeignCodeClassLoader (io.xol.chunkstories.content.sandbox.ForeignCodeClassLoader)1 NotAPluginException (io.xol.chunkstories.plugin.NotAPluginException)1 PluginInformationImplementation (io.xol.chunkstories.plugin.PluginInformationImplementation)1 BufferedImage (java.awt.image.BufferedImage)1