From c8f674ac6fa0914d9e448d2929f2385cdad80d60 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 5 Nov 2024 11:34:49 +0100 Subject: next commit --- Game/Network.gd | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'Game/Network.gd') diff --git a/Game/Network.gd b/Game/Network.gd index be5bb20..355f7a4 100644 --- a/Game/Network.gd +++ b/Game/Network.gd @@ -133,25 +133,28 @@ func update_tower(remote_tower_node_path: NodePath, remote_data: Dictionary): @rpc("any_peer") -func remove_unit(remote_unit_node_path): +func remove_unit(remote_unit_node_path: NodePath): var unit = get_tree().current_scene.get_node_or_null(remote_unit_node_path) if unit: unit.queue_free() @rpc("any_peer") -func update_unit(remote_unit_node_path, data): +func update_unit(remote_unit_node_path: NodePath, remote_data: Dictionary): + var data: Unit.NetworkData = dict_to_inst(remote_data) var unit: Unit = get_tree().current_scene.get_node_or_null(remote_unit_node_path) + if unit: - if "hp" in data: - unit.hp = data.hp - if "position" in data: - unit.position = data.position - if "sprite" in data: - unit.get_node("Sprite2D").self_modulate = data.sprite.self_modulate - if "current_path" in data: - unit.current_path = data.current_path - unit.line.points = PackedVector2Array(data.current_path) - if "current_path_idx" in data: - unit.current_path_idx = data.current_path_idx + unit.update_with_network_data(data) + #if "hp" in data: + #unit.hp = data.hp + #if "position" in data: + #unit.position = data.position + #if "sprite" in data: + #unit.get_node("Sprite2D").self_modulate = data.sprite.self_modulate + #if "current_path" in data: + #unit.current_path = data.current_path + #unit.line.points = PackedVector2Array(data.current_path) + #if "current_path_idx" in data: + #unit.current_path_idx = data.current_path_idx -- cgit v1.2.3