pub struct BoxedSystem { /* private fields */ }Expand description
A type-erased, boxed system.
BoxedSystem wraps any System implementor in a Box, enabling
dynamic dispatch and storage in collections.
§When to Use
Use BoxedSystem when you need to:
- Store systems of different types in a single collection
- Pass systems around without knowing their concrete type
- Build dynamic system pipelines
§Example
use goud_engine::ecs::{World};
use goud_engine::ecs::system::{System, BoxedSystem};
struct SystemA;
impl System for SystemA {
fn name(&self) -> &'static str { "SystemA" }
fn run(&mut self, _world: &mut World) {}
}
struct SystemB;
impl System for SystemB {
fn name(&self) -> &'static str { "SystemB" }
fn run(&mut self, _world: &mut World) {}
}
// Store different system types in a Vec
let mut systems: Vec<BoxedSystem> = vec![
BoxedSystem::new(SystemA),
BoxedSystem::new(SystemB),
];
// Run all systems
let mut world = World::new();
for system in &mut systems {
system.run(&mut world);
}Implementations§
Source§impl BoxedSystem
impl BoxedSystem
Sourcepub fn new<S: System + 'static>(system: S) -> Self
pub fn new<S: System + 'static>(system: S) -> Self
Creates a new boxed system from any System implementor.
Sourcepub fn component_access(&self) -> Access
pub fn component_access(&self) -> Access
Returns the system’s component access pattern.
Sourcepub fn initialize(&mut self, world: &mut World)
pub fn initialize(&mut self, world: &mut World)
Initializes the system.
Sourcepub fn should_run(&self, world: &World) -> bool
pub fn should_run(&self, world: &World) -> bool
Checks if the system should run.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Returns true if this system only reads data.
Sourcepub fn conflicts_with(&self, other: &BoxedSystem) -> bool
pub fn conflicts_with(&self, other: &BoxedSystem) -> bool
Checks if this system conflicts with another.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxedSystem
impl !RefUnwindSafe for BoxedSystem
impl Send for BoxedSystem
impl !Sync for BoxedSystem
impl Unpin for BoxedSystem
impl UnsafeUnpin for BoxedSystem
impl !UnwindSafe for BoxedSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more