2025-07-10 19:07:46 +02:00
|
|
|
using Babushka.scripts.CSharp.Common.SceneManagement;
|
2025-05-24 23:50:06 +02:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace Babushka.scripts.CSharp.Common;
|
|
|
|
|
|
|
|
|
|
public partial class SceneTransition : Node
|
|
|
|
|
{
|
2025-07-10 19:07:46 +02:00
|
|
|
[Export] private string[] _sceneNamesToLoad;
|
|
|
|
|
[Export] private int _sceneIndex;
|
2025-05-24 23:50:06 +02:00
|
|
|
[Export] private bool _unloadSelf = true;
|
|
|
|
|
|
|
|
|
|
public void LoadScene()
|
|
|
|
|
{
|
2025-07-10 23:23:20 +02:00
|
|
|
LoadSceneAtIndex(0);
|
2025-05-24 23:50:06 +02:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 19:07:46 +02:00
|
|
|
public void LoadSceneAtIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
string sceneName = _sceneNamesToLoad[index];
|
2025-08-11 19:15:12 +02:00
|
|
|
SceneTransitionThreaded.Instance.ChangeSceneToFile(sceneName);
|
2025-07-10 19:07:46 +02:00
|
|
|
UnloadAfterDelay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void UnloadAfterDelay()
|
|
|
|
|
{
|
|
|
|
|
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
|
|
|
|
|
if (_unloadSelf)
|
|
|
|
|
{
|
|
|
|
|
QueueFree();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-15 20:05:53 +02:00
|
|
|
public void Quit()
|
|
|
|
|
{
|
|
|
|
|
GetTree().Quit();
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-24 23:50:06 +02:00
|
|
|
}
|