refactor: Replace hardcoded node paths with constants and remove ScoreComponent.

This commit is contained in:
2026-01-31 15:35:04 +01:00
parent 62bdf1ba39
commit b62478bbea
27 changed files with 183 additions and 202 deletions

View File

@@ -1,5 +1,6 @@
using Godot;
using Godot.Collections;
using Mr.BrickAdventures;
using Mr.BrickAdventures.scripts.Resources;
namespace Mr.BrickAdventures.Autoloads;
@@ -13,7 +14,7 @@ public partial class SaveSystem : Node
public override void _Ready()
{
_gameManager = GetNode<GameManager>("/root/GameManager");
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
}
public void SaveGame()
@@ -46,16 +47,16 @@ public partial class SaveSystem : Node
GD.Print("Game state loaded from: ", SavePath);
GD.Print("Player state: ", saveDataObj["player_state"]);
_gameManager.PlayerState = (Dictionary)saveDataObj["player_state"];
var skills = new Array<SkillData>();
foreach (var skill in (Array<SkillData>)_gameManager.PlayerState["unlocked_skills"])
{
skills.Add(skill);
}
_gameManager.UnlockSkills(skills);
return true;
}
public bool CheckSaveExists() => FileAccess.FileExists(SavePath);
}