WIP new SceneTransition system
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Babushka.scripts.CSharp.Common.SceneManagement;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common;
|
||||
@@ -5,9 +7,12 @@ namespace Babushka.scripts.CSharp.Common;
|
||||
public partial class SceneTransition : Node
|
||||
{
|
||||
[Export] private PackedScene _sceneToLoad;
|
||||
[Export] private string[] _sceneNamesToLoad;
|
||||
[Export] private int _sceneIndex;
|
||||
[Export] private Node? _sceneInstanceParent;
|
||||
[Export] private bool _unloadSelf = true;
|
||||
|
||||
// todo: remove and replace with indexed system
|
||||
public void LoadScene()
|
||||
{
|
||||
Node sceneInstance = _sceneToLoad.Instantiate();
|
||||
@@ -24,6 +29,22 @@ public partial class SceneTransition : Node
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadSceneAtIndex(int index)
|
||||
{
|
||||
string sceneName = _sceneNamesToLoad[index];
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFileThreaded(sceneName);
|
||||
UnloadAfterDelay();
|
||||
}
|
||||
|
||||
private async void UnloadAfterDelay()
|
||||
{
|
||||
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
|
||||
if (_unloadSelf)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
GetTree().Quit();
|
||||
|
||||
Reference in New Issue
Block a user