oxide_engine_api/
script.rs1use crate::context::Context;
2
3#[macro_export]
5macro_rules! create_script {
6 ($struct_name:ident { $($field:ident: $value:expr),* $(,)? }) => {
7 #[unsafe(no_mangle)]
8 pub extern "Rust" fn create_script() -> Box<dyn Script> {
9 Box::new($struct_name {
10 $($field: $value),*
11 })
12 }
13 };
14}
15
16pub trait Script: Send {
18 fn init(&mut self, ctx: &impl Context) {
20 ctx.log("Script Init");
21 }
22 fn ready(&mut self, ctx: &impl Context) {
24 ctx.log("Script Ready");
25 }
26 fn update(&mut self, ctx: &impl Context, delta: f32) {
28 ctx.log("Script Update");
29 println!("{}",delta);
30 }
31 fn event(&mut self, ctx: &impl Context, event: crate::Event) {
33 ctx.log("Script Event");
34 }
35}