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

38 lines
874 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-01-05 04:55:06 +00:00
use crate::{world::World, Access};
2023-12-04 04:14:27 +00:00
2023-12-06 04:17:19 +00:00
pub mod graph;
pub use graph::*;
pub mod criteria;
pub use criteria::*;
pub mod batched;
pub use batched::*;
2023-12-06 04:17:19 +00:00
2024-01-05 04:55:06 +00:00
pub mod fn_sys;
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;
}