|  | 
| 1 | 1 | use crate::{ | 
| 2 | 2 |     archetype::{Archetype, ArchetypeComponentId}, | 
| 3 |  | -    bundle::Bundle, | 
| 4 | 3 |     component::{Component, ComponentId, ComponentTicks, StorageType}, | 
| 5 | 4 |     entity::Entity, | 
| 6 | 5 |     query::{Access, Fetch, FetchState, FilteredAccess, WorldQuery}, | 
| @@ -282,106 +281,6 @@ impl<'w, 's, T: Component> Fetch<'w, 's> for WithoutFetch<T> { | 
| 282 | 281 |     } | 
| 283 | 282 | } | 
| 284 | 283 | 
 | 
| 285 |  | -pub struct WithBundle<T: Bundle>(PhantomData<T>); | 
| 286 |  | - | 
| 287 |  | -impl<T: Bundle> WorldQuery for WithBundle<T> { | 
| 288 |  | -    type Fetch = WithBundleFetch<T>; | 
| 289 |  | -    type State = WithBundleState<T>; | 
| 290 |  | -} | 
| 291 |  | - | 
| 292 |  | -pub struct WithBundleFetch<T: Bundle> { | 
| 293 |  | -    is_dense: bool, | 
| 294 |  | -    marker: PhantomData<T>, | 
| 295 |  | -} | 
| 296 |  | - | 
| 297 |  | -pub struct WithBundleState<T: Bundle> { | 
| 298 |  | -    component_ids: Vec<ComponentId>, | 
| 299 |  | -    is_dense: bool, | 
| 300 |  | -    marker: PhantomData<T>, | 
| 301 |  | -} | 
| 302 |  | - | 
| 303 |  | -// SAFETY: no component access or archetype component access | 
| 304 |  | -unsafe impl<T: Bundle> FetchState for WithBundleState<T> { | 
| 305 |  | -    fn init(world: &mut World) -> Self { | 
| 306 |  | -        let bundle_info = world.bundles.init_info::<T>(&mut world.components); | 
| 307 |  | -        let components = &world.components; | 
| 308 |  | -        Self { | 
| 309 |  | -            component_ids: bundle_info.component_ids.clone(), | 
| 310 |  | -            is_dense: !bundle_info.component_ids.iter().any(|id| unsafe { | 
| 311 |  | -                components.get_info_unchecked(*id).storage_type() != StorageType::Table | 
| 312 |  | -            }), | 
| 313 |  | -            marker: PhantomData, | 
| 314 |  | -        } | 
| 315 |  | -    } | 
| 316 |  | - | 
| 317 |  | -    #[inline] | 
| 318 |  | -    fn update_component_access(&self, access: &mut FilteredAccess<ComponentId>) { | 
| 319 |  | -        for component_id in self.component_ids.iter().cloned() { | 
| 320 |  | -            access.add_with(component_id); | 
| 321 |  | -        } | 
| 322 |  | -    } | 
| 323 |  | - | 
| 324 |  | -    #[inline] | 
| 325 |  | -    fn update_archetype_component_access( | 
| 326 |  | -        &self, | 
| 327 |  | -        _archetype: &Archetype, | 
| 328 |  | -        _access: &mut Access<ArchetypeComponentId>, | 
| 329 |  | -    ) { | 
| 330 |  | -    } | 
| 331 |  | - | 
| 332 |  | -    fn matches_archetype(&self, archetype: &Archetype) -> bool { | 
| 333 |  | -        self.component_ids.iter().all(|id| archetype.contains(*id)) | 
| 334 |  | -    } | 
| 335 |  | - | 
| 336 |  | -    fn matches_table(&self, table: &Table) -> bool { | 
| 337 |  | -        self.component_ids.iter().all(|id| table.has_column(*id)) | 
| 338 |  | -    } | 
| 339 |  | -} | 
| 340 |  | - | 
| 341 |  | -impl<'w, 's, T: Bundle> Fetch<'w, 's> for WithBundleFetch<T> { | 
| 342 |  | -    type Item = bool; | 
| 343 |  | -    type State = WithBundleState<T>; | 
| 344 |  | - | 
| 345 |  | -    unsafe fn init( | 
| 346 |  | -        _world: &World, | 
| 347 |  | -        state: &Self::State, | 
| 348 |  | -        _last_change_tick: u32, | 
| 349 |  | -        _change_tick: u32, | 
| 350 |  | -    ) -> Self { | 
| 351 |  | -        Self { | 
| 352 |  | -            is_dense: state.is_dense, | 
| 353 |  | -            marker: PhantomData, | 
| 354 |  | -        } | 
| 355 |  | -    } | 
| 356 |  | - | 
| 357 |  | -    #[inline] | 
| 358 |  | -    fn is_dense(&self) -> bool { | 
| 359 |  | -        self.is_dense | 
| 360 |  | -    } | 
| 361 |  | - | 
| 362 |  | -    #[inline] | 
| 363 |  | -    unsafe fn set_table(&mut self, _state: &Self::State, _table: &Table) {} | 
| 364 |  | - | 
| 365 |  | -    #[inline] | 
| 366 |  | -    unsafe fn set_archetype( | 
| 367 |  | -        &mut self, | 
| 368 |  | -        _state: &Self::State, | 
| 369 |  | -        _archetype: &Archetype, | 
| 370 |  | -        _tables: &Tables, | 
| 371 |  | -    ) { | 
| 372 |  | -    } | 
| 373 |  | - | 
| 374 |  | -    #[inline] | 
| 375 |  | -    unsafe fn archetype_fetch(&mut self, _archetype_index: usize) -> bool { | 
| 376 |  | -        true | 
| 377 |  | -    } | 
| 378 |  | - | 
| 379 |  | -    #[inline] | 
| 380 |  | -    unsafe fn table_fetch(&mut self, _table_row: usize) -> bool { | 
| 381 |  | -        true | 
| 382 |  | -    } | 
| 383 |  | -} | 
| 384 |  | - | 
| 385 | 284 | /// A filter that tests if any of the given filters apply. | 
| 386 | 285 | /// | 
| 387 | 286 | /// This is useful for example if a system with multiple components in a query only wants to run | 
|  | 
0 commit comments