use crate::{impl_reflect_value, GetTypeRegistration, ReflectDeserialize, TypeRegistryArc}; use bevy_app::{AppBuilder, Plugin}; use bevy_ecs::Entity; #[derive(Default)] pub struct ReflectPlugin; impl Plugin for ReflectPlugin { fn build(&self, app: &mut AppBuilder) { app.init_resource::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::(); #[cfg(feature = "glam")] { app.register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::(); } #[cfg(feature = "bevy_ecs")] { app.register_type::(); } } } impl_reflect_value!(Entity(Hash, PartialEq, Serialize, Deserialize)); pub trait RegisterTypeBuilder { fn register_type(&mut self) -> &mut Self; } impl RegisterTypeBuilder for AppBuilder { fn register_type(&mut self) -> &mut Self { { let registry = self.resources().get_mut::().unwrap(); registry.write().register::(); } self } }