diff --git a/examples/ecs/generic_system.rs b/examples/ecs/generic_system.rs index 783b8d57d9..8b3aa8742a 100644 --- a/examples/ecs/generic_system.rs +++ b/examples/ecs/generic_system.rs @@ -174,12 +174,16 @@ mod system_with_generic_system_param { } } -// TODO: change this to use assets? // You may want to be have the SystemParam be specified in an associated type. mod system_param_in_associated_type { use super::*; use bevy::ecs::system::{lifetimeless::SRes, StaticSystemParam, SystemParam, SystemParamItem}; + #[derive(Resource)] + pub struct ResourceA { + pub data: u32, + } + #[derive(Resource)] pub struct ResourceC { pub data: u32, @@ -202,10 +206,22 @@ mod system_param_in_associated_type { } } + #[derive(Resource)] + pub struct ItemB; + impl MyTrait for ItemB { + // we can specify any system param here, including a combination of other system params + type Param = (SRes, SRes); + + fn do_something(&self, param: &mut SystemParamItem) -> u32 { + // todo: Make this more intelligible + param.0.data + param.1.data + } + } + pub fn system( mut param: StaticSystemParam<::Param>, - asset: ResMut, + item: ResMut, ) { - asset.do_something(&mut param); + item.do_something(&mut param); } }