From 72863ffa31e27f4c6be862d80472cfb897fccaea Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 19 Nov 2024 15:24:50 +0100 Subject: next commit --- Towers/Tower.gd | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Towers/Tower.gd') diff --git a/Towers/Tower.gd b/Towers/Tower.gd index 34e12ae..73b1614 100644 --- a/Towers/Tower.gd +++ b/Towers/Tower.gd @@ -151,12 +151,13 @@ func add_component(component: TowerComponent): func redraw_components(): - var keys = components.keys() - for idx in range(keys.size()): - var key = keys[idx] - var component: TowerComponent = components[key] - var sprite = %ComponentsAnchor.get_node(NodePath(component.id)) - sprite.position.y = (idx + 1) * -16 + pass + #var keys = components.keys() + #for idx in range(keys.size()): + #var key = keys[idx] + #var component: TowerComponent = components[key] + ##var sprite = %ComponentsAnchor.get_node(NodePath(component.id)) + ##sprite.position.y = (idx + 1) * -16 func get_region(): @@ -220,9 +221,11 @@ func to_network_data() -> NetworkData: func update_with_network_data(data: NetworkData): for component_data in data.components: - var component = get_node(component_data.path) as TowerComponent - component.update_with_network_data(dict_to_inst(component_data)) - redraw_components() + var component = get_node_or_null(component_data.path) as TowerComponent + if not component: + add_component(TowerComponent.from_network_data(dict_to_inst(component_data))) + else: + component.update_with_network_data(dict_to_inst(component_data)) static func from_network_data(data: NetworkData) -> Tower: var tower: Tower = preload("res://Towers/Tower.tscn").instantiate() -- cgit v1.2.3