Struct all_is_cubes::behavior::BehaviorSet
source · pub struct BehaviorSet<H: BehaviorHost> { /* 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: BehaviorHost> BehaviorSet<H>
impl<H: BehaviorHost> 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: BehaviorHost> Clone for BehaviorSet<H>
impl<H: BehaviorHost> Clone for BehaviorSet<H>
source§impl<H: BehaviorHost> Debug for BehaviorSet<H>
impl<H: BehaviorHost> Debug for BehaviorSet<H>
source§impl<H: BehaviorHost> Default for BehaviorSet<H>
impl<H: BehaviorHost> Default for BehaviorSet<H>
source§impl<'de, H> Deserialize<'de> for BehaviorSet<H>where
H: BehaviorHost<Attachment: DeserializeOwned>,
impl<'de, H> Deserialize<'de> for BehaviorSet<H>where
H: BehaviorHost<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>where
H: BehaviorHost<Attachment: Serialize>,
impl<H> Serialize for BehaviorSet<H>where
H: BehaviorHost<Attachment: Serialize>,
source§impl<H: BehaviorHost> Transactional for BehaviorSet<H>
impl<H: BehaviorHost> Transactional for BehaviorSet<H>
§type Transaction = BehaviorSetTransaction<H>
type Transaction = BehaviorSetTransaction<H>
Self.source§impl<H: BehaviorHost> VisitHandles for BehaviorSet<H>
impl<H: BehaviorHost> 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<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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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