diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-05 11:34:49 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-05 11:34:49 +0100 |
commit | c8f674ac6fa0914d9e448d2929f2385cdad80d60 (patch) | |
tree | a913454c42bb520aa644f4e2dcf0d42ba11c83de /Game/Network.gd | |
parent | 84365b6f901a9c0251a9f724a8d9f81a3787e97d (diff) |
next commit
Diffstat (limited to 'Game/Network.gd')
-rw-r--r-- | Game/Network.gd | 29 |
1 files changed, 16 insertions, 13 deletions
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 |