add: LoadingScene, ProxyNode
This commit is contained in:
30
src/Scenes/LoadingScene.cs
Normal file
30
src/Scenes/LoadingScene.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Godot;
|
||||
using Polonium.DataStructures;
|
||||
using Polonium.Managers;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
|
||||
public abstract partial class LoadingScene<T> : Scene
|
||||
where T : ProgressInfo
|
||||
{
|
||||
public Scene AfterLoaded { get; set; }
|
||||
|
||||
private double CoolDown { get; set; } = 0;
|
||||
|
||||
public LoaderManager<T> Manager { get; set; }
|
||||
|
||||
protected abstract void ConsumeProgressInfo(T progressInfo);
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
CoolDown += delta;
|
||||
if (CoolDown < 1)
|
||||
return;
|
||||
CoolDown = 0;
|
||||
T progress = Manager.QueryProgress();
|
||||
ConsumeProgressInfo(progress);
|
||||
if(Manager.Finished)
|
||||
PoloniumRegistry.Instance.RootScene.SwitchScene(AfterLoaded);
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user