grunk/src/world/world.gd
Rob Kelly e2ca0cb1a2
All checks were successful
linting & formatting / build (push) Successful in 12s
itch.io publish action / build (linux64, x86_64) (push) Successful in 2m35s
itch.io publish action / build (osx, app) (push) Successful in 2m37s
itch.io publish action / build (win64, exe) (push) Successful in 2m40s
Ported settings menu from GFOLF
2025-03-22 19:16:52 -06:00

39 lines
823 B
GDScript

class_name World extends Node
## Access and flow control for the game world.
@export var initial_level: PackedScene
@export var pause_scene: PackedScene
@onready var level_root: Node3D = %LevelRoot
@onready var ui_root: Control = %UIRoot
static var instance: World
func _ready() -> void:
World.instance = self
load_level(initial_level)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
pause()
func pause() -> void:
get_tree().paused = true
var pause_menu: Control = pause_scene.instantiate()
ui_root.add_child(pause_menu)
pause_menu.tree_exiting.connect(unpause)
func unpause() -> void:
get_tree().paused = false
func load_level(level: PackedScene) -> void:
for c: Node in level_root.get_children():
c.queue_free()
level_root.add_child(level.instantiate())