Initial project sync
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class_name EnergyBar
|
||||
extends ProgressBar
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
show_percentage = false
|
||||
_event_bus().connect("player_energy_changed", refresh)
|
||||
|
||||
|
||||
func refresh(current: float, maximum: float) -> void:
|
||||
max_value = maxf(0.01, maximum)
|
||||
value = clampf(current, 0.0, maximum)
|
||||
|
||||
|
||||
func _event_bus() -> Node:
|
||||
var root := get_tree().root
|
||||
var bus := root.get_node_or_null("EventBus")
|
||||
if bus == null:
|
||||
bus = load("res://autoload/event_bus.gd").new()
|
||||
bus.name = "EventBus"
|
||||
root.add_child(bus)
|
||||
return bus
|
||||
Reference in New Issue
Block a user