From 3d4ed2a1fdeeedfc97dfb3a7306fc905cdf1114b Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 2 Apr 2025 18:39:37 +0200 Subject: [PATCH] Save game on level start if enabled --- Scripts/GameManager.cs | 7 +++++-- Scripts/Utils/SessionSettings.cs | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Scripts/GameManager.cs b/Scripts/GameManager.cs index 2bdf4a56..5714e2a4 100644 --- a/Scripts/GameManager.cs +++ b/Scripts/GameManager.cs @@ -69,6 +69,11 @@ public partial class GameManager : Node2D { Instance = this; + if (GlobalState.Instance.SessionSettings.AllowSaving) + { + GlobalState.Instance.SaveGame(); + } + _hud = GetNodeOrNull("HUD"); if (_hud == null) GD.Print("No HUD in scene."); @@ -189,10 +194,8 @@ public partial class GameManager : Node2D _player.Owner = this; } - _player.Transform = this.GlobalTransform; - _player.GlobalPosition = GetStartPosition(); LastCheckpointPosition = _player.GlobalPosition; diff --git a/Scripts/Utils/SessionSettings.cs b/Scripts/Utils/SessionSettings.cs index 69bfc106..549a5031 100644 --- a/Scripts/Utils/SessionSettings.cs +++ b/Scripts/Utils/SessionSettings.cs @@ -8,6 +8,8 @@ public class SessionSettings public bool SkipDialogues { get; set; } = false; public bool GodMode { get; set; } = false; + public bool AllowSaving { get; set; } = false; + public Godot.Collections.Dictionary Items { get; set; } = new(); public int LevelNumber { get; set; } = 0;