chore(): cargo fmt

This commit is contained in:
kaosat.dev 2024-05-07 00:40:47 +02:00
parent c27bfb839e
commit 310ee194a9
4 changed files with 20 additions and 22 deletions

View File

@ -31,7 +31,7 @@ pub fn add_components_from_gltf_extras(world: &mut World) {
);
let type_registry: &AppTypeRegistry = world.resource();
let type_registry = type_registry.read();
let type_registry = type_registry.read();
let reflect_components = ronstring_to_reflect_component(&extra.value, &type_registry);
// we assign the components specified /xxx_components objects to their parent node

View File

@ -15,8 +15,6 @@ pub fn ronstring_to_reflect_component(
let mut components: Vec<(Box<dyn Reflect>, TypeRegistration)> = Vec::new();
// println!("ron_string {:?}", ron_string);
for (name, value) in lookup.into_iter() {
let parsed_value: String;
match value.clone() {
Value::String(str) => {
@ -28,24 +26,30 @@ pub fn ronstring_to_reflect_component(
if name.as_str() == "bevy_components" {
bevy_components_string_to_components(parsed_value, type_registry, &mut components)
} else {
components_string_to_components(name, value, parsed_value, type_registry, &mut components)
components_string_to_components(
name,
value,
parsed_value,
type_registry,
&mut components,
)
}
}
components
}
fn components_string_to_components(
name: String,
name: String,
value: Value,
parsed_value: String,
type_registry: &TypeRegistry,
components: &mut Vec<(Box<dyn Reflect>, TypeRegistration)>
){
components: &mut Vec<(Box<dyn Reflect>, TypeRegistration)>,
) {
let type_string = name.replace("component: ", "").trim().to_string();
let capitalized_type_name = capitalize_first_letter(type_string.as_str());
if let Some(type_registration) =
type_registry.get_with_short_type_path(capitalized_type_name.as_str())
type_registry.get_with_short_type_path(capitalized_type_name.as_str())
{
debug!("TYPE INFO {:?}", type_registration.type_info());
@ -87,8 +91,8 @@ fn components_string_to_components(
fn bevy_components_string_to_components(
parsed_value: String,
type_registry: &TypeRegistry,
components: &mut Vec<(Box<dyn Reflect>, TypeRegistration)>
){
components: &mut Vec<(Box<dyn Reflect>, TypeRegistration)>,
) {
let lookup: HashMap<String, Value> = ron::from_str(&parsed_value).unwrap();
for (key, value) in lookup.into_iter() {
let parsed_value: String;
@ -99,9 +103,7 @@ fn bevy_components_string_to_components(
_ => parsed_value = 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());
let ron_string = format!(
@ -131,4 +133,4 @@ fn bevy_components_string_to_components(
warn!("no type registration for {}", key);
}
}
}
}

View File

@ -25,10 +25,12 @@ pub fn export_types(world: &mut World) {
let types = world.resource_mut::<AppTypeRegistry>();
let types = types.read();
let schemas = types.iter()
let schemas = types
.iter()
.filter(|type_info| {
let type_id = type_info.type_id();
return components_to_filter_out.is_allowed_by_id(type_id) && resources_to_filter_out.is_allowed_by_id(type_id);
return components_to_filter_out.is_allowed_by_id(type_id)
&& resources_to_filter_out.is_allowed_by_id(type_id);
})
.map(export_type)
.collect::<Map<_, _>>();

View File

@ -152,7 +152,6 @@ impl MaterialExtension for MyExtension {
}
}
use bevy::utils::HashMap;
#[derive(Component, Reflect, Default, Debug)]
@ -189,7 +188,6 @@ pub struct HashmapTestStringColor {
#[reflect(Component)]
pub struct HashmapTestStringColorFlat(HashMap<String, Color>);
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct ComponentAToFilterOut;
@ -237,17 +235,13 @@ impl Plugin for ComponentsTestPlugin {
.register_type::<HashmapTestStringFloat>()
.register_type::<HashMap<u32, String>>()
.register_type::<HashmapTestIntString>()
.register_type::<HashMap<u32, Color>>()
.register_type::<HashmapTestIntColor>()
.register_type::<HashMap<String, Color>>()
.register_type::<HashmapTestStringColor>()
.register_type::<HashmapTestStringColorFlat>()
.register_type::<ComponentAToFilterOut>()
.register_type::<ComponentBToFilterOut>()
.add_plugins(MaterialPlugin::<
ExtendedMaterial<StandardMaterial, MyExtension>,
>::default());