use godot::prelude::*; use godot::classes::{Node,INode}; use crate::genetics::genome::Genome; use crate::genetics::plants::peashooter::peashooter_template; use crate::genetics::plants::sunflower::sunflower_template; #[derive(GodotConvert, Var, Export, Default, Clone)] #[godot(via = GString)] pub enum PlantType { #[default] // Rust standard attribute, not godot-rust. None, Peashooter, Sunflower, CherryBomb, } #[derive(GodotClass)] #[class(base=Node)] pub struct GodotGenome { #[export] from_plant: PlantType, genome: Option, base: Base } #[godot_api] impl INode for GodotGenome { fn init(base: Base) -> Self { Self { from_plant: PlantType::None, genome: None, base } } fn ready(&mut self) { self.genome = match self.from_plant { PlantType::Peashooter => Some(peashooter_template()), PlantType::Sunflower => Some(sunflower_template()), PlantType::CherryBomb => Some(peashooter_template()), _ => None, } } } impl GodotGenome { pub fn get_genome(&self) -> Option { self.genome.clone() } }