@@ -9,9 +9,9 @@ use bevy::{
99 } ,
1010 platform:: hash:: FixedState ,
1111 reflect:: {
12- DynamicEnum , DynamicStruct , DynamicTuple , DynamicTupleStruct , DynamicVariant , FromType ,
13- NamedField , PartialReflect , Reflect , ReflectKind , StructInfo , StructVariantInfo , TypeInfo ,
14- TypePath , TypeRegistration , TypeRegistry , TypeRegistryArc ,
12+ DynamicEnum , DynamicList , DynamicStruct , DynamicTuple , DynamicTupleStruct , DynamicVariant ,
13+ FromType , NamedField , PartialReflect , Reflect , ReflectKind , StructInfo , StructVariantInfo ,
14+ TypeInfo , TypePath , TypeRegistration , TypeRegistry , TypeRegistryArc ,
1515 } ,
1616} ;
1717use thiserror:: Error ;
@@ -447,6 +447,7 @@ impl<'a, 'b> BsnReflector<'a, 'b> {
447447 ty,
448448 ) ,
449449 BsnValue :: Tuple ( items) => self . reflect_tuple ( items, ty) ,
450+ BsnValue :: List ( items) => self . reflect_list ( items, ty) ,
450451 _ => Err ( ReflectError :: UnexpectedType (
451452 format ! ( "{:?}" , value) ,
452453 ty. type_path ( ) . into ( ) ,
@@ -517,6 +518,22 @@ impl<'a, 'b> BsnReflector<'a, 'b> {
517518 Ok ( ReflectedValue :: new ( ty. type_id ( ) , Box :: new ( dynamic_tuple) ) )
518519 }
519520
521+ fn reflect_list ( & self , items : & [ BsnValue ] , ty : & TypeInfo ) -> ReflectResult < ReflectedValue > {
522+ if let Ok ( list_info) = ty. as_list ( ) {
523+ let mut dynamic_list = DynamicList :: default ( ) ;
524+ let item_type_info = list_info. item_info ( ) . expect ( "Expected typed list" ) ;
525+ for item in items. iter ( ) {
526+ dynamic_list. push_box ( self . reflect_value ( item, item_type_info) ?. instance ) ;
527+ }
528+ Ok ( ReflectedValue :: new ( ty. type_id ( ) , Box :: new ( dynamic_list) ) )
529+ } else {
530+ Err ( ReflectError :: UnexpectedType (
531+ format ! ( "{:?}" , items) ,
532+ format ! ( "{:?}" , ty) ,
533+ ) )
534+ }
535+ }
536+
520537 fn reflect_path ( & self , path : & str , ty : Option < & TypeInfo > ) -> ReflectResult < ReflectedValue > {
521538 let ty = match ty {
522539 Some ( ty) => ty,
0 commit comments