Removed automatic root search from content system

This commit is contained in:
Harrison Deng 2018-11-01 00:05:10 -05:00
parent 9c50226eb7
commit f6fbb366a3
3 changed files with 16 additions and 17 deletions

View File

@ -178,7 +178,7 @@ namespace RhythmBullet
Assets.Queue<Texture2D>("cybercircle3B");
Assets.Queue<Texture2D>("title");
Assets.Queue<Texture2D>("cybercircle1");
Assets.Queue<Texture2D>("default_cover");
Assets.Queue<Texture2D>("default_cover", false);
Assets.Queue<Texture2D>("laser");
Assets.Queue<Texture2D>("pellet");
Assets.Queue<Texture2D>("shard");

View File

@ -6,15 +6,17 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
{
class LoadableContent
struct LoadableContent
{
internal Type type;
internal string assetName;
internal bool usePathModifier;
public LoadableContent(string assetName, Type type)
public LoadableContent(string assetName, Type type, bool usePathModifier)
{
this.type = type;
this.assetName = assetName;
this.usePathModifier = usePathModifier;
}
}
}

View File

@ -30,20 +30,17 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
contentPathModifier = new Dictionary<Type, IContentPathModifier>();
}
private void Load(string assetName, Type type)
private void Load(string assetName, Type type, bool usePathModifier)
{
IContentPathModifier handler = contentPathModifier[type];
string path = handler.Modify(assetName);
try
string path = assetName;
if (usePathModifier)
{
assets.Add(assetName, contentManager.Load<IDisposable>(path));
}
catch (ContentLoadException cle)
{
Debug.WriteLine("Failed to load " + assetName + "with modified path: " + cle.Message);
Debug.WriteLine("Loading asset from root: " + assetName);
assets.Add(assetName, contentManager.Load<IDisposable>(assetName));
IContentPathModifier handler = contentPathModifier[type];
path = handler.Modify(assetName);
}
assets.Add(assetName, contentManager.Load<IDisposable>(path));
Debug.WriteLine("Loaded asset: " + assetName);
}
@ -56,13 +53,13 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
}
}
public void Queue<T>(string assetName) where T : IDisposable
public void Queue<T>(string assetName, bool usePathModifier = true) where T : IDisposable
{
lock (queue)
{
if (!assets.ContainsKey(assetName))
{
queue.Enqueue(new LoadableContent(assetName, typeof(T)));
queue.Enqueue(new LoadableContent(assetName, typeof(T), usePathModifier));
Debug.WriteLine("Queued asset: " + assetName);
}
else
@ -94,7 +91,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
lock (queue)
{
LoadableContent content = queue.Dequeue();
Load(content.assetName, content.type);
Load(content.assetName, content.type, content.usePathModifier);
tasksCompleted++;
OnProgress(content.assetName, (float)tasksCompleted / totalTasks);
}