Add core game components including ConfigFileHandler, GameManager, SaveSystem, and UIManager

This commit is contained in:
2025-08-10 01:35:35 +02:00
parent 8467f67090
commit 4098d192af
31 changed files with 1347 additions and 2 deletions

46
Autoloads/SaveSystem.cs Normal file
View File

@@ -0,0 +1,46 @@
using Godot;
using Godot.Collections;
namespace Mr.BrickAdventures.Autoloads;
public partial class SaveSystem : Node
{
[Export] public string SavePath { get; set; } = "user://savegame.save";
[Export] public int Version { get; set; } = 1;
//private GM _gm;
public override void _Ready()
{
//_gm = GetNode<GM>("/root/GameManager");
}
public void SaveGame()
{
//TODO: Implement saving logic
}
public bool LoadGame()
{
//TODO: Implement loading logic
if (!FileAccess.FileExists(SavePath))
return false;
using var file = FileAccess.Open(SavePath, FileAccess.ModeFlags.Read);
var saveDataObj = (Dictionary)file.GetVar();
if (saveDataObj.ContainsKey("version") && (int)saveDataObj["version"] != Version)
{
GD.Print($"Save file version mismatch. Expected: {Version}, Found: {saveDataObj["version"]}");
return false;
}
GD.Print("Game state loaded from: ", SavePath);
GD.Print("Player state: ", saveDataObj["player_state"]);
return true;
}
public bool CheckSaveExists() => FileAccess.FileExists(SavePath);
}