oxide_engine_api/
lib.rs

1use std::path::PathBuf;
2use slotmap::DefaultKey;
3
4// === ФУНКЦИИ СКРИПТА ===
5pub trait Script: Send {
6	/// Выполняется один раз во время загрузки файла библиотеки
7	fn init(&mut self, ctx: &dyn Context);
8	/// Выполняется каждый main loop
9	fn update(&mut self, ctx: &dyn Context, delta: f32);
10}
11
12// === МЕТОДЫ КОНТЕКСТА ===
13pub trait Context {
14	/// Доступ к подсистеме объектов
15	fn objects(&self) -> &dyn ObjectServer;
16	
17	/// Логирование (можно вынести в отдельную подсистему позже)
18	fn log(&self, msg: &str);
19}
20
21// === ПОДСИСТЕМА ОБЪЕКТОВ ===
22pub trait ObjectServer {
23	/// Создаёт корневой объект (без родителя)
24	fn create_root(&self, object_name: String, script_path: Option<PathBuf>) -> DefaultKey;
25
26	/// Создаёт дочерний объект
27	/// Возвращает `None`, если родитель не существует
28	fn create_child(&self, object_name: String, script_path: Option<PathBuf>, parent_object: DefaultKey) -> Option<DefaultKey>;
29
30	/// Удаляет объект и всё его поддерево
31	fn remove(&self, object_id: DefaultKey);
32
33	///
34	fn set_script(&self, object_id: DefaultKey, script_path: PathBuf) -> bool;
35
36	///
37	fn remove_script(&self, object_id: DefaultKey) -> bool;
38
39	///
40	fn move_to_parent(&self, childe_object_id: DefaultKey, new_parent_id: DefaultKey) -> bool;
41}