/** * @param urn The two-part uri for asset ("module:assetName") * @return The requested texture, or null if it doesn't exist */ public static Optional<Texture> getTexture(ResourceUrn urn) { return get(urn, Texture.class); }
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested music, or null if it doesn't exist */ public static Optional<StreamingSound> getMusic(String simpleUri) { return get(simpleUri, StreamingSound.class); } //
/** * @param urn The two-part uri for asset ("module:assetName") * @return The requested texture, or null if it doesn't exist */ public static Optional<Texture> getTexture(String urn) { return get(urn, Texture.class); }
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested shader, or null if it doesn't exist */ public static Optional<Shader> getShader(String simpleUri) { return get(simpleUri, Shader.class); } //
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested font, or null if it doesn't exist */ public static Optional<Font> getFont(String simpleUri) { return get(simpleUri, Font.class); } //
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested sound, or null if it doesn't exist */ public static Optional<StaticSound> getSound(String simpleUri) { return get(simpleUri, StaticSound.class); } //
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested mesh, or null if it doesn't exist */ public static Optional<Mesh> getMesh(String simpleUri) { return get(simpleUri, Mesh.class); } //
/** * @param simpleUri The two-part uri for asset ("module:assetName") * @return The requested material, or null if it doesn't exist */ public static Optional<Material> getMaterial(String simpleUri) { return get(simpleUri, Material.class); }
public static Optional<UIElement> getUIElement(String uri) { return get(uri, UIElement.class); }
@Override public Prefab parse(String raw) { return Assets.get(raw, Prefab.class).orElse(null); }
@Override public V deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return type.cast(Assets.get(json.getAsString(), type).orElse(null)); } }
@Override public T getFromString(String representation) { if (Strings.isNullOrEmpty(representation)) { return null; } Optional<T> asset = Assets.get(representation, assetClass); if (asset.isPresent()) { return assetClass.cast(asset.get()); } return null; } }
private void addHeightMap(ResourceUrn uri) { String name = uri.toString() + "Height"; Optional<BlockTile> tile = Assets.get(name, BlockTile.class); if (tile.isPresent()) { tilesHeight.add(tile.get()); } else { // intentionally pad this list with null so that the indexes match the main atlas tilesHeight.add(null); } }
@Override public boolean step() { ResourceUrn textureUrn = urns.next(); Assets.get(textureUrn, Texture.class); stepDone(); return !urns.hasNext(); }
private void addNormal(ResourceUrn uri) { String name = uri.toString() + "Normal"; Optional<BlockTile> tile = Assets.get(name, BlockTile.class); if (tile.isPresent()) { tilesNormal.add(tile.get()); } else { // intentionally pad this list with null so that the indexes match the main atlas tilesNormal.add(null); } }
private void addGlossMap(ResourceUrn uri) { String name = uri.toString() + "Gloss"; Optional<BlockTile> tile = Assets.get(name, BlockTile.class); if (tile.isPresent()) { tilesGloss.add(tile.get()); } else { // intentionally pad this list with null so that the indexes match the main atlas tilesGloss.add(null); } }
public static Mesh getIconMesh(TextureRegion region) { if (region instanceof Asset) { ResourceUrn urn = ((Asset<?>) region).getUrn(); if (urn.getFragmentName().isEmpty()) { return Assets.get(new ResourceUrn(urn.getModuleName(), IconMeshDataProducer.ICON_DISCRIMINATOR, urn.getResourceName()), Mesh.class).get(); } else { Name fragName = new Name(urn.getResourceName().toString() + ResourceUrn.FRAGMENT_SEPARATOR + urn.getFragmentName().toString()); return Assets.get(new ResourceUrn(urn.getModuleName(), IconMeshDataProducer.ICON_DISCRIMINATOR, fragName), Mesh.class).get(); } } else { return generateIconMesh(region); } }
private void applyCommonDataDelta(EntityData.Prefab delta, PrefabData result) { if (delta.hasPersisted()) { result.setPersisted(delta.getPersisted()); } if (delta.hasAlwaysRelevant()) { result.setAlwaysRelevant(delta.getAlwaysRelevant()); } if (delta.hasParentName()) { Optional<? extends Prefab> parent = Assets.get(delta.getParentName(), Prefab.class); result.setParent(parent.orElse(null)); } }
private void deserializeCommonData(EntityData.Prefab prefabData, PrefabData result) { result.setPersisted((prefabData.hasPersisted()) ? prefabData.getPersisted() : true); result.setAlwaysRelevant(prefabData.hasAlwaysRelevant() ? prefabData.getAlwaysRelevant() : false); if (prefabData.hasParentName()) { Prefab parent = Assets.get(prefabData.getParentName(), Prefab.class).orElse(null); result.setParent(parent); } }