bevy_trait_query/one/core/
change_detection.rs

1use std::cell::UnsafeCell;
2
3use bevy_ecs::{
4    component::Tick,
5    ptr::ThinSlicePtr,
6    storage::{ComponentSparseSet, SparseSets},
7};
8
9#[derive(Clone, Copy)]
10pub(crate) enum ChangeDetectionStorage<'w> {
11    Uninit,
12    Table {
13        /// This points to one of the component table columns,
14        /// corresponding to one of the `ComponentId`s in the fetch state.
15        /// The fetch impl registers read access for all of these components,
16        /// so there will be no runtime conflicts.
17        ticks: ThinSlicePtr<'w, UnsafeCell<Tick>>,
18    },
19    SparseSet {
20        /// This gives us access to one of the components implementing the trait.
21        /// The fetch impl registers read access for all components implementing the trait,
22        /// so there will not be any runtime conflicts.
23        components: &'w ComponentSparseSet,
24    },
25}
26#[derive(Clone, Copy)]
27pub struct ChangeDetectionFetch<'w> {
28    pub(crate) storage: ChangeDetectionStorage<'w>,
29    pub(crate) sparse_sets: &'w SparseSets,
30    pub(crate) last_run: Tick,
31    pub(crate) this_run: Tick,
32}