diff --git a/rust-pvz-genetics/src/genetics/gene/gene_place.rs b/rust-pvz-genetics/src/genetics/gene/gene_place.rs index 6704cab..c1e1123 100644 --- a/rust-pvz-genetics/src/genetics/gene/gene_place.rs +++ b/rust-pvz-genetics/src/genetics/gene/gene_place.rs @@ -6,6 +6,8 @@ pub enum GenePlace { Stem, Head, Face, + Mouth, + Eyes, Leaf, } @@ -17,6 +19,8 @@ impl Display for GenePlace { GenePlace::Head => "Head", GenePlace::Face => "Face", GenePlace::Leaf => "Leaf", + GenePlace::Eyes => "Eyes", + GenePlace::Mouth => "Mouth", }) } } @@ -29,6 +33,8 @@ impl GenePlace { GenePlace::Head => GenePlace::Head, GenePlace::Face => GenePlace::Face, GenePlace::Leaf => GenePlace::Leaf, + GenePlace::Mouth => GenePlace::Face, + GenePlace::Eyes => GenePlace::Face, } } } diff --git a/rust-pvz-genetics/src/genetics/genome.rs b/rust-pvz-genetics/src/genetics/genome.rs index f63b345..ad2c183 100644 --- a/rust-pvz-genetics/src/genetics/genome.rs +++ b/rust-pvz-genetics/src/genetics/genome.rs @@ -2,7 +2,7 @@ use std::fmt::Display; use crate::genetics::gene::Gene; -#[derive(Clone,PartialEq,Eq)] +#[derive(Default,Clone,PartialEq,Eq)] pub struct Genome { pub(crate) graph: Vec<(Gene,Vec)>, } diff --git a/rust-pvz-genetics/src/genetics/plant_templates.rs b/rust-pvz-genetics/src/genetics/plant_templates.rs index f39e0f7..a3ac5ba 100644 --- a/rust-pvz-genetics/src/genetics/plant_templates.rs +++ b/rust-pvz-genetics/src/genetics/plant_templates.rs @@ -6,12 +6,14 @@ pub fn peashooter_template() -> Genome { Gene::new(GeneSource::Peashooter,GenePlace::Stem, GeneType::fill_all()), Gene::new(GeneSource::Peashooter,GenePlace::Head,GeneType::random_distribution()), Gene::new(GeneSource::Peashooter,GenePlace::Leaf,GeneType::modifier(|_|{Flow::empty()})), - Gene::new(GeneSource::Peashooter,GenePlace::Face,GeneType::consumer(|_|{})) + Gene::new(GeneSource::Peashooter,GenePlace::Eyes,GeneType::Structural), + Gene::new(GeneSource::Peashooter,GenePlace::Mouth,GeneType::consumer(|_|{})) ],vec![ (0,1), (1,2), (2,3), - (2,4) + (2,4), + (2,5), ]).unwrap() } @@ -20,11 +22,13 @@ pub fn sunflower_template() -> Genome { Gene::new(GeneSource::Sunflower,GenePlace::Root, GeneType::Structural), Gene::new(GeneSource::Sunflower,GenePlace::Stem, GeneType::Structural), Gene::new(GeneSource::Sunflower,GenePlace::Head, GeneType::modifier(|_|{Flow::empty()})), - Gene::new(GeneSource::Sunflower,GenePlace::Face, GeneType::consumer(|_|{})), + Gene::new(GeneSource::Sunflower,GenePlace::Eyes, GeneType::Structural), + Gene::new(GeneSource::Sunflower,GenePlace::Mouth, GeneType::consumer(|_|{})), ], vec![ (0,1), (1,2), (2,3), + (2,4), ]).unwrap() } diff --git a/rust-pvz-genetics/src/lib.rs b/rust-pvz-genetics/src/lib.rs index 9f8d80d..ad44e82 100644 --- a/rust-pvz-genetics/src/lib.rs +++ b/rust-pvz-genetics/src/lib.rs @@ -1,2 +1,11 @@ +use godot::prelude::*; + pub mod genetics; pub mod wrapper; + +struct PVZGenetics; + +#[gdextension] +unsafe impl ExtensionLibrary for PVZGenetics { + +} diff --git a/rust-pvz-genetics/src/wrapper/godot_genome.rs b/rust-pvz-genetics/src/wrapper/godot_genome.rs new file mode 100644 index 0000000..7cb7604 --- /dev/null +++ b/rust-pvz-genetics/src/wrapper/godot_genome.rs @@ -0,0 +1,34 @@ +use godot::prelude::*; +use godot::classes::{Node,INode}; + +use crate::genetics::genome::Genome; + +#[derive(GodotConvert, Var, Export, Default, Clone)] +#[godot(via = GString)] +pub enum PlantType { + #[default] // Rust standard attribute, not godot-rust. + None, + Peashooter, + Sunflower, +} + +#[derive(GodotClass)] +#[class(base=Node)] +struct GodotGenome { + #[export] + from_plant: PlantType, + genome: Genome, + base: Base +} + +#[godot_api] +impl INode for GodotGenome { + fn init(base: Base) -> Self { + Self { + from_plant: PlantType::None, + genome: Genome::new(), + base + } + } + +} diff --git a/rust-pvz-genetics/src/wrapper/mod.rs b/rust-pvz-genetics/src/wrapper/mod.rs index e69de29..1ea2455 100644 --- a/rust-pvz-genetics/src/wrapper/mod.rs +++ b/rust-pvz-genetics/src/wrapper/mod.rs @@ -0,0 +1 @@ +pub mod godot_genome;