pub(crate) fn update_asset_storage<T: Asset>(&self, mut assets: ResMut<Assets<T>>) {
        let asset_lifecycles = self.server.asset_lifecycles.read();
        let asset_lifecycle = asset_lifecycles.get(&T::TYPE_UUID).unwrap();
        let mut asset_sources_guard = None;
        let channel = asset_lifecycle
            .downcast_ref::<AssetLifecycleChannel<T>>()
            .unwrap();

        loop {
            match channel.receiver.try_recv() {
                Ok(AssetLifecycleEvent::Create(result)) => {
                    // update SourceInfo if this asset was loaded from an AssetPath
                    if let HandleId::AssetPathId(id) = result.id {
                        let asset_sources = asset_sources_guard
                            .get_or_insert_with(|| self.server.asset_sources.write());
                        if let Some(source_info) = asset_sources.get_mut(&id.source_path_id()) {
                            if source_info.version == result.version {
                                source_info.committed_assets.insert(id.label_id());
                                if source_info.is_loaded() {
                                    source_info.load_state = LoadState::Loaded;
                                }
                            }
                        }
                    }

                    assets.set_untracked(result.id, *result.asset);
                }
                Ok(AssetLifecycleEvent::Free(handle_id)) => {
                    if let HandleId::AssetPathId(id) = handle_id {
                        let asset_sources = asset_sources_guard
                            .get_or_insert_with(|| self.server.asset_sources.write());
                        if let Some(source_info) = asset_sources.get_mut(&id.source_path_id()) {
                            source_info.committed_assets.remove(&id.label_id());
                            source_info.load_state = LoadState::Unloaded;
                        }
                    }
                    assets.remove(handle_id);
                }
                Err(TryRecvError::Empty) => {
                    break;
                }
                Err(TryRecvError::Disconnected) => panic!("AssetChannel disconnected."),
            }
        }
    }
// Note: this takes a `ResMut<Assets<T>>` to ensure change detection does not get
// triggered unless the `Assets` collection is actually updated.
this takes a `ResMut>` to ensure change detection does not get
triggered unless the `Assets` collection is actually updated.
this takes a ` ResMut > ` to ensure change detection does not get triggered unless the ` Assets ` collection is actually updated .
pub(crate) fn update_asset_storage<T: Asset>(&self, mut assets: ResMut<Assets<T>>) {
        let asset_lifecycles = self.server.asset_lifecycles.read();
        let asset_lifecycle = asset_lifecycles.get(&T::TYPE_UUID).unwrap();
        let mut asset_sources_guard = None;
        let channel = asset_lifecycle
            .downcast_ref::<AssetLifecycleChannel<T>>()
            .unwrap();
        loop {
            match channel.receiver.try_recv() {
                Ok(AssetLifecycleEvent::Create(result)) => {
                    // update SourceInfo if this asset was loaded from an AssetPath
                    if let HandleId::AssetPathId(id) = result.id {
                        let asset_sources = asset_sources_guard
                            .get_or_insert_with(|| self.server.asset_sources.write());
                        if let Some(source_info) = asset_sources.get_mut(&id.source_path_id()) {
                            if source_info.version == result.version {
                                source_info.committed_assets.insert(id.label_id());
                                if source_info.is_loaded() {
                                    source_info.load_state = LoadState::Loaded;
                                }
                            }
                        }
                    }
                    assets.set_untracked(result.id, *result.asset);
                }
                Ok(AssetLifecycleEvent::Free(handle_id)) => {
                    if let HandleId::AssetPathId(id) = handle_id {
                        let asset_sources = asset_sources_guard
                            .get_or_insert_with(|| self.server.asset_sources.write());
                        if let Some(source_info) = asset_sources.get_mut(&id.source_path_id()) {
                            source_info.committed_assets.remove(&id.label_id());
                            source_info.load_state = LoadState::Unloaded;
                        }
                    }
                    assets.remove(handle_id);
                }
                Err(TryRecvError::Empty) => {
                    break;
                }
                Err(TryRecvError::Disconnected) => panic!("AssetChannel disconnected."),
            }
        }
    }
pub ( crate ) fn update_asset_storage < T : Asset > ( & self , mut assets : ResMut < Assets < T > > ) { let asset_lifecycles = self . server . asset_lifecycles . read ( ) ; let asset_lifecycle = asset_lifecycles . get ( & T :: TYPE_UUID ) . unwrap ( ) ; let mut asset_sources_guard = None ; let channel = asset_lifecycle . downcast_ref :: < AssetLifecycleChannel < T > > ( ) . unwrap ( ) ; loop { match channel . receiver . try_recv ( ) { Ok ( AssetLifecycleEvent :: Create ( result ) ) => { // update SourceInfo if this asset was loaded from an AssetPath if let HandleId :: AssetPathId ( id ) = result . id { let asset_sources = asset_sources_guard . get_or_insert_with ( | | self . server . asset_sources . write ( ) ) ; if let Some ( source_info ) = asset_sources . get_mut ( & id . source_path_id ( ) ) { if source_info . version == result . version { source_info . committed_assets . insert ( id . label_id ( ) ) ; if source_info . is_loaded ( ) { source_info . load_state = LoadState :: Loaded ; } } } } assets . set_untracked ( result . id , * result . asset ) ; } Ok ( AssetLifecycleEvent :: Free ( handle_id ) ) => { if let HandleId :: AssetPathId ( id ) = handle_id { let asset_sources = asset_sources_guard . get_or_insert_with ( | | self . server . asset_sources . write ( ) ) ; if let Some ( source_info ) = asset_sources . get_mut ( & id . source_path_id ( ) ) { source_info . committed_assets . remove ( & id . label_id ( ) ) ; source_info . load_state = LoadState :: Unloaded ; } } assets . remove ( handle_id ) ; } Err ( TryRecvError :: Empty ) => { break ; } Err ( TryRecvError :: Disconnected ) => panic ! ( " " ) , } } }
Note: this takes a `ResMut<Assets<T>>` to ensure change detection does not get
triggered unless the `Assets` collection is actually updated.
Note : this takes a ` ResMut<Assets<T >> ` to ensure change detection does not get triggered unless the ` Assets ` collection is actually updated .
&self
assets
ResMut<Assets<T>>
&self
assets
ResMut<Assets<T>>