52 lines
991 B
Rust
52 lines
991 B
Rust
use gdnative::prelude::*;
|
|
use lazy_static::lazy_static;
|
|
use tokio::sync::RwLock;
|
|
|
|
mod saves;
|
|
mod terrain;
|
|
mod world;
|
|
|
|
lazy_static! {
|
|
static ref WORLD: RwLock<Vec<Vec<Vec<u8>>>> = RwLock::new(vec![vec![vec![]]]);
|
|
}
|
|
|
|
#[derive(NativeClass)]
|
|
#[inherit(Node)]
|
|
pub struct StateServer {
|
|
#[property]
|
|
a: u64,
|
|
}
|
|
|
|
#[methods]
|
|
impl StateServer {
|
|
fn new(_owner: &Node) -> Self {
|
|
StateServer { a: 14 }
|
|
}
|
|
|
|
#[export]
|
|
fn load_from_file(&self, _owner: &Node, file: GodotString) {
|
|
saves::load(&file.to_string());
|
|
}
|
|
|
|
#[export]
|
|
fn save_from_file(&self, _owner: &Node, file: GodotString) {
|
|
saves::save(&file.to_string());
|
|
}
|
|
|
|
#[export]
|
|
fn _ready(&self, _owner: &Node) {
|
|
godot_print!("hello!")
|
|
}
|
|
|
|
#[export]
|
|
fn foo(&self, _owner: &Node) {
|
|
godot_print!("bar")
|
|
}
|
|
|
|
#[export]
|
|
fn generate_world(&self, _owner: &Node){
|
|
let new_world = world::World::new(3,3,3);
|
|
new_world.generate();
|
|
}
|
|
}
|