using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Microsoft.Xna.Framework;
using StardewModdingAPI.Framework.Reflection;
using StardewValley;
namespace StardewModdingAPI.Framework
{
/// SMAPI's implementation of the game's content manager which lets it raise content events.
internal class SContentManager : LocalizedContentManager
{
/*********
** Accessors
*********/
/// Encapsulates monitoring and logging.
private readonly IMonitor Monitor;
/// The underlying content manager's asset cache.
private readonly IDictionary Cache;
/// Normalises an asset key to match the cache key.
private readonly IPrivateMethod NormaliseAssetKey;
/*********
** Public methods
*********/
/// Construct an instance.
/// The service provider to use to locate services.
/// The root directory to search for content.
/// Encapsulates monitoring and logging.
public SContentManager(IServiceProvider serviceProvider, string rootDirectory, IMonitor monitor)
: this(serviceProvider, rootDirectory, Thread.CurrentThread.CurrentUICulture, null, monitor) { }
/// Construct an instance.
/// The service provider to use to locate services.
/// The root directory to search for content.
/// The current culture for which to localise content.
/// The current language code for which to localise content.
/// Encapsulates monitoring and logging.
public SContentManager(IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, string languageCodeOverride, IMonitor monitor)
: base(serviceProvider, rootDirectory, currentCulture, languageCodeOverride)
{
this.Monitor = monitor;
IReflectionHelper reflection = new ReflectionHelper();
this.Cache = reflection
.GetPrivateField>(this, "loadedAssets")
.GetValue();
this.NormaliseAssetKey = reflection.GetPrivateMethod(typeof(TitleContainer), "GetCleanPath");
}
/// Load an asset that has been processed by the Content Pipeline.
/// The type of asset to load.
/// The asset path relative to the loader root directory, not including the .xnb extension.
public override T Load(string assetName)
{
return base.Load(assetName);
}
}
}