-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.gd
More file actions
46 lines (38 loc) · 1.38 KB
/
main.gd
File metadata and controls
46 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
extends Node
var world_scene = "res://Maps/world.tscn"
var loading_screen_scene = preload("res://UI/LoadingScreen/loading_screen.tscn")
var current_world = null
var loading_screen = null
func _ready():
# Connect to SignalBus signals
SignalBus.connect("start_game", Callable(self, "_on_start_game"))
SignalBus.connect("go_to_main_menu", Callable(self, "_on_go_to_main_menu"))
#SignalBus.connect("show_pause_menu", Callable(self, "_on_show_pause_menu"))
#SignalBus.connect("hide_pause_menu", Callable(self, "_on_hide_pause_menu"))
# Start with MainMenu visible
$GUI/MainMenu.visible = true
$GUI/PauseMenu.visible = false
func _on_start_game():
# Clean up existing world if any
if current_world:
current_world.queue_free()
current_world = null
# Instantiate and show loading screen
if not loading_screen:
loading_screen = loading_screen_scene.instantiate()
add_child(loading_screen)
loading_screen.connect("world_loaded", Callable(self, "_on_world_loaded"))
loading_screen.show_loading_screen(world_scene)
$GUI/MainMenu.visible = false
func _on_world_loaded(world_instance):
current_world = world_instance
GameManager.set_game_paused(false)
func _on_go_to_main_menu():
# Unload world to free memory
if current_world:
current_world.queue_free()
current_world = null
# Update UI
$GUI/MainMenu.visible = true
$GUI/PauseMenu.visible = false
GameManager.set_game_paused(false)