chore(): docstrings, minor cleanups

This commit is contained in:
kaosat.dev 2024-03-18 14:51:43 +01:00
parent 53e68ad58f
commit 1891903f03
2 changed files with 18 additions and 12 deletions

View File

@ -66,14 +66,12 @@ pub(crate) fn materials_inject(
} else { } else {
let material_file_handle: Handle<Gltf> = asset_server.load(materials_path.clone()); let material_file_handle: Handle<Gltf> = asset_server.load(materials_path.clone());
let material_file_id = material_file_handle.id(); let material_file_id = material_file_handle.id();
let asset_infos: Vec<AssetLoadTracker<Gltf>> = vec![ let asset_infos: Vec<AssetLoadTracker<Gltf>> = vec![AssetLoadTracker {
AssetLoadTracker { name: material_full_path,
name: material_full_path, id: material_file_id,
id: material_file_id, loaded: false,
loaded: false, handle: material_file_handle.clone(),
handle: material_file_handle.clone(), }];
}
];
commands commands
.entity(entity) .entity(entity)

View File

@ -46,10 +46,12 @@ pub struct AddToGameWorld;
/// helper component, just to transfer child data /// helper component, just to transfer child data
pub(crate) struct OriginalChildren(pub Vec<Entity>); pub(crate) struct OriginalChildren(pub Vec<Entity>);
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
pub struct BlueprintsList(pub HashMap<String, Vec<String>>); pub struct BlueprintsList(pub HashMap<String, Vec<String>>);
/// helper component, for tracking loaded assets's loading state, id , handle etc
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub(crate) struct AssetLoadTracker<T: bevy::prelude::Asset> { pub(crate) struct AssetLoadTracker<T: bevy::prelude::Asset> {
#[allow(dead_code)] #[allow(dead_code)]
@ -59,19 +61,25 @@ pub(crate) struct AssetLoadTracker<T: bevy::prelude::Asset> {
#[allow(dead_code)] #[allow(dead_code)]
pub handle: Handle<T>, pub handle: Handle<T>,
} }
/// helper component, for tracking loaded assets
#[derive(Component, Debug)] #[derive(Component, Debug)]
pub(crate) struct AssetsToLoad<T: bevy::prelude::Asset> { pub(crate) struct AssetsToLoad<T: bevy::prelude::Asset> {
pub all_loaded: bool, pub all_loaded: bool,
pub asset_infos: Vec<AssetLoadTracker<T>>, pub asset_infos: Vec<AssetLoadTracker<T>>,
pub progress: f32, pub progress: f32,
} }
impl <T: bevy::prelude::Asset>Default for AssetsToLoad<T> { impl<T: bevy::prelude::Asset> Default for AssetsToLoad<T> {
fn default() -> Self { fn default() -> Self {
Self { all_loaded: Default::default(), asset_infos: Default::default(), progress: Default::default() } Self {
all_loaded: Default::default(),
asset_infos: Default::default(),
progress: Default::default(),
}
} }
} }
/// flag component /// flag component, usually added when a blueprint is loaded
#[derive(Component)] #[derive(Component)]
pub(crate) struct BlueprintAssetsLoaded; pub(crate) struct BlueprintAssetsLoaded;
/// flag component /// flag component
@ -221,7 +229,7 @@ pub(crate) fn spawn_from_blueprints(
name, name,
) in spawn_placeholders.iter() ) in spawn_placeholders.iter()
{ {
info!( debug!(
"attempting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}", "attempting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}",
blupeprint_name.0, name, entity, original_parent blupeprint_name.0, name, entity, original_parent
); );