refactor: Consolidate skill component logic into SkillComponentBase and update manager access to singletons.

This commit is contained in:
2026-01-31 17:35:27 +01:00
parent 425fa5b940
commit 288f0b1916
27 changed files with 212 additions and 179 deletions

View File

@@ -18,6 +18,8 @@ public partial class SkillManager : Node
public Dictionary ActiveComponents { get; private set; } = new();
public static SkillManager Instance { get; private set; }
[Signal]
public delegate void ActiveThrowSkillChangedEventHandler(BrickThrowComponent throwComponent);
[Signal]
@@ -25,9 +27,15 @@ public partial class SkillManager : Node
public override void _Ready()
{
Instance = this;
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
}
public override void _ExitTree()
{
if (Instance == this) Instance = null;
}
/// <summary>
/// Called by the PlayerController from its _Ready method to register itself with the manager.
/// </summary>
@@ -143,7 +151,6 @@ public partial class SkillManager : Node
{
if (s.Name == skillName)
{
s.IsActive = false;
break;
}
}
@@ -188,12 +195,16 @@ public partial class SkillManager : Node
return null;
}
public bool IsSkillActive(SkillData skill)
{
return skill != null && ActiveComponents.ContainsKey(skill.Name);
}
public void ActivateSkill(SkillData skill)
{
if (!ActiveComponents.ContainsKey(skill.Name))
{
AddSkill(skill);
skill.IsActive = true;
}
}
@@ -202,7 +213,6 @@ public partial class SkillManager : Node
if (ActiveComponents.ContainsKey(skill.Name))
{
RemoveSkill(skill.Name);
skill.IsActive = false;
}
}