|
1 | 1 | use crate::{ |
2 | 2 | core::{ |
3 | | - Archetype, Component, ComponentFlags, ComponentId, Entity, FilterFetch, FilteredAccess, |
4 | | - FilteredAccessSet, FromWorld, Or, QueryState, World, WorldQuery, |
| 3 | + Archetype, Archetypes, Bundles, Component, ComponentFlags, ComponentId, Components, |
| 4 | + Entities, Entity, FilterFetch, FilteredAccess, FilteredAccessSet, FromWorld, Or, |
| 5 | + QueryState, World, WorldQuery, |
5 | 6 | }, |
6 | 7 | system::{CommandQueue, Commands, Query, SystemState}, |
7 | 8 | }; |
@@ -567,6 +568,118 @@ impl<'a, T: 'static> SystemParamFetch<'a> for NonSendMutState<T> { |
567 | 568 |
|
568 | 569 | pub struct OrState<T>(T); |
569 | 570 |
|
| 571 | +impl<'a> SystemParam for &'a Archetypes { |
| 572 | + type Fetch = ArchetypesState; |
| 573 | +} |
| 574 | + |
| 575 | +pub struct ArchetypesState; |
| 576 | + |
| 577 | +// SAFE: no component value access |
| 578 | +unsafe impl SystemParamState for ArchetypesState { |
| 579 | + type Config = (); |
| 580 | + |
| 581 | + fn init(_world: &mut World, _system_state: &mut SystemState, _config: Self::Config) -> Self { |
| 582 | + Self |
| 583 | + } |
| 584 | +} |
| 585 | + |
| 586 | +impl<'a> SystemParamFetch<'a> for ArchetypesState { |
| 587 | + type Item = &'a Archetypes; |
| 588 | + |
| 589 | + #[inline] |
| 590 | + unsafe fn get_param( |
| 591 | + _state: &'a mut Self, |
| 592 | + _system_state: &'a SystemState, |
| 593 | + world: &'a World, |
| 594 | + ) -> Option<Self::Item> { |
| 595 | + Some(world.archetypes()) |
| 596 | + } |
| 597 | +} |
| 598 | + |
| 599 | +impl<'a> SystemParam for &'a Components { |
| 600 | + type Fetch = ComponentsState; |
| 601 | +} |
| 602 | + |
| 603 | +pub struct ComponentsState; |
| 604 | + |
| 605 | +// SAFE: no component value access |
| 606 | +unsafe impl SystemParamState for ComponentsState { |
| 607 | + type Config = (); |
| 608 | + |
| 609 | + fn init(_world: &mut World, _system_state: &mut SystemState, _config: Self::Config) -> Self { |
| 610 | + Self |
| 611 | + } |
| 612 | +} |
| 613 | + |
| 614 | +impl<'a> SystemParamFetch<'a> for ComponentsState { |
| 615 | + type Item = &'a Components; |
| 616 | + |
| 617 | + #[inline] |
| 618 | + unsafe fn get_param( |
| 619 | + _state: &'a mut Self, |
| 620 | + _system_state: &'a SystemState, |
| 621 | + world: &'a World, |
| 622 | + ) -> Option<Self::Item> { |
| 623 | + Some(world.components()) |
| 624 | + } |
| 625 | +} |
| 626 | + |
| 627 | +impl<'a> SystemParam for &'a Entities { |
| 628 | + type Fetch = EntitiesState; |
| 629 | +} |
| 630 | + |
| 631 | +pub struct EntitiesState; |
| 632 | + |
| 633 | +// SAFE: no component value access |
| 634 | +unsafe impl SystemParamState for EntitiesState { |
| 635 | + type Config = (); |
| 636 | + |
| 637 | + fn init(_world: &mut World, _system_state: &mut SystemState, _config: Self::Config) -> Self { |
| 638 | + Self |
| 639 | + } |
| 640 | +} |
| 641 | + |
| 642 | +impl<'a> SystemParamFetch<'a> for EntitiesState { |
| 643 | + type Item = &'a Entities; |
| 644 | + |
| 645 | + #[inline] |
| 646 | + unsafe fn get_param( |
| 647 | + _state: &'a mut Self, |
| 648 | + _system_state: &'a SystemState, |
| 649 | + world: &'a World, |
| 650 | + ) -> Option<Self::Item> { |
| 651 | + Some(world.entities()) |
| 652 | + } |
| 653 | +} |
| 654 | + |
| 655 | +impl<'a> SystemParam for &'a Bundles { |
| 656 | + type Fetch = BundlesState; |
| 657 | +} |
| 658 | + |
| 659 | +pub struct BundlesState; |
| 660 | + |
| 661 | +// SAFE: no component value access |
| 662 | +unsafe impl SystemParamState for BundlesState { |
| 663 | + type Config = (); |
| 664 | + |
| 665 | + fn init(_world: &mut World, _system_state: &mut SystemState, _config: Self::Config) -> Self { |
| 666 | + Self |
| 667 | + } |
| 668 | +} |
| 669 | + |
| 670 | +impl<'a> SystemParamFetch<'a> for BundlesState { |
| 671 | + type Item = &'a Bundles; |
| 672 | + |
| 673 | + #[inline] |
| 674 | + unsafe fn get_param( |
| 675 | + _state: &'a mut Self, |
| 676 | + _system_state: &'a SystemState, |
| 677 | + world: &'a World, |
| 678 | + ) -> Option<Self::Item> { |
| 679 | + Some(world.bundles()) |
| 680 | + } |
| 681 | +} |
| 682 | + |
570 | 683 | macro_rules! impl_system_param_tuple { |
571 | 684 | ($($param: ident),*) => { |
572 | 685 | impl<$($param: SystemParam),*> SystemParam for ($($param,)*) { |
|
0 commit comments