Big rework

This commit is contained in:
Rendo 2026-04-04 01:02:52 +05:00
commit ba78ce8502
8 changed files with 67 additions and 53 deletions

View file

@ -7,22 +7,55 @@ pub mod gene_source;
pub use gene_types::GeneType;
pub use gene_source::GeneSource;
pub use gene_place::GenePlace;
use godot::builtin::Vector2;
#[derive(PartialEq,Eq,Clone)]
pub struct Gene {
pub plant_source: GeneSource,
pub place: GenePlace,
pub kind: GeneType
pub kind: GeneType,
pub sprite: Option<String>,
pub get_child_position: fn(GeneType) -> Vector2
}
impl Gene {
pub fn new(plant_source: GeneSource, place: GenePlace, kind: GeneType) -> Self {
pub fn invisible(plant_source: GeneSource,place: GenePlace,kind: GeneType) -> Self {
Self {
plant_source,
place,
kind,
sprite: None,
get_child_position: |_| Vector2::ZERO,
}
}
pub fn structural(plant_source: GeneSource, place: GenePlace, kind: GeneType, get_child_position: fn(GeneType) -> Vector2) -> Self {
Self {
plant_source,
place,
kind,
sprite: None,
get_child_position,
}
}
pub fn visible(plant_source: GeneSource, place: GenePlace, kind: GeneType, sprite: String) -> Self {
Self {
plant_source,
place,
kind,
sprite: Some(sprite),
get_child_position: |_| Vector2::ZERO,
}
}
pub fn new(plant_source: GeneSource, place: GenePlace, kind: GeneType, sprite: String, get_child_position: fn(GeneType) -> Vector2) -> Self {
Self {
plant_source,
place,
kind,
sprite: Some(sprite),
get_child_position,
}
}
}