From f6fbb366a313e98671c21aaabac706c9db8a0c89 Mon Sep 17 00:00:00 2001 From: Recrown Date: Thu, 1 Nov 2018 00:05:10 -0500 Subject: [PATCH] Removed automatic root search from content system --- RhythmBullet/RhythmBulletGame.cs | 2 +- .../Utilities/ContentSystem/ContentLoad.cs | 6 +++-- .../Utilities/ContentSystem/ContentSystem.cs | 25 ++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/RhythmBullet/RhythmBulletGame.cs b/RhythmBullet/RhythmBulletGame.cs index 1895f45..8620e4b 100644 --- a/RhythmBullet/RhythmBulletGame.cs +++ b/RhythmBullet/RhythmBulletGame.cs @@ -178,7 +178,7 @@ namespace RhythmBullet Assets.Queue("cybercircle3B"); Assets.Queue("title"); Assets.Queue("cybercircle1"); - Assets.Queue("default_cover"); + Assets.Queue("default_cover", false); Assets.Queue("laser"); Assets.Queue("pellet"); Assets.Queue("shard"); diff --git a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentLoad.cs b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentLoad.cs index 602a8a7..3ffcb04 100644 --- a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentLoad.cs +++ b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentLoad.cs @@ -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; } } } diff --git a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentSystem.cs b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentSystem.cs index 97a98bf..b3df5fc 100644 --- a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentSystem.cs +++ b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentSystem.cs @@ -30,20 +30,17 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem contentPathModifier = new Dictionary(); } - 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(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(assetName)); + IContentPathModifier handler = contentPathModifier[type]; + path = handler.Modify(assetName); + } + assets.Add(assetName, contentManager.Load(path)); + Debug.WriteLine("Loaded asset: " + assetName); } @@ -56,13 +53,13 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem } } - public void Queue(string assetName) where T : IDisposable + public void Queue(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); }