Refactor UI components to inherit from Control and update node paths for consistency

This commit is contained in:
2025-08-26 16:20:01 +02:00
parent 1d4948e5b4
commit ca0d21e40a
84 changed files with 767 additions and 884 deletions

View File

@@ -20,10 +20,12 @@ public partial class ScoreComponent : Node
return;
}
var coins = GetTree().GetNodesInGroup("Coins");
var coins = GetTree().GetNodesInGroup("coins");
GD.Print($"Found {coins.Count} coins in the scene.");
foreach (var coin in coins)
{
var c = coin.GetNodeOrNull<CollectableComponent>("CollectableComponent");
GD.Print(c == null ? "CollectableComponent not found on coin." : "CollectableComponent found on coin.");
if (c != null)
{
c.Collected += OnCollected;
@@ -31,6 +33,17 @@ public partial class ScoreComponent : Node
}
}
public override void _Process(double delta)
{
GetCoinsInScene();
}
private void GetCoinsInScene()
{
var coins = GetTree().GetNodesInGroup("Coins");
GD.Print($"Found {coins.Count} coins in the scene.");
}
private void OnCollected(float amount, CollectableType type, Node2D body)
{
if (type != CollectableType.Coin) return;