From 21c582507ae2dc9d264c80719e39ac47d3b0122b Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 28 Feb 2024 22:30:38 +0100 Subject: refactor(ecs): use better system input type filtering solution --- ecs/src/system/stateful.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'ecs/src/system') 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::() != TypeId::of::<()>() { + if TypeId::of::() != + TypeId::of::() + { let input = match option_input.take::() { - TakeOptionInputResult::Found(input) => input, - TakeOptionInputResult::NotFound => { + TupleTakeOptionElementResult::Found(input) => input, + TupleTakeOptionElementResult::NotFound => { panic!( "Parameter input {} not found", type_name::() ); } - TakeOptionInputResult::AlreadyTaken => { + TupleTakeOptionElementResult::AlreadyTaken => { panic!( concat!( "Parameter {} is already initialized. ", -- cgit v1.2.3-18-g5258