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

38 lines
851 B
Rust

use std::ptr::NonNull;
use crate::{World, Access};
mod graph;
pub use graph::*;
mod criteria;
pub use criteria::*;
mod batched;
pub use batched::*;
mod fn_sys;
pub use fn_sys::*;
/// 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.
fn world_access(&self) -> Access;
/// The actual execution of the system.
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<()>;
}
pub trait IntoSystem<T> {
type System: System;
fn into_system(self) -> Self::System;
}