35 lines
896 B
GDScript
35 lines
896 B
GDScript
extends Node
|
|
|
|
signal level_load_started
|
|
signal level_loaded
|
|
signal Tilemap_boudns_change(bounds: Array[Vector2])
|
|
var current_tilemap_bounds: Array[Vector2]
|
|
var target_transition: String
|
|
var position_offset: Vector2
|
|
|
|
func _ready() -> void:
|
|
await get_tree().process_frame
|
|
level_loaded.emit()
|
|
|
|
func change_tilemap_bounds(bounds: Array[Vector2]) -> void:
|
|
current_tilemap_bounds = bounds
|
|
Tilemap_boudns_change.emit(bounds)
|
|
|
|
func load_new_level(
|
|
level_path: String,
|
|
new_target_transition: String,
|
|
new_position_offset: Vector2
|
|
) -> void:
|
|
get_tree().paused = true
|
|
target_transition = new_target_transition
|
|
position_offset = new_position_offset
|
|
var tree = get_tree()
|
|
await SceneTransition.fade_out()
|
|
level_load_started.emit()
|
|
await SceneTransition.fade_in()
|
|
tree.change_scene_to_file(level_path)
|
|
await tree.process_frame
|
|
tree.paused = false
|
|
await tree.process_frame
|
|
level_loaded.emit()
|