refactor and better screen mechanism (probably)
This commit is contained in:
@@ -11,18 +11,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
{
|
||||
public delegate void ContentSystemUpdate(String fileName, float completed);
|
||||
|
||||
public class ContentSystem
|
||||
public class ContentManagerController
|
||||
{
|
||||
public event ContentSystemUpdate ContentSystemListeners;
|
||||
Thread thread;
|
||||
readonly ContentManager contentManager;
|
||||
readonly Queue<LoadableContent> queue;
|
||||
Dictionary<string, IDisposable> assets;
|
||||
public readonly Dictionary<Type, IContentPathModifier> contentPathModifier;
|
||||
volatile float progress;
|
||||
public ContentSystem(ContentManager contentManager)
|
||||
volatile bool running;
|
||||
|
||||
public ContentManagerController(ContentManager contentManager)
|
||||
{
|
||||
this.contentManager = contentManager;
|
||||
assets = new Dictionary<string, IDisposable>();
|
||||
@@ -46,6 +45,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
|
||||
public T Get<T>(string assetName)
|
||||
{
|
||||
Console.WriteLine("Attempt get");
|
||||
lock (queue)
|
||||
{
|
||||
return (T)assets[assetName];
|
||||
@@ -83,6 +83,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
|
||||
private void LoadBatch()
|
||||
{
|
||||
running = true;
|
||||
int totalTasks = queue.Count;
|
||||
int tasksCompleted = 0;
|
||||
while (queue.Count != 0)
|
||||
@@ -93,9 +94,9 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
Load(content.assetName, content.type, content.usePathModifier);
|
||||
tasksCompleted++;
|
||||
progress = (float)tasksCompleted / totalTasks;
|
||||
OnProgress(content.assetName, progress);
|
||||
}
|
||||
}
|
||||
running = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the asset from the list of assets in the system.
|
||||
@@ -143,15 +144,10 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return queue.Count == 0;
|
||||
return !running && queue.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnProgress(string fileName, float progress)
|
||||
{
|
||||
ContentSystemListeners?.Invoke(fileName, progress);
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
Reference in New Issue
Block a user