Class AssetLoader<T extends Asset>

java.lang.Object
technology.sola.engine.assets.AssetLoader<T>
Type Parameters:
T - the Asset type
Direct Known Subclasses:
ControlsConfigAssetLoader, FontAssetLoader, GuiJsonDocumentAssetLoader, SpriteSheetAssetLoader

@NullMarked public abstract class AssetLoader<T extends Asset> extends Object
The AssetLoader class contains functionality for loading an Asset type. These are implemented for each SolaPlatform and Asset combination.
  • Constructor Details

    • AssetLoader

      public AssetLoader()
  • Method Details

    • addAssetMapping

      public AssetLoader<T> addAssetMapping(String id, String path)
      Adds an asset id to path mapping but does not populate the cache until the asset is requested via get(String)
      Parameters:
      id - id of the asset
      path - path to the asset
      Returns:
      this
    • hasAssetMapping

      public boolean hasAssetMapping(String id)
      Checks to see if an asset mapping has already been added to this loader.
      Parameters:
      id - the id for the asset mapping
      Returns:
      true if the asset mapping has already been added
    • addAsset

      public AssetLoader<T> addAsset(String id, T asset)
      Manually add an Asset to this loader.
      Parameters:
      id - the id for the Asset
      asset - the Asset
      Returns:
      this loader
    • get

      public AssetHandle<T> get(String id)
      Returns an AssetHandle for the asset requested or throws an exception if id to path mapping not found.
      Parameters:
      id - id of the asset
      Returns:
      handle for the asset
    • getNewAsset

      public AssetHandle<T> getNewAsset(String id, String path)
      Adds an asset id to path mapping and then returns an AssetHandle to the asset.
      Parameters:
      id - id of the asset
      path - path to the asset
      Returns:
      handle for the asset
    • getAssetClass

      public abstract Class<T> getAssetClass()
      Returns:
      The Class of the Asset
    • loadAsset

      protected abstract AssetHandle<T> loadAsset(String path)
      Returns an AssetHandle for the specified path and beings loading the Asset.
      Parameters:
      path - the path to the asset
      Returns:
      the AssetHandle for the path