End of lesson 28.

This commit is contained in:
2025-04-18 13:42:15 -03:00
parent 6576c0155c
commit 75cbdf40b2
8 changed files with 107 additions and 12 deletions

View File

@@ -1,6 +1,9 @@
extends Node
var map:Map
var loading: bool
var newSpawnpoint
var newFacing
func _ready():
CommandDispatcher.LOAD_MAP.connect(loadMap)
@@ -8,21 +11,31 @@ func _ready():
func loadMap(newMapPath, spawnpoint, facing):
var newMap:Map
CommandDispatcher.PAUSE_PROCESSOR.emit()
loading = true
if (map != null):
map.queue_free()
map = load(newMapPath).instantiate()
add_child(map)
map.get_node("Entities").add_child(map.spawnPlayerAtPosition(spawnpoint, facing))
GameManager.currentMap = newMapPath
CommandDispatcher.WAIT_FOR_COMMAND.emit()
ResourceLoader.load_threaded_request(GameManager.currentMap)
newSpawnpoint = spawnpoint
newFacing = facing
#map = load(newMapPath).instantiate()
#
#add_child(map)
#
#map.get_node("Entities").add_child(map.spawnPlayerAtPosition(spawnpoint, facing))
#
#GameManager.currentMap = newMapPath
#
#CommandDispatcher.WAIT_FOR_COMMAND.emit()
func _unhandled_key_input(event):
@@ -42,3 +55,18 @@ func _unhandled_key_input(event):
if (direction != null):
CommandDispatcher.PROCESS_COMMAND.emit(MoveCommand.new(direction))
func _process(delta: float) -> void:
if(loading):
if(ResourceLoader.load_threaded_get_status(GameManager.currentMap) == ResourceLoader.THREAD_LOAD_LOADED):
loading = false
map = ResourceLoader.load_threaded_get(GameManager.currentMap).instantiate()
call_deferred("add_child", map)
map.spawnPlayerAtPosition(newSpawnpoint, newSpawnpoint)
CommandDispatcher.LOAD_COMPLETE.emit()
CommandDispatcher.WAIT_FOR_COMMAND.emit()

View File

@@ -1 +1,5 @@
extends Mob
class_name Player
@export var camera:Camera2D