class_name Bud extends VineNode signal opened var img_path @export var depth : int # Triggers when a bud is hit. Spreads the vine, then removes the bud func _on_opened(): $AnimatedSprite2D.play("open") opened.emit() spread() await $AnimatedSprite2D.animation_finished queue_free() # Spread in all directions where the given vine is not yet present func spread(): for dir in [Vector2.UP, Vector2.DOWN, Vector2.RIGHT, Vector2.LEFT]: if not vine.vine_locations.has(Global.vec_mod(location + dir, Grid.num_collumns)): grow_to_next_bud(dir) # Grow a vine func grow_to_next_bud(dir): var target_offset = vine.random_offset() var target = Global.vec_mod(location + dir, Grid.num_collumns) var pos1 = Grid.get_world_position(location, offset) var pos2 = Grid.get_world_position(target, target_offset) var num_seg = floor((pos1-pos2).length() / 96) await vine.grow_vine_sequence(location, offset, target, target_offset, num_seg, depth, true, false)