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/Client.gd | 4 ++++ Game/Lobby/Server/godotkeep.txt | 0 Game/Network.gd | 29 ++++++++++++++++------------- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 Game/Lobby/Server/godotkeep.txt (limited to 'Game') diff --git a/Game/Client.gd b/Game/Client.gd index 88c59c2..2c3bb69 100644 --- a/Game/Client.gd +++ b/Game/Client.gd @@ -100,6 +100,10 @@ func spawn_unit(unit: Unit, spawn: Spawn, overwrite_target: PathNode = null): current_stage.spawn_unit.rpc(inst_to_dict(unit.to_network_data())) +func update_unit(path: NodePath, data: Unit.NetworkData): + Network.update_unit.rpc(path, inst_to_dict(data)) + + func array_intersect(first, second): var compare = {} for value in first: diff --git a/Game/Lobby/Server/godotkeep.txt b/Game/Lobby/Server/godotkeep.txt new file mode 100644 index 0000000..e69de29 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