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

@ -15,8 +15,6 @@ 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) => {
@ -28,7 +26,13 @@ pub fn ronstring_to_reflect_component(
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(name, value, parsed_value, type_registry, &mut components) components_string_to_components(
name,
value,
parsed_value,
type_registry,
&mut components,
)
} }
} }
components components
@ -39,7 +43,7 @@ fn components_string_to_components(
value: Value, value: Value,
parsed_value: String, parsed_value: String,
type_registry: &TypeRegistry, 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 type_string = name.replace("component: ", "").trim().to_string();
let capitalized_type_name = capitalize_first_letter(type_string.as_str()); let capitalized_type_name = capitalize_first_letter(type_string.as_str());
@ -87,7 +91,7 @@ fn components_string_to_components(
fn bevy_components_string_to_components( fn bevy_components_string_to_components(
parsed_value: String, parsed_value: String,
type_registry: &TypeRegistry, 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(); 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() {
@ -99,9 +103,7 @@ fn bevy_components_string_to_components(
_ => parsed_value = ron::to_string(&value).unwrap().to_string(), _ => parsed_value = ron::to_string(&value).unwrap().to_string(),
} }
if let Some(type_registration) = if let Some(type_registration) = type_registry.get_with_type_path(key.as_str()) {
type_registry.get_with_type_path(key.as_str())
{
debug!("TYPE INFO {:?}", type_registration.type_info()); debug!("TYPE INFO {:?}", type_registration.type_info());
let ron_string = format!( let ron_string = format!(

View File

@ -25,10 +25,12 @@ pub fn export_types(world: &mut World) {
let types = world.resource_mut::<AppTypeRegistry>(); let types = world.resource_mut::<AppTypeRegistry>();
let types = types.read(); let types = types.read();
let schemas = types.iter() let schemas = types
.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) && 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) .map(export_type)
.collect::<Map<_, _>>(); .collect::<Map<_, _>>();

View File

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