extends HBoxContainer
## Does a funky lil bump when you collect tha grunk

const COUNTER_BUMP_RATE := 0.3

@onready var counter: Label = %Counter


func _ready() -> void:
	Game.manager.grunk_collected.connect(on_grunk_collected)
	counter.pivot_offset = Vector2(0, counter.size.y)


func on_grunk_collected(delta: float) -> void:
	counter.text = str(int(Game.manager.grunk_tank))
	counter.scale = Vector2.ONE + Vector2.ONE * clampf(delta / 128.0, 0.1, 1.0)


func _process(_delta: float) -> void:
	counter.scale = counter.scale.lerp(Vector2.ONE, COUNTER_BUMP_RATE)
