Use proper scene load function in all cases

This commit is contained in:
Marco 2025-02-21 12:09:42 +01:00
commit c5ed30f458
5 changed files with 12 additions and 5 deletions

View file

@ -27,7 +27,7 @@ public partial class GlobalState : Node
// The solution is to defer the load to a later time, when
// we can be sure that no code from the current scene is running:
CallDeferred(MethodName.DeferredGotoScene, path);
CallDeferred(MethodName.DeferredGotoScene, path, new MapStartDataResource());
}
public void GoToScene(string path, MapStartDataResource startData)
@ -53,6 +53,9 @@ public partial class GlobalState : Node
// Optionally, to make it compatible with the SceneTree.change_scene_to_file() API.
GetTree().CurrentScene = CurrentScene;
// // Update current scene here too
// CurrentScene = GetTree().Root.GetChild(-1);
if (startData is not null)
{
// Call deferred if it gives issues

View file

@ -29,7 +29,8 @@ public partial class IntroManager : Node
private void DialogueEndAction()
{
GetTree().ChangeSceneToFile(NextMap);
GlobalState.Instance.GotoScene(NextMap);
//GetTree().ChangeSceneToFile(NextMap);
}
}

View file

@ -31,7 +31,8 @@ public partial class MainMenu : Control
private void _on_start_button_pressed()
{
if (GameScene != null) {
GetTree().ChangeSceneToFile(GameScene);
GlobalState.Instance.GotoScene(GameScene);
//GetTree().ChangeSceneToFile(GameScene);
}
}

View file

@ -82,7 +82,8 @@ public partial class IntroScenePlayer : CanvasLayer
private void Finished()
{
GetTree().ChangeSceneToFile(NextSceneName);
GlobalState.Instance.GotoScene(NextSceneName);
//GetTree().ChangeSceneToFile(NextSceneName);
}
private async Task Transition()

View file

@ -47,6 +47,7 @@ public partial class PauseMenu : Control
private void QuitButtonOnPressed()
{
GetTree().ChangeSceneToFile(MainMenuScene);
GlobalState.Instance.GotoScene(MainMenuScene);
//GetTree().ChangeSceneToFile(MainMenuScene);
}
}