Struct legion::SystemBuilder [−][src]
A low level builder for constructing systems.
#[derive(Copy, Clone, Debug, PartialEq)] struct Static; #[derive(Debug)] struct TestResource {} let mut system_one = SystemBuilder::new("TestSystem") .read_resource::<TestResource>() .with_query( <(Entity, Read<Position>, Read<Model>)>::query() .filter(!component::<Static>() | maybe_changed::<Position>()), ) .build( move |commands, world, resource, queries| { for (entity, pos, model) in queries.iter_mut(world) {} }, );
Implementations
impl SystemBuilder<(), ()>
[src]
pub fn new<T: Into<SystemId>>(name: T) -> Self
[src]
Create a new system builder to construct a new system.
Please note, the name
argument for this method is just for debugging and visualization
purposes and is not logically used anywhere.
impl<Q, R> SystemBuilder<Q, R> where
Q: 'static + Send + ConsFlatten,
R: 'static + ConsFlatten,
[src]
Q: 'static + Send + ConsFlatten,
R: 'static + ConsFlatten,
pub fn with_name(self, name: SystemId) -> Self
[src]
Provides a name to the system being built.
pub fn with_query<V, F>(
self,
query: Query<V, F>
) -> SystemBuilder<<Q as ConsAppend<Query<V, F>>>::Output, R> where
V: IntoView,
F: 'static + EntityFilter,
Q: ConsAppend<Query<V, F>>,
[src]
self,
query: Query<V, F>
) -> SystemBuilder<<Q as ConsAppend<Query<V, F>>>::Output, R> where
V: IntoView,
F: 'static + EntityFilter,
Q: ConsAppend<Query<V, F>>,
Defines a query to provide this system for its execution. Multiple queries can be provided, and queries are cached internally for efficiency for filtering and archetype ID handling.
It is best practice to define your queries here, to allow for the caching to take place. These queries are then provided to the executing closure as a tuple of queries.
pub fn read_resource<T>(
self
) -> SystemBuilder<Q, <R as ConsAppend<Read<T>>>::Output> where
T: 'static + Resource,
R: ConsAppend<Read<T>>,
<R as ConsAppend<Read<T>>>::Output: ConsFlatten,
[src]
self
) -> SystemBuilder<Q, <R as ConsAppend<Read<T>>>::Output> where
T: 'static + Resource,
R: ConsAppend<Read<T>>,
<R as ConsAppend<Read<T>>>::Output: ConsFlatten,
Flag this resource type as being read by this system.
This will inform the dispatcher to not allow any writes access to this resource while this system is running. Parralel reads still occur during execution.
pub fn write_resource<T>(
self
) -> SystemBuilder<Q, <R as ConsAppend<Write<T>>>::Output> where
T: 'static + Resource,
R: ConsAppend<Write<T>>,
<R as ConsAppend<Write<T>>>::Output: ConsFlatten,
[src]
self
) -> SystemBuilder<Q, <R as ConsAppend<Write<T>>>::Output> where
T: 'static + Resource,
R: ConsAppend<Write<T>>,
<R as ConsAppend<Write<T>>>::Output: ConsFlatten,
Flag this resource type as being written by this system.
This will inform the dispatcher to not allow any parallel access to this resource while this system is running.
pub fn read_component<T>(self) -> Self where
T: Component,
[src]
T: Component,
This performs a soft resource block on the component for writing. The dispatcher will generally handle dispatching read and writes on components based on archetype, allowing for more granular access and more parallelization of systems.
Using this method will mark the entire component as read by this system, blocking writing systems from accessing any archetypes which contain this component for the duration of its execution.
This type of access with SubWorld
is provided for cases where sparse component access
is required and searching entire query spaces for entities is inefficient.
pub fn write_component<T>(self) -> Self where
T: Component,
[src]
T: Component,
This performs a exclusive resource block on the component for writing. The dispatcher will generally handle dispatching read and writes on components based on archetype, allowing for more granular access and more parallelization of systems.
Using this method will mark the entire component as written by this system, blocking other systems from accessing any archetypes which contain this component for the duration of its execution.
This type of access with SubWorld
is provided for cases where sparse component access
is required and searching entire query spaces for entities is inefficient.
pub fn build<F>(
self,
run_fn: F
) -> System<<R as ConsFlatten>::Output, <Q as ConsFlatten>::Output, F> where
<R as ConsFlatten>::Output: for<'a> ResourceSet<'a>,
<Q as ConsFlatten>::Output: QuerySet,
F: FnMut(&mut CommandBuffer, &mut SubWorld<'_>, &mut <<R as ConsFlatten>::Output as ResourceSet<'static>>::Result, &mut <Q as ConsFlatten>::Output),
[src]
self,
run_fn: F
) -> System<<R as ConsFlatten>::Output, <Q as ConsFlatten>::Output, F> where
<R as ConsFlatten>::Output: for<'a> ResourceSet<'a>,
<Q as ConsFlatten>::Output: QuerySet,
F: FnMut(&mut CommandBuffer, &mut SubWorld<'_>, &mut <<R as ConsFlatten>::Output as ResourceSet<'static>>::Result, &mut <Q as ConsFlatten>::Output),
Builds a system which is not Schedulable
, as it is not thread safe (!Send and !Sync),
but still implements all the calling infrastructure of the Runnable
trait. This provides
a way for legion consumers to leverage the System
construction and type-handling of
this build for thread local systems which cannot leave the main initializing thread.
Trait Implementations
Auto Trait Implementations
impl<Q, R> RefUnwindSafe for SystemBuilder<Q, R> where
Q: RefUnwindSafe,
R: RefUnwindSafe,
Q: RefUnwindSafe,
R: RefUnwindSafe,
impl<Q, R> Send for SystemBuilder<Q, R> where
Q: Send,
R: Send,
Q: Send,
R: Send,
impl<Q, R> Sync for SystemBuilder<Q, R> where
Q: Sync,
R: Sync,
Q: Sync,
R: Sync,
impl<Q, R> Unpin for SystemBuilder<Q, R> where
Q: Unpin,
R: Unpin,
Q: Unpin,
R: Unpin,
impl<Q, R> UnwindSafe for SystemBuilder<Q, R> where
Q: UnwindSafe,
R: UnwindSafe,
Q: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
[src]
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,