mirror of
https://github.com/kodzukye/omens-ascent.git
synced 2026-08-10 13:23:10 +00:00
38 lines
1.1 KiB
GDScript
38 lines
1.1 KiB
GDScript
class_name Scene_Manager
|
|
extends Node
|
|
|
|
signal scene_changed(scene_path: String)
|
|
|
|
const _LEVEL_MUSIC: Dictionary = {
|
|
"res://scenes/levels/act1_section1.tscn": "act1_section1",
|
|
"res://scenes/levels/act2_floor1.tscn": "act2_floor1",
|
|
"res://scenes/levels/boss_arena.tscn": "boss_arena"
|
|
}
|
|
|
|
const _PLAYER_SPAWN: Dictionary = {
|
|
"res://scenes/levels/act1_section1.tscn": Vector2(301.0, -189.0),
|
|
"res://scenes/levels/act2_floor1.tscn": Vector2(50.0, -130),
|
|
"res://scenes/levels/boss_arena.tscn": Vector2(48.0, -192.0)
|
|
}
|
|
|
|
func change_scene(scene_path: String) -> void:
|
|
var error: Error = get_tree().change_scene_to_file(scene_path)
|
|
if error != OK:
|
|
return
|
|
|
|
if _PLAYER_SPAWN.has(scene_path):
|
|
EventBus.last_checkpoint_position = _PLAYER_SPAWN[scene_path]
|
|
EventBus.has_checkpoint = true
|
|
AudioManager.play_ambiance(_LEVEL_MUSIC[scene_path])
|
|
|
|
scene_changed.emit(scene_path)
|
|
|
|
func reload_current_scene() -> void:
|
|
var scene_file_path: String = get_tree().current_scene.scene_file_path
|
|
if scene_file_path == "":
|
|
return
|
|
change_scene(scene_file_path)
|
|
|
|
func quit_game() -> void:
|
|
get_tree().quit()
|