Is a class such as this necessary?
public class ContentCache
{
private readonly ContentManager _content;
private readonly Dictionary<string, Texture2D> _textureCache = new Dictionary<string, Texture2D>();
public ContentCache(ContentManager content)
{
_content = content;
}
public Texture2D Load(string assetName)
{
Texture2D texture = null;
if (!_textureCache.TryGetValue(assetName, out texture))
{
_textureCache[assetName] =
texture = _content.Load<Texture2D>(assetName);
}
return texture;
}
}
I am curious if ContentManager.Load<Texture2D>()
does it's own caching internally. I don't want to double-cache things.
Note:
Our XNA game is 2D and going to run on WP7 and Windows, and also iOS and OSX using MonoGame.
MonoGame may function differently than XNA in Windows, but I can probably browse it's source to find that out.