pub struct BehaviorSet<H: Host> { /* private fields */ }Expand description
Collects Behaviors and invokes them.
Note: This type is public out of necessity because it is revealed elsewhere, but its details are currently subject to change.
To modify the set, use a BehaviorSetTransaction.
§Serialization stability warning
This type implements serde::Serialize and serde::Deserialize, but serialization
support is still experimental (as is the game data model in general). We do not guarantee that future versions of all-is-cubes
will be able to deserialize data which is serialized by this version.
Additionally, the serialization schema is designed with serde_json in mind. It is not
guaranteed that using a different data format crate, which may use a different subset of
the information exposed via serde::Serialize, will produce stable results.
Implementations§
Source§impl<H: Host> BehaviorSet<H>
impl<H: Host> BehaviorSet<H>
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty BehaviorSet.
Sourcepub fn query<T: Behavior<H>>(
&self,
) -> impl Iterator<Item = QueryItem<'_, H, T>> + '_
pub fn query<T: Behavior<H>>( &self, ) -> impl Iterator<Item = QueryItem<'_, H, T>> + '_
Find behaviors of a specified type.
The behaviors will be returned in a deterministic order. In the current implementation, that order is the order in which they were added.
TODO: Allow querying by attachment details (spatial, etc)
Sourcepub fn query_any<'a>(
&'a self,
type_filter: Option<TypeId>,
) -> impl Iterator<Item = QueryItem<'a, H, dyn Behavior<H> + 'static>> + 'a
pub fn query_any<'a>( &'a self, type_filter: Option<TypeId>, ) -> impl Iterator<Item = QueryItem<'a, H, dyn Behavior<H> + 'static>> + 'a
Find behaviors by filter criteria. All Nones mean “anything”.
The behaviors will be returned in a deterministic order. In the current implementation, that order is the order in which they were added.
TODO: Allow querying by attachment details (spatial, etc)
Trait Implementations§
Source§impl<H: Host> Clone for BehaviorSet<H>
impl<H: Host> Clone for BehaviorSet<H>
Source§impl<H: Host> Component for BehaviorSet<H>
impl<H: Host> Component for BehaviorSet<H>
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
requiree: ComponentId,
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
Component::on_add, etc.)ComponentHooks.Source§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl<H: Host> Debug for BehaviorSet<H>
impl<H: Host> Debug for BehaviorSet<H>
Source§impl<H: Host> Default for BehaviorSet<H>
impl<H: Host> Default for BehaviorSet<H>
Source§impl<'de, H> Deserialize<'de> for BehaviorSet<H>where
H: Host<Attachment: DeserializeOwned>,
impl<'de, H> Deserialize<'de> for BehaviorSet<H>where
H: Host<Attachment: DeserializeOwned>,
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<H> Serialize for BehaviorSet<H>
impl<H> Serialize for BehaviorSet<H>
Source§impl<H: Host> Transactional for BehaviorSet<H>
impl<H: Host> Transactional for BehaviorSet<H>
Source§type Transaction = BehaviorSetTransaction<H>
type Transaction = BehaviorSetTransaction<H>
Self.Source§fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
self,
equivalent to the following steps: Read moreSource§impl<H: Host> VisitHandles for BehaviorSet<H>
impl<H: Host> VisitHandles for BehaviorSet<H>
Source§fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
Auto Trait Implementations§
impl<H> Freeze for BehaviorSet<H>
impl<H> !RefUnwindSafe for BehaviorSet<H>
impl<H> Send for BehaviorSet<H>
impl<H> Sync for BehaviorSet<H>
impl<H> Unpin for BehaviorSet<H>
impl<H> !UnwindSafe for BehaviorSet<H>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
Source§fn register_required_components(
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )
Bundle.Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more