diff options
author | HampusM <hampus@hampusmat.com> | 2024-02-28 22:30:38 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-02-28 22:30:38 +0100 |
commit | 21c582507ae2dc9d264c80719e39ac47d3b0122b (patch) | |
tree | c564e8507dcc3060442821cbfdce1788c472cb9c /ecs/src/system/stateful.rs | |
parent | c1ec41dffb488109740bce2c2354db917fb6c20f (diff) |
refactor(ecs): use better system input type filtering solution
Diffstat (limited to 'ecs/src/system/stateful.rs')
-rw-r--r-- | ecs/src/system/stateful.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs index 9b2f279..54f9807 100644 --- a/ecs/src/system/stateful.rs +++ b/ecs/src/system/stateful.rs @@ -6,15 +6,13 @@ use seq_macro::seq; use crate::component::Component; use crate::system::util::check_params_are_compatible; -use crate::system::{ - FilteredInputs, - InputFilter, - Into as IntoSystem, - OptionInputs, - Param, - System, - TakeOptionInputResult, - TypeErased, +use crate::system::{Into as IntoSystem, Param, System, TypeErased}; +use crate::tuple::{ + Filter as TupleFilter, + FilterExclude as TupleFilterExclude, + IntoInOptions as TupleIntoInOptions, + TakeOptionElementResult as TupleTakeOptionElementResult, + WithOptionElements as TupleWithOptionElements, }; use crate::ComponentStorage; @@ -34,25 +32,28 @@ macro_rules! impl_system { Func: Fn(#(TParam~I,)*) + Copy + 'static, #(TParam~I: Param<'world>,)* #(TParam~I::Input: 'static,)* - (#(TParam~I::Input,)*): InputFilter + (#(TParam~I::Input,)*): TupleFilter, + <(#(TParam~I::Input,)*) as TupleFilter>::Out: TupleIntoInOptions { - type Input = <(#(TParam~I::Input,)*) as InputFilter>::Filtered; + type Input = <(#(TParam~I::Input,)*) as TupleFilter>::Out; fn initialize(mut self, input: Self::Input) -> Self { let mut option_input = input.into_in_options(); #( - if TypeId::of::<TParam~I::Input>() != TypeId::of::<()>() { + if TypeId::of::<TParam~I::Input>() != + TypeId::of::<TupleFilterExclude>() + { let input = match option_input.take::<TParam~I::Input>() { - TakeOptionInputResult::Found(input) => input, - TakeOptionInputResult::NotFound => { + TupleTakeOptionElementResult::Found(input) => input, + TupleTakeOptionElementResult::NotFound => { panic!( "Parameter input {} not found", type_name::<TParam~I::Input>() ); } - TakeOptionInputResult::AlreadyTaken => { + TupleTakeOptionElementResult::AlreadyTaken => { panic!( concat!( "Parameter {} is already initialized. ", |