refactor: Replace hardcoded node paths with constants and remove ScoreComponent.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user