namespace NT { /**
     * The message code prefix for asset load notifications.
     */ export const MESSAGE_ASSET_LOADER_ASSET_LOADED = "MESSAGE_ASSET_LOADER_ASSET_LOADED::" ; /** Manages all assets in the engine. */ export class AssetManager { private static _loaders : IAssetLoader [ ] = [ ] ; private static _loadedAssets : { [ name ] : IAsset ; } = { } ; /** Private to enforce static method calls and prevent instantiation. */ private constructor ( ) { } /** Initializes this manager. */ public static Initialize ( ) { AssetManager . _loaders . push ( new ImageAssetLoader ( ) ) ; AssetManager . _loaders . push ( new JsonAssetLoader ( ) ) ; AssetManager . _loaders . push ( new TextAssetLoader ( ) ) ; } param loader public static registerLoader ( loader ) { AssetManager . _loaders . push ( loader ) ; } param asset public static onAssetLoaded ( asset ) { AssetManager . _loadedAssets [ asset . Name ] = asset ; Message . send ( MESSAGE_ASSET_LOADER_ASSET_LOADED + asset . Name , this , asset ) ; } param assetName public static loadAsset ( assetName ) { let extension = assetName . split ( '.' ) . pop ( ) . toLowerCase ( ) ; for ( let l of AssetManager . _loaders ) { if ( l . supportedExtensions . indexOf ( extension ) !== - 1 ) { l . LoadAsset ( assetName ) ; return ; } } console . warn ( "Unable to load asset with extension " + extension + " because there is no loader associated with it." ) ; } param assetName public static isAssetLoaded ( assetName ) { return AssetManager . _loadedAssets [ assetName ] !== undefined ; } param assetName public static getAsset ( assetName ) { if ( AssetManager . _loadedAssets [ assetName ] !== undefined ) { return AssetManager . _loadedAssets [ assetName ] ; } else { AssetManager . loadAsset ( assetName ) ; } return undefined ; } } }