summaryrefslogtreecommitdiff
path: root/extractor/map.gd
diff options
context:
space:
mode:
Diffstat (limited to 'extractor/map.gd')
-rw-r--r--extractor/map.gd34
1 files changed, 34 insertions, 0 deletions
diff --git a/extractor/map.gd b/extractor/map.gd
new file mode 100644
index 0000000..c3a9713
--- /dev/null
+++ b/extractor/map.gd
@@ -0,0 +1,34 @@
+extends Node3D
+
+
+func _ready() -> void:
+ # add player
+ var map_server_login_success_packet: MapServerLoginSuccessPacket = Network.map_server.received_packets[MapServerLoginSuccessPacket.HEADER][0]
+ var initial_player_position: Vector2 = map_server_login_success_packet.get_position()
+
+ var player = preload("res://entities/player.tscn").instantiate()
+ player.position = Vector3(initial_player_position.x, 0, initial_player_position.y)
+ add_child(player)
+
+ # listen to packets
+ Network.map_server.received_packet.connect(func(packet: Packet):
+ if packet is ChangeMapPacket:
+ player.position.x = packet.get_position().x
+ player.position.z = packet.get_position().y
+ )
+
+ # play audio
+ for node: AudioStreamPlayer3D in find_children("se_*"):
+ node.play()
+
+ # add HUD TODO: add all HUD as HUD scene
+ var chat_window = preload("res://ui/chat_window.tscn").instantiate()
+ add_child(chat_window)
+
+ # TODO: load map.
+ # TODO: whatever else needs to be loaded after converting from rsw
+
+ var map_loaded_packet := MapLoadedPacket.new()
+ Network.map_server.send(map_loaded_packet)
+
+ # TODO: check which map server packets to send next