You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/SceneTransition.cs

40 lines
934 B

using Babushka.scripts.CSharp.Common.Savegame;
using Babushka.scripts.CSharp.Common.SceneManagement;
using Godot;
namespace Babushka.scripts.CSharp.Common;
public partial class SceneTransition : Node
{
[Export] private string[] _sceneNamesToLoad;
[Export] private int _sceneIndex;
[Export] private bool _unloadSelf = true;
public void LoadScene()
{
LoadSceneAtIndex(0);
}
public void LoadSceneAtIndex(int index)
{
SavegameService.Save();
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();
}
}