Gimme a scream Corey

This commit is contained in:
rendo 2026-04-02 12:54:42 +05:00
commit 33eb6187a0
7 changed files with 66 additions and 18 deletions

View file

@ -2,6 +2,7 @@ use godot::prelude::*;
use godot::classes::{Node,INode};
use crate::genetics::genome::Genome;
use crate::genetics::plant_templates::{cherry_bomb_template, peashooter_template, sunflower_template};
#[derive(GodotConvert, Var, Export, Default, Clone)]
#[godot(via = GString)]
@ -10,6 +11,7 @@ pub enum PlantType {
None,
Peashooter,
Sunflower,
CherryBomb,
}
#[derive(GodotClass)]
@ -17,7 +19,7 @@ pub enum PlantType {
pub struct GodotGenome {
#[export]
from_plant: PlantType,
genome: Genome,
genome: Option<Genome>,
base: Base<Node>
}
@ -26,9 +28,23 @@ impl INode for GodotGenome {
fn init(base: Base<Node>) -> Self {
Self {
from_plant: PlantType::None,
genome: Genome::new(),
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(cherry_bomb_template()),
_ => None,
}
}
}
impl GodotGenome {
pub fn get_genome(&self) -> Option<Genome> {
self.genome.clone()
}
}