mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
fuck around with native script
This commit is contained in:
parent
c8046a6e85
commit
3317db5211
8 changed files with 115 additions and 9 deletions
|
@ -10,3 +10,7 @@ crate-type = ["cdylib"]
|
|||
|
||||
[dependencies]
|
||||
gdnative = "0.10"
|
||||
tokio = {version = "1.18.0", features = ["sync"]}
|
||||
lazy_static = "1.4.0"
|
||||
strum = "0.24.0"
|
||||
strum_macros = "0.24"
|
||||
|
|
44
routes-native/\
Normal file
44
routes-native/\
Normal file
|
@ -0,0 +1,44 @@
|
|||
use gdnative::{export::hint::EnumHint, prelude::*};
|
||||
use lazy_static::lazy_static;
|
||||
use std::{string::ToString, vec};
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::{Display, EnumIter};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
lazy_static! {
|
||||
// static ref STATE: RwLock<Vector3> = RwLock::new(Vector3::new(1.0, 2.0, 3.0));
|
||||
}
|
||||
|
||||
#[derive(Debug, EnumIter, Display, FromVariant, ToVariant)]
|
||||
enum Terrain {
|
||||
Earth,
|
||||
Rock,
|
||||
Sand,
|
||||
Water,
|
||||
Air,
|
||||
}
|
||||
|
||||
#[derive(NativeClass)]
|
||||
#[inherit(Node)]
|
||||
pub struct StateServer;
|
||||
|
||||
#[methods]
|
||||
impl StateServer {
|
||||
fn new(_owner: &Node) -> Self {
|
||||
StateServer
|
||||
}
|
||||
|
||||
#[export]
|
||||
fn _ready(&self, _owner: &Node) {
|
||||
// godot_print!("hello, state")
|
||||
}
|
||||
|
||||
#[export]
|
||||
fn terrain_types(&self, _owner: &Node) -> EnumHint{
|
||||
let mut hints = vec![];
|
||||
for terrain in Terrain::iter() {
|
||||
hints.push(terrain.to_string());
|
||||
}
|
||||
EnumHint::new(hints)
|
||||
}
|
||||
}
|
|
@ -1,18 +1,46 @@
|
|||
use gdnative::prelude::*;
|
||||
use gdnative::{export::hint::EnumHint, prelude::*};
|
||||
use lazy_static::lazy_static;
|
||||
use std::{string::ToString, vec};
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::{Display, EnumIter};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
lazy_static! {
|
||||
// static ref STATE: RwLock<Vector3> = RwLock::new(Vector3::new(1.0, 2.0, 3.0));
|
||||
}
|
||||
|
||||
#[derive(Debug, EnumIter, Display, FromVariant, ToVariant)]
|
||||
enum Terrain {
|
||||
Earth,
|
||||
Rock,
|
||||
Sand,
|
||||
Water,
|
||||
Air,
|
||||
}
|
||||
|
||||
#[derive(NativeClass)]
|
||||
#[inherit(Node)]
|
||||
pub struct StateServer;
|
||||
pub struct StateServer {
|
||||
#[property]
|
||||
a: u8,
|
||||
}
|
||||
|
||||
#[methods]
|
||||
impl StateServer {
|
||||
fn new(_owner: &Node) -> Self {
|
||||
StateServer
|
||||
StateServer {
|
||||
a: 9,
|
||||
}
|
||||
}
|
||||
|
||||
#[export]
|
||||
fn _ready(&self, _owner: &Node) {
|
||||
godot_print!("hello, state")
|
||||
godot_print!("hello, uwu")
|
||||
}
|
||||
|
||||
|
||||
#[export]
|
||||
fn foo(&self, _owner: &Node) {
|
||||
godot_print!("bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue