gfolf2/src/ui/world_ui.gd

27 lines
591 B
GDScript3
Raw Normal View History

2024-11-17 12:35:28 -07:00
class_name WorldUI extends Control
## Container & accessor for the world UI.
2024-11-19 15:44:47 -07:00
@export var pause_scene := preload("res://src/ui/menus/pause_menu/pause_menu.tscn")
2024-11-19 11:51:05 -07:00
@onready var hud_container: Control = %HUDContainer
2024-11-19 15:44:47 -07:00
func _unhandled_key_input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
pause()
2024-11-19 11:51:05 -07:00
func add_player_hud(hud: ShotHUD) -> void:
hud_container.add_child(hud)
2024-11-19 15:44:47 -07:00
func pause() -> void:
var menu := pause_scene.instantiate()
add_child(menu)
menu.tree_exiting.connect(_unpause)
get_tree().paused = true
func _unpause() -> void:
get_tree().paused = false