changed content manager controller's generic type to allow for any object instead of IDisposable only.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.ContentSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,7 +16,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
Thread thread;
|
||||
readonly ContentManager contentManager;
|
||||
readonly Queue<ContentData> queue;
|
||||
Dictionary<string, IDisposable> assets;
|
||||
Dictionary<string, Object> assets;
|
||||
/// <summary>
|
||||
/// Path modifiers to change the path in which the content manager looks to load a file. Used for better organizing things while not needing to type entire path.
|
||||
/// </summary>
|
||||
@@ -44,7 +45,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
public ContentManagerController(ContentManager contentManager)
|
||||
{
|
||||
this.contentManager = contentManager;
|
||||
assets = new Dictionary<string, IDisposable>();
|
||||
assets = new Dictionary<string, Object>();
|
||||
queue = new Queue<ContentData>();
|
||||
contentPathModifier = new Dictionary<Type, IContentPathResolver>();
|
||||
}
|
||||
@@ -59,13 +60,14 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
if (contentPathModifier.ContainsKey(type))
|
||||
{
|
||||
handler = contentPathModifier[type];
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
handler = normalPathModifier;
|
||||
}
|
||||
path = handler.Modify(assetName);
|
||||
}
|
||||
assets.Add(assetName, contentManager.Load<IDisposable>(path));
|
||||
assets.Add(assetName, contentManager.Load<Object>(path));
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
/// <typeparam name="T">The type of the asset to be queued.</typeparam>
|
||||
/// <param name="assetName">Name of asset to look for.</param>
|
||||
/// <param name="usePathModifier">Whether or not to use the path modifiers.</param>
|
||||
public void Queue<T>(string assetName, bool usePathModifier = true) where T : IDisposable
|
||||
public void Queue<T>(string assetName, bool usePathModifier = true)
|
||||
{
|
||||
lock (queue)
|
||||
{
|
||||
@@ -145,7 +147,10 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
{
|
||||
if (assets.ContainsKey(name))
|
||||
{
|
||||
assets[name].Dispose();
|
||||
if (assets[name] is IDisposable)
|
||||
{
|
||||
((IDisposable)assets[name]).Dispose();
|
||||
}
|
||||
assets.Remove(name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user