extends StaticBody3D class_name TheCube @export var max_health : int = 50 var health : int = max_health : set(value): health = value EventBus.cube_integrity_changed.emit(health, max_health) if health <= 0: death() @export var money : int = 100 : set(value): money = value EventBus.money_changed.emit(money) func _ready() -> void: call_deferred("display_money_on_first_call") EventBus.money_received.connect(_on_EventBus_money_received) EventBus.money_spent.connect(_on_EventBus_money_spent) EventBus.player_has_won.connect(_on_EventBus_player_has_won) #Because I can't connect properly on first frame and send money info func display_money_on_first_call() -> void: EventBus.money_changed.emit(money) func take_damage(damage : int) -> void: health -= damage func win(): get_tree().change_scene_to_file("res://UI/win_screen.tscn") func death(): get_tree().change_scene_to_file("res://UI/defeat_screen.tscn") func _on_EventBus_money_received(money_received : int): money += money_received func _on_EventBus_money_spent(money_spent : int): money -= money_spent func _on_EventBus_player_has_won(): win()