diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-19 15:24:50 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-19 15:24:50 +0100 |
commit | 72863ffa31e27f4c6be862d80472cfb897fccaea (patch) | |
tree | ce04be8d77b10c797c8ff854c8ff1a219eb1af46 /Towers/Tower.gd | |
parent | 63d2a59042fb9d90a586ad85d8364de7c38aea8e (diff) |
Diffstat (limited to 'Towers/Tower.gd')
-rw-r--r-- | Towers/Tower.gd | 21 |
1 files changed, 12 insertions, 9 deletions
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() |