30 lines
835 B
GDScript
30 lines
835 B
GDScript
extends Node
|
|
|
|
|
|
func start_game() -> void:
|
|
print("starting game")
|
|
get_tree().change_scene_to_file("res://scenes/worlds/yukotsukis_room/yukotsukis_room.tscn")
|
|
EventBus.game_started.emit()
|
|
|
|
|
|
func goto_room(previous_room: Room, waypoint: RemoteWaypoint, config: RoomConfig = null) -> void:
|
|
print("changing rooms")
|
|
|
|
# for signal
|
|
var prev_name: StringName
|
|
var next_name: StringName
|
|
|
|
prev_name = previous_room.name
|
|
|
|
# wait until previous room is freed
|
|
await previous_room.tree_exited
|
|
|
|
# instantiate next room and set room variables
|
|
var next_room: Room = waypoint.to_scene.instantiate()
|
|
next_name = next_room.name
|
|
next_room.initial_spawn = waypoint.spawn_coordinates
|
|
if config: next_room.config = config
|
|
get_tree().root.add_child(next_room)
|
|
|
|
# notify event bus
|
|
EventBus.room_changed.emit(prev_name, next_name, waypoint)
|