diff --git a/State/Global/GlobalState.cs b/State/Global/GlobalState.cs index 286693d..7b109c8 100644 --- a/State/Global/GlobalState.cs +++ b/State/Global/GlobalState.cs @@ -14,6 +14,10 @@ public partial class GlobalState : Node, ISave [Export] public Stats Stats { get; set; } + private ulong _saveTimeElapsed = 0; + + public ulong TimeElapsed => _saveTimeElapsed + Godot.Time.GetTicksMsec(); + public static GlobalState Instance { get; private set; } [Export] @@ -76,6 +80,7 @@ public partial class GlobalState : Node, ISave Progression = save.Progression; MapState = save.MapState; Stats = save.Stats; + _saveTimeElapsed = save.TimeElapsed; // use as offset var inventory = World.Instance.CurrentPlayer.Inventory; inventory.Items = Stats.Items; @@ -96,6 +101,7 @@ public partial class GlobalState : Node, ISave save.Progression = Progression; save.MapState = MapState; save.Stats = Stats; + save.TimeElapsed = TimeElapsed; // update time elapsed when saving var inventory = World.Instance.CurrentPlayer.Inventory; Stats.Items = inventory.Items; diff --git a/Utils/ISave.cs b/Utils/ISave.cs index 4affb77..297a4f2 100644 --- a/Utils/ISave.cs +++ b/Utils/ISave.cs @@ -9,4 +9,6 @@ public interface ISave public State.Global.MapState MapState { get; set; } public State.Global.Stats Stats { get; set; } + + public ulong TimeElapsed { get; } } diff --git a/Utils/Save.cs b/Utils/Save.cs index c69837f..87446c2 100644 --- a/Utils/Save.cs +++ b/Utils/Save.cs @@ -13,10 +13,14 @@ public partial class Save : Resource, ISave [Export] public State.Global.Stats Stats { get; set; } + [Export] + public ulong TimeElapsed { get; set; } + public Save() { Progression = new(); MapState = new(); Stats = new(); + TimeElapsed = 0; } }