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;
|
2023-12-27 04:48:46 +00:00
|
|
|
pub use graph::*;
|
|
|
|
|
2024-03-03 01:20:38 +00:00
|
|
|
mod criteria;
|
2023-12-27 04:48:46 +00:00
|
|
|
pub use criteria::*;
|
|
|
|
|
2024-03-03 01:20:38 +00:00
|
|
|
mod batched;
|
2023-12-27 04:48:46 +00:00
|
|
|
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 {
|
2023-12-27 04:48:46 +00:00
|
|
|
/// 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;
|
2023-12-27 04:48:46 +00:00
|
|
|
|
|
|
|
/// The actual execution of the system.
|
2023-12-04 04:14:27 +00:00
|
|
|
fn execute(&mut self, world: NonNull<World>) -> anyhow::Result<()>;
|
2023-12-27 04:48:46 +00:00
|
|
|
|
|
|
|
/// A setup step of the System, called before `execute` ever runs.
|
|
|
|
fn setup(&self, world: NonNull<World>) -> anyhow::Result<()> {
|
2023-12-28 03:53:58 +00:00
|
|
|
let _ = world;
|
2023-12-27 04:48:46 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
2024-02-23 21:34:21 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|