Tweaks to map loading

This commit is contained in:
Marco 2025-03-28 14:02:33 +01:00
commit e56b896365

View file

@ -98,14 +98,13 @@ public partial class GlobalState : Node
private void DeferredGotoScene(string path, MapStartDataResource startData = null) private void DeferredGotoScene(string path, MapStartDataResource startData = null)
{ {
// if (InventoryManager.Instance is not null)
// {
// SessionSettings.Items = InventoryManager.Instance.Save();
// }
// It is now safe to remove the current scene. // It is now safe to remove the current scene.
CurrentScene.Free(); CurrentScene.Free();
//var sceneParent = CurrentScene.GetParent();
//sceneParent.RemoveChild(CurrentScene);
//sceneParent.QueueFree();
// Load a new scene. // Load a new scene.
var nextScene = GD.Load<PackedScene>(path); var nextScene = GD.Load<PackedScene>(path);
CurrentSceneId = nextScene.GetSceneUniqueId(); CurrentSceneId = nextScene.GetSceneUniqueId();
@ -128,9 +127,10 @@ public partial class GlobalState : Node
DeferredAddStartDataToGameManager(startData); DeferredAddStartDataToGameManager(startData);
} }
if (GameManager.Instance is not null) { // Do not do this here because it might get the old gamemanager instead
GameManager.Instance.ApplySessionState(SessionSettings); // if (GameManager.Instance is not null) {
} // GameManager.Instance.ApplySessionState(SessionSettings);
// }
FadeIn(); FadeIn();
} }