mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 16:35:54 +00:00
Map start system
This commit is contained in:
parent
4abab60eac
commit
7acc344986
11 changed files with 323 additions and 41 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
public partial class GlobalState : Node
|
||||
|
|
@ -13,8 +14,6 @@ public partial class GlobalState : Node
|
|||
Viewport root = GetTree().Root;
|
||||
// Using a negative index counts from the end, so this gets the last child node of `root`.
|
||||
CurrentScene = root.GetChild(-1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GotoScene(string path)
|
||||
|
|
@ -31,7 +30,13 @@ public partial class GlobalState : Node
|
|||
CallDeferred(MethodName.DeferredGotoScene, path);
|
||||
}
|
||||
|
||||
public void DeferredGotoScene(string path)
|
||||
public void GoToScene(string path, MapStartDataResource startData)
|
||||
{
|
||||
// TODO: Implement startdata usage
|
||||
CallDeferred(MethodName.DeferredGotoScene, path, startData);
|
||||
}
|
||||
|
||||
private void DeferredGotoScene(string path, MapStartDataResource startData = null)
|
||||
{
|
||||
// It is now safe to remove the current scene.
|
||||
CurrentScene.Free();
|
||||
|
|
@ -47,11 +52,16 @@ public partial class GlobalState : Node
|
|||
|
||||
// Optionally, to make it compatible with the SceneTree.change_scene_to_file() API.
|
||||
GetTree().CurrentScene = CurrentScene;
|
||||
|
||||
if (startData is not null)
|
||||
{
|
||||
// Call deferred if it gives issues
|
||||
DeferredAddStartDataToGameManager(startData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MapStartData
|
||||
{
|
||||
public int EggIndex = 0;
|
||||
|
||||
private void DeferredAddStartDataToGameManager(MapStartDataResource resource)
|
||||
{
|
||||
GameManager.Instance.ApplyMapStartData(resource);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue