1use std::path::PathBuf;
2use slotmap::DefaultKey;
3
4pub trait Script: Send {
6 fn init(&mut self, ctx: &dyn Context);
8 fn update(&mut self, ctx: &dyn Context, delta: f32);
10}
11
12pub trait Context {
14 fn objects(&self) -> &dyn ObjectServer;
16
17 fn log(&self, msg: &str);
19}
20
21pub trait ObjectServer {
23 fn create_root(&self, object_name: String, script_path: Option<PathBuf>) -> DefaultKey;
25
26 fn create_child(&self, object_name: String, script_path: Option<PathBuf>, parent_object: DefaultKey) -> Option<DefaultKey>;
29
30 fn remove(&self, object_id: DefaultKey);
32
33 fn set_script(&self, object_id: DefaultKey, script_path: PathBuf) -> bool;
35
36 fn remove_script(&self, object_id: DefaultKey) -> bool;
38
39 fn move_to_parent(&self, childe_object_id: DefaultKey, new_parent_id: DefaultKey) -> bool;
41}