The_Dark_Side_of_Earth/vines_petals/bud.gd

25 lines
810 B
GDScript3
Raw Normal View History

2025-10-03 16:36:28 +02:00
class_name Bud extends VineNode
signal opened
2025-10-03 17:09:51 +02:00
var img_path
2025-10-05 15:01:51 +02:00
@export var depth : int
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(Global.vec_mod(location + dir, Grid.num_collumns)):
2025-10-03 16:36:28 +02:00
grow_to_next_bud(dir)
func grow_to_next_bud(dir):
2025-10-05 15:01:51 +02:00
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)
2025-10-03 16:36:28 +02:00
var num_seg = floor((pos1-pos2).length() / 96)
2025-10-05 15:01:51 +02:00
await vine.grow_vine_sequence(location, offset, target, target_offset, num_seg, depth, true, false)