diff options
Diffstat (limited to 'Game')
-rw-r--r-- | Game/Client.gd | 4 | ||||
-rw-r--r-- | Game/Lobby/Server/godotkeep.txt | 0 | ||||
-rw-r--r-- | Game/Network.gd | 29 |
3 files changed, 20 insertions, 13 deletions
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 --- /dev/null +++ b/Game/Lobby/Server/godotkeep.txt 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 |