Exemplo n.º 1
0
        /// <summary>Load a matched asset.</summary>
        /// <param name="asset">Basic metadata about the asset being loaded.</param>
        public T Load <T>(IAssetInfo asset)
        {
            // texture redirect
            string redirectPath = this.GetRedirect <T>(asset);

            if (redirectPath != null)
            {
                string relativePath = ContentHandler.GetRelativePath(redirectPath, this.ModPath); // underlying content manager doesn't allow absolute paths
                return(this.ContentHelper.Load <T>(relativePath));
            }

            // loader delegate
            FileLoadMethod <T> loader = this.GetLoaderDelegate <T>(asset);

            if (loader != null)
            {
                return(loader.Invoke(asset.AssetName));
            }

            // none found?
            throw new InvalidOperationException("ContentManager: no asset loaders found. This shouldn't happen.");
        }