Add TimeElapsed property
							parent
							
								
									28a408de1b
								
							
						
					
					
						commit
						df82248670
					
				|  | @ -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; | ||||
|  |  | |||
|  | @ -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; } | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue