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>) -> Option<DefaultKey>;
26
27 fn create_child(&self, object_name: String, script_path: Option<PathBuf>, parent_object: DefaultKey) -> Option<DefaultKey>;
30
31 fn remove(&self, object_id: DefaultKey) -> bool;
33
34 fn set_script(&self, object_id: DefaultKey, script_path: PathBuf) -> bool;
36
37 fn remove_script(&self, object_id: DefaultKey) -> bool;
39
40 fn move_to_parent(&self, child_object_id: DefaultKey, new_parent_id: DefaultKey) -> bool;
42
43 fn get_by_id(&self, object_id: DefaultKey) -> Option<DefaultKey>;
44
45 fn get_by_name(&self, object_name: PathBuf) -> Option<DefaultKey>;
46}