From f7209d2164ee40669c171deeb67e6d581b26e9b7 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 19 Feb 2024 16:03:08 +0100 Subject: [PATCH] Added network sub threads --- client/Main.tscn | 6 ++++++ client/enemy/EnemyController.gd | 3 +++ client/network/shared/NetworkNode.gd | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/Main.tscn b/client/Main.tscn index 64cba1f..31798f5 100644 --- a/client/Main.tscn +++ b/client/Main.tscn @@ -46,6 +46,9 @@ ui = NodePath("UI") [node name="Client" type="Node" parent="."] unique_name_in_owner = true process_mode = 3 +process_thread_group = 2 +process_thread_group_order = 0 +process_thread_messages = 0 script = ExtResource("2_8hxcx") [node name="Ping" type="Node" parent="Client"] @@ -98,6 +101,9 @@ script = ExtResource("10_y3len") packet_type = 20 [node name="Statistics" type="Timer" parent="Client"] +process_thread_group = 1 +process_thread_group_order = 0 +process_thread_messages = 0 autostart = true [node name="World" type="Node3D" parent="."] diff --git a/client/enemy/EnemyController.gd b/client/enemy/EnemyController.gd index 11ff008..d445623 100644 --- a/client/enemy/EnemyController.gd +++ b/client/enemy/EnemyController.gd @@ -10,5 +10,8 @@ func _ready(): enemy = owner func _process(_delta): + if !Global.player: + return + var direction := (Global.player.global_position - enemy.global_position).normalized() direction_changed.emit(direction) diff --git a/client/network/shared/NetworkNode.gd b/client/network/shared/NetworkNode.gd index 0803d6c..8a17162 100644 --- a/client/network/shared/NetworkNode.gd +++ b/client/network/shared/NetworkNode.gd @@ -21,5 +21,5 @@ func handle_packet(packet: PackedByteArray): push_warning("Unknown packet type %d" % type) return - handler.handle_packet(packet.slice(1)) + handler.handle_packet.call_deferred(packet.slice(1)) download += packet.size()