summaryrefslogtreecommitdiff
path: root/Game/Network.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Network.gd')
-rw-r--r--Game/Network.gd29
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