2025-12-11 14:49:31 +00:00
|
|
|
using Godot;
|
|
|
|
|
using Rokojori;
|
|
|
|
|
|
2026-05-25 10:32:41 +00:00
|
|
|
using Rokojori.Extensions;
|
|
|
|
|
|
2025-12-11 14:49:31 +00:00
|
|
|
[Tool, GlobalClass]
|
|
|
|
|
public partial class CollectableCounter : Action
|
|
|
|
|
{
|
|
|
|
|
[Export]
|
|
|
|
|
public Collector collector;
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
public UIText uiText;
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
public CollectableType collectableType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int numCollectables = -1;
|
|
|
|
|
int collected = 0;
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
|
|
|
|
numCollectables = Nodes.AllInScene<Collectable>().Filter( c => c.collectableData.collectableType == collectableType ).Count;
|
|
|
|
|
uiText.locale = LocaleText.Create( collected + "/" + numCollectables );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void _OnTrigger()
|
|
|
|
|
{
|
|
|
|
|
collected ++;
|
|
|
|
|
|
|
|
|
|
uiText.locale = LocaleText.Create( collected + "/" + numCollectables );
|
|
|
|
|
}
|
|
|
|
|
}
|