branches and one texture
This commit is contained in:
@@ -1,47 +1,18 @@
|
||||
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]
|
||||
@export var space_between_plants: float
|
||||
|
||||
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);
|
||||
print("Generate plant")
|
||||
var plant_position := Vector2(i * space_between_plants, 0)
|
||||
var plant_data: PlantData = PlantData.new(plant_position)
|
||||
plant_data.day = plant_data.get_growing_time()
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
var plant: Plant = Plant.new(plant_data)
|
||||
add_child(plant)
|
||||
plant.global_position = plant_position
|
||||
|
||||
Reference in New Issue
Block a user