use core::{cell::UnsafeCell, panic::Location};
use bevy_ecs::{
change_detection::MaybeLocation,
change_detection::Tick,
ptr::{Ptr, ThinSlicePtr},
storage::{ComponentSparseSet, SparseSets},
};
use crate::TraitImplMeta;
pub struct OneTraitFetch<'w, Trait: ?Sized> {
pub(crate) sparse_sets: &'w SparseSets,
pub(crate) storage: FetchStorage<'w, Trait>,
pub(crate) last_run: Tick,
pub(crate) this_run: Tick,
}
impl<Trait: ?Sized> Clone for OneTraitFetch<'_, Trait> {
fn clone(&self) -> Self {
*self
}
}
impl<Trait: ?Sized> Copy for OneTraitFetch<'_, Trait> {}
pub(crate) enum FetchStorage<'w, Trait: ?Sized> {
Uninit,
Table {
column: Ptr<'w>,
added_ticks: ThinSlicePtr<'w, UnsafeCell<Tick>>,
changed_ticks: ThinSlicePtr<'w, UnsafeCell<Tick>>,
location: MaybeLocation<&'w UnsafeCell<&'static Location<'static>>>,
meta: TraitImplMeta<Trait>,
},
SparseSet {
components: &'w ComponentSparseSet,
meta: TraitImplMeta<Trait>,
},
}
impl<Trait: ?Sized> Clone for FetchStorage<'_, Trait> {
fn clone(&self) -> Self {
*self
}
}
impl<Trait: ?Sized> Copy for FetchStorage<'_, Trait> {}