wrapper pt1
This commit is contained in:
parent
5abbbc3bf9
commit
219fc97519
6 changed files with 58 additions and 4 deletions
34
rust-pvz-genetics/src/wrapper/godot_genome.rs
Normal file
34
rust-pvz-genetics/src/wrapper/godot_genome.rs
Normal file
|
|
@ -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<Node>
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
impl INode for GodotGenome {
|
||||
fn init(base: Base<Node>) -> Self {
|
||||
Self {
|
||||
from_plant: PlantType::None,
|
||||
genome: Genome::new(),
|
||||
base
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue