Expand description
This crate provides easy to use way to make systems that operate on a single entity.
§Warning
Currently there is a bug, individual entity systems don’t store their state.
State is being shared across all entities that are being iterated by the system that resulted from into_system
call.
That means that Local
, EntityReader
and other SystemParam
’s, that
rely on it’s state property to be preserved between system runs, won’t work correctly.
It is a huge footgun, so the work on fixing it is being done.
After fix, the API will change, user would need to explicitly specify the entities this system is allowed to run on. That means, you most probably would need to be able to mutate systems at runtime - something that bevy currently doesn’t support. I also work on a crate that will be able to provide you with such functionality - it is not published yet.
§Example
#[derive(Component)]
struct Count(i32);
#[derive(Component)]
struct MyMarkerComponent;
fn my_entity_system(
mut data: Data<&mut Count, With<MyMarkerComponent>>,
mut commands: Commands
) {
data.item.0 += 1;
commands.spawn(Count(10));
}
fn my_entity_system_with_input(input: In<i32>, mut data: Data<&mut Count>) {
data.item.0 += *input;
}
bevy_ecs::system::assert_is_system(my_entity_system.into_system());
bevy_ecs::system::assert_is_system(my_entity_system_with_input.into_system());
Modules§
- data_
match - Contains
DataMatch
- implementors
- Built in implementations of
EntitySystem
- into_
entity_ system - Convenience in working with
EntitySystem
s - into_
system - Implementation of
IntoSystem
- marked_
entity_ system - Contains functionality to run
EntitySystem
s that should be marked in order to implement this trait This is necessary to avoid conflicting implementations when implementing trait for rust functions - prelude
- Prelude module
Traits§
- Entity
System - Trait implemented for all functions that can be used as
System
s and operate on a singleEntity
. Such system can only be run for entities that match it’sData
andFilter
- Read
Only Entity System - Implemented for
EntitySystem
s that only read data from the world