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