rhythmbullet/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentSystem.cs

41 lines
1.2 KiB
C#

using Microsoft.Xna.Framework.Content;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
{
class ContentSystem
{
private readonly ContentManager contentManager;
private readonly Queue<Dictionary<Type, string>> queue;
private Dictionary<string, IDisposable> assets;
readonly Dictionary<Type, IContentResolver> contentResolver;
public ContentSystem(ContentManager contentManager)
{
this.contentManager = contentManager;
assets = new Dictionary<string, IDisposable>();
queue = new Queue<Dictionary<Type, string>>();
contentResolver = new Dictionary<Type, IContentResolver>();
}
void Load(string assetName, Type type)
{
if (assets.ContainsKey(assetName))
{
IContentResolver handler = contentResolver[type];
string path = handler.Load(assetName);
assets.Add(assetName, contentManager.Load<IDisposable>(path));
}
}
T get<T> (string assetName)
{
return (T)assets[assetName];
}
}
}