chore(clippy): minor tweaks

This commit is contained in:
kaosat.dev 2024-05-16 22:38:45 +02:00
parent f561112704
commit 00bf63cbd3
3 changed files with 13 additions and 21 deletions

View File

@ -62,14 +62,9 @@ pub enum GltfComponentsSet {
#[derive(Clone, Resource)] #[derive(Clone, Resource)]
pub struct GltfComponentsConfig {} pub struct GltfComponentsConfig {}
#[derive(Default)]
pub struct ComponentsFromGltfPlugin {} pub struct ComponentsFromGltfPlugin {}
impl Default for ComponentsFromGltfPlugin {
fn default() -> Self {
Self {}
}
}
impl Plugin for ComponentsFromGltfPlugin { impl Plugin for ComponentsFromGltfPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins(blender_settings::plugin) app.add_plugins(blender_settings::plugin)

View File

@ -15,16 +15,15 @@ pub fn ronstring_to_reflect_component(
let mut components: Vec<(Box<dyn Reflect>, TypeRegistration)> = Vec::new(); let mut components: Vec<(Box<dyn Reflect>, TypeRegistration)> = Vec::new();
// println!("ron_string {:?}", ron_string); // println!("ron_string {:?}", ron_string);
for (name, value) in lookup.into_iter() { for (name, value) in lookup.into_iter() {
let parsed_value: String; let parsed_value: String = match value.clone() {
match value.clone() {
Value::String(str) => { Value::String(str) => {
parsed_value = str; str
} }
_ => parsed_value = ron::to_string(&value).unwrap().to_string(), _ => ron::to_string(&value).unwrap().to_string(),
} };
if name.as_str() == "bevy_components" { if name.as_str() == "bevy_components" {
bevy_components_string_to_components(parsed_value, type_registry, &mut components) bevy_components_string_to_components(parsed_value, type_registry, &mut components);
} else { } else {
components_string_to_components( components_string_to_components(
name, name,
@ -32,7 +31,7 @@ pub fn ronstring_to_reflect_component(
parsed_value, parsed_value,
type_registry, type_registry,
&mut components, &mut components,
) );
} }
} }
components components
@ -95,13 +94,12 @@ fn bevy_components_string_to_components(
) { ) {
let lookup: HashMap<String, Value> = ron::from_str(&parsed_value).unwrap(); let lookup: HashMap<String, Value> = ron::from_str(&parsed_value).unwrap();
for (key, value) in lookup.into_iter() { for (key, value) in lookup.into_iter() {
let parsed_value: String; let parsed_value: String = match value.clone() {
match value.clone() {
Value::String(str) => { Value::String(str) => {
parsed_value = str; str
} }
_ => parsed_value = ron::to_string(&value).unwrap().to_string(), _ => ron::to_string(&value).unwrap().to_string(),
} };
if let Some(type_registration) = type_registry.get_with_type_path(key.as_str()) { if let Some(type_registration) = type_registry.get_with_type_path(key.as_str()) {
debug!("TYPE INFO {:?}", type_registration.type_info()); debug!("TYPE INFO {:?}", type_registration.type_info());

View File

@ -17,7 +17,6 @@ pub fn export_types(world: &mut World) {
let asset_root = world.resource::<AssetRoot>(); let asset_root = world.resource::<AssetRoot>();
let registry_save_path = Path::join(&asset_root.0, &config.save_path); let registry_save_path = Path::join(&asset_root.0, &config.save_path);
println!("registry_save_path {}", registry_save_path.display());
let writer = File::create(registry_save_path).expect("should have created schema file"); let writer = File::create(registry_save_path).expect("should have created schema file");
let components_to_filter_out = &config.component_filter.clone(); let components_to_filter_out = &config.component_filter.clone();
@ -29,8 +28,8 @@ pub fn export_types(world: &mut World) {
.iter() .iter()
.filter(|type_info| { .filter(|type_info| {
let type_id = type_info.type_id(); let type_id = type_info.type_id();
return components_to_filter_out.is_allowed_by_id(type_id) components_to_filter_out.is_allowed_by_id(type_id)
&& resources_to_filter_out.is_allowed_by_id(type_id); && resources_to_filter_out.is_allowed_by_id(type_id)
}) })
.map(export_type) .map(export_type)
.collect::<Map<_, _>>(); .collect::<Map<_, _>>();