The_Dark_Side_of_Earth/vines_petals/bud.gd

24 lines
814 B
GDScript3
Raw Normal View History

2025-10-03 16:36:28 +02:00
class_name Bud extends VineNode
signal opened
func _on_opened():
$AnimatedSprite2D.play("open")
2025-10-03 16:36:28 +02:00
opened.emit()
spread()
await $AnimatedSprite2D.animation_finished
queue_free()
2025-10-03 16:36:28 +02:00
func spread():
for dir in [Vector2.UP, Vector2.DOWN, Vector2.RIGHT, Vector2.LEFT]:
if not vine.vine_locations.has(location + dir):
vine.vine_locations.append(location + dir)
grow_to_next_bud(dir)
func grow_to_next_bud(dir):
var target_offset = Vector2(randf_range(60, 240), randf_range(60, 240))
var pos1 = grid.get_world_position(location, offset)
var pos2 = grid.get_world_position(location + dir, target_offset)
var num_seg = floor((pos1-pos2).length() / 96)
var path = "res://vines_petals/vine_active_green.png"
await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, path, true)