48 lines
1.6 KiB
GDScript
48 lines
1.6 KiB
GDScript
extends Node
|
|
|
|
@export var n_plants_to_generate: int
|
|
@export var space_between_plants: int
|
|
@export var base_mutations: Array[PlantMutation]
|
|
@export var all_mutations: Array[PlantMutation]
|
|
@export var max_n_mutations := 2
|
|
# @export var base_parts: Array[PackedScene]
|
|
# @export var leaves_parts: Array[PackedScene]
|
|
# @export var branches_parts: Array[PackedScene]
|
|
# @export var flowers_parts: Array[PackedScene]
|
|
|
|
func _ready():
|
|
generate_plants();
|
|
|
|
func generate_plants():
|
|
var fail_safe := 0;
|
|
for i in n_plants_to_generate:
|
|
|
|
|
|
# func populate_part(parent: PlantPart, parent_node: Node2D, depth := 1):
|
|
# if parent.attaches.size() == 0:
|
|
# return
|
|
|
|
# if depth >= max_depth:
|
|
# return
|
|
|
|
# var n_sub_parts: int = randi() % parent.attaches.size();
|
|
# var available_parent_attaches: Array = range(parent.attaches.size());
|
|
# for i in n_sub_parts:
|
|
# var attach_ind_ind: int = randi() % available_parent_attaches.size();
|
|
# var parent_attach_ind: int = available_parent_attaches[attach_ind_ind];
|
|
# available_parent_attaches.pop_at(attach_ind_ind);
|
|
# var attach := parent.attaches[parent_attach_ind];
|
|
|
|
# var next_packed_scene: PackedScene;
|
|
# if parent.type == PlantPart.PartType.BASE_PART:
|
|
# next_packed_scene =
|
|
# elif parent.type == PlantPart.PartType.BRANCH_PART:
|
|
# var selected_root: Vector2 = next_part.roots.pick_random().position;
|
|
|
|
# var sprite := Sprite2D.new();
|
|
# sprite.texture = next_part.texture;
|
|
# sprite.position = attach.position - selected_root;
|
|
# parent_node.add_child(sprite);
|
|
|
|
# populate_part(next_part, sprite, depth + 1);
|