diff --git a/src/registry.rs b/src/registry.rs index 0633714..e828a30 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -1,3 +1,5 @@ +use std::fs::{File, OpenOptions}; + use bevy::prelude::*; use bevy::reflect::{ ArrayInfo, EnumInfo, ListInfo, MapInfo, NamedField, OpaqueInfo, SetInfo, StructInfo, @@ -22,10 +24,20 @@ fn create_registry(config: Res, type_registry: Res = type_registry .iter() + // TODO: somehow filter by components? + //.filter(|t| is_component(t)) .filter(|t| filter.is_allowed_by_id(t.type_id())) .map(RegistryEntry::from) .collect(); - println!("{types:?}"); + + if let Ok(file) = File::create(&config.registry_path) { + if let Err(e) = serde_json::to_writer(&file, &types) { + warn!( + "Failed to write registry to {:?}: {e:?}", + &config.registry_path + ); + } + } } #[derive(Debug, Serialize, Deserialize)]