b15f3b7391
Need to implement: Slider and logic for it and UI and the logic for that as well.
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Concurrent;
|
|
using UnityEngine;
|
|
|
|
namespace Proxima
|
|
{
|
|
internal class ProximaDispatcher
|
|
{
|
|
private ConcurrentQueue<Action> _queue = new ConcurrentQueue<Action>();
|
|
private MonoBehaviour _coroutineRunner;
|
|
|
|
public ProximaDispatcher(MonoBehaviour coroutineRunner)
|
|
{
|
|
_coroutineRunner = coroutineRunner;
|
|
}
|
|
|
|
public void Dispatch(Action action)
|
|
{
|
|
_queue.Enqueue(action);
|
|
}
|
|
|
|
public void InvokeAll()
|
|
{
|
|
while (_queue.TryDequeue(out var action))
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Exception(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void StartCoroutine(IEnumerator coroutine)
|
|
{
|
|
if (_coroutineRunner)
|
|
{
|
|
_coroutineRunner.StartCoroutine(coroutine);
|
|
}
|
|
}
|
|
}
|
|
} |