ecs: publicly expose Added/Changed and inline some things

This commit is contained in:
Carter Anderson 2020-07-22 16:19:27 -07:00
parent a4e291d9c8
commit 141044aae7
3 changed files with 8 additions and 2 deletions

View file

@ -80,7 +80,9 @@ pub use borrow::{EntityRef, Ref, RefMut};
pub use bundle::{Bundle, DynamicBundle, MissingComponent};
pub use entities::{Entity, Location, NoSuchEntity};
pub use entity_builder::{BuiltEntity, EntityBuilder};
pub use query::{Access, BatchedIter, Query, QueryBorrow, QueryIter, With, Without, Mut, Mutated};
pub use query::{
Access, Added, BatchedIter, Changed, Mut, Mutated, Query, QueryBorrow, QueryIter, With, Without,
};
pub use query_one::QueryOne;
pub use world::{ArchetypesGeneration, Component, ComponentError, Iter, SpawnBatchIter, World};

View file

@ -229,6 +229,7 @@ pub struct Mutated<'a, T> {
impl<'a, T: Component> Deref for Mutated<'a, T> {
type Target = T;
#[inline]
fn deref(&self) -> &T {
self.value
}
@ -290,6 +291,7 @@ pub struct Added<'a, T> {
impl<'a, T: Component> Deref for Added<'a, T> {
type Target = T;
#[inline]
fn deref(&self) -> &T {
self.value
}
@ -352,6 +354,7 @@ pub struct Changed<'a, T> {
impl<'a, T: Component> Deref for Changed<'a, T> {
type Target = T;
#[inline]
fn deref(&self) -> &T {
self.value
}
@ -378,6 +381,7 @@ impl<'a, T: Component> Fetch<'a> for FetchChanged<T> {
fn borrow(archetype: &Archetype) {
archetype.borrow::<T>();
}
unsafe fn get(archetype: &'a Archetype, offset: usize) -> Option<Self> {
archetype
.get_with_added_and_mutated::<T>()

View file

@ -16,6 +16,6 @@ pub mod prelude {
Commands, IntoForEachSystem, IntoQuerySystem, IntoThreadLocalSystem, Query, System,
},
world::WorldBuilderSource,
Bundle, Mutated, Component, Entity, Ref, RefMut, With, Without, World,
Added, Bundle, Changed, Component, Entity, Mutated, Ref, RefMut, With, Without, World,
};
}