lyra-engine/lyra-ecs/src/system/mod.rs

38 lines
851 B
Rust
Raw Normal View History

2024-01-05 04:55:06 +00:00
use std::ptr::NonNull;
2023-12-04 04:14:27 +00:00
2024-03-03 02:34:20 +00:00
use crate::{World, Access};
2023-12-04 04:14:27 +00:00
2024-03-03 01:20:38 +00:00
mod graph;
pub use graph::*;
2024-03-03 01:20:38 +00:00
mod criteria;
pub use criteria::*;
2024-03-03 01:20:38 +00:00
mod batched;
pub use batched::*;
2023-12-06 04:17:19 +00:00
2024-03-03 01:20:38 +00:00
mod fn_sys;
2024-01-05 04:55:06 +00:00
pub use fn_sys::*;
2023-12-04 04:14:27 +00:00
/// A system that does not mutate the world
pub trait System {
/// A method that indicates the type of access of the world the system requires.
2023-12-04 04:14:27 +00:00
fn world_access(&self) -> Access;
/// The actual execution of the system.
2023-12-04 04:14:27 +00:00
fn execute(&mut self, world: NonNull<World>) -> anyhow::Result<()>;
/// A setup step of the System, called before `execute` ever runs.
fn setup(&self, world: NonNull<World>) -> anyhow::Result<()> {
let _ = world;
Ok(())
}
fn execute_deferred(&mut self, world: NonNull<World>) -> anyhow::Result<()>;
2023-12-04 04:14:27 +00:00
}
pub trait IntoSystem<T> {
type System: System;
fn into_system(self) -> Self::System;
}