mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Automatic script assembly reloading
This commit is contained in:
@@ -5,6 +5,8 @@ using GlitchyEngine.Renderer;
|
||||
using GlitchyEngine.Debug;
|
||||
using GlitchyEngine.Content;
|
||||
using GlitchyEngine.Scripting;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
namespace GlitchyEngine
|
||||
{
|
||||
@@ -28,6 +30,9 @@ namespace GlitchyEngine
|
||||
|
||||
private IContentManager _contentManager;
|
||||
|
||||
private append List<delegate void()> _jobQueue = .() ~ ClearAndDeleteItems!(_);
|
||||
private append Monitor _jobQueueMutex = .();
|
||||
|
||||
public bool IsRunning => _running;
|
||||
public Window Window => _window;
|
||||
|
||||
@@ -37,9 +42,11 @@ namespace GlitchyEngine
|
||||
|
||||
public GameTime GameTime => _gameTime;
|
||||
|
||||
[Inline]
|
||||
[Inline, Obsolete("Use Application.Instance instead.", false)]
|
||||
public static Application Get() => s_Instance;
|
||||
|
||||
public static Application Instance => s_Instance;
|
||||
|
||||
public Settings Settings {get; private set;} = new .() ~ delete _;
|
||||
|
||||
public this()
|
||||
@@ -157,6 +164,8 @@ namespace GlitchyEngine
|
||||
}
|
||||
#endif
|
||||
|
||||
RunJobs();
|
||||
|
||||
if(allowFrame && !_isMinimized)
|
||||
{
|
||||
Debug.Profiler.ProfileScope!("Update Layers");
|
||||
@@ -218,5 +227,29 @@ namespace GlitchyEngine
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Executes the given Job on the main thread. Takes ownership of the delegate.
|
||||
public void InvokeOnMainThread(delegate void() ownJob)
|
||||
{
|
||||
using (_jobQueueMutex.Enter())
|
||||
{
|
||||
_jobQueue.Add(ownJob);
|
||||
}
|
||||
}
|
||||
|
||||
private void RunJobs()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
using (_jobQueueMutex.Enter())
|
||||
{
|
||||
for (let job in _jobQueue)
|
||||
{
|
||||
job();
|
||||
}
|
||||
|
||||
ClearAndDeleteItems!(_jobQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user