1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use event::Event;
pub use lotus_bindgen_macros::lotus_bindgen;

use object::{Object, RawObject};
use serde::{de::DeserializeOwned, Serialize};

pub mod event;
pub(crate) mod ffi;
pub mod log;
pub mod macros;
pub(crate) mod object;
pub mod settings;
pub mod var;

pub trait Script {
    fn init(&mut self);
    fn tick(&mut self);
    fn event(&mut self, event: Event);
}

pub fn delta() -> f32 {
    todo!()
}

pub fn is_rc() -> bool {
    todo!()
}

pub fn from_serialized_heap_ptr<T: DeserializeOwned>(ptr: i32) -> T {
    let raw = RawObject::from_heap_ptr(ptr);
    let obj = raw.to_object();
    obj.value
}

pub fn to_serialized_heap_ptr<T: Serialize>(value: T) -> i32 {
    let obj = Object::new(value);
    let raw = obj.to_raw();

    raw.to_heap_ptr() as i32
}