Trait ambient_api::ecs::Concept
source · pub trait Concept {
// Required methods
fn make(self) -> Entity;
fn get_spawned(id: EntityId) -> Option<Self>
where Self: Sized;
fn get_unspawned(entity: &Entity) -> Option<Self>
where Self: Sized;
fn contained_by_spawned(id: EntityId) -> bool;
fn contained_by_unspawned(entity: &Entity) -> bool;
// Provided method
fn spawn(self) -> EntityId
where Self: Sized { ... }
}
Expand description
Concepts are defined in the package manifest, and are used to define a collection of components that correspond to some concept in the game world.
For example, a Camera
concept might describe a camera in the game world, and have a near
and projection
component.
Required Methods§
sourcefn get_spawned(id: EntityId) -> Option<Self>where
Self: Sized,
fn get_spawned(id: EntityId) -> Option<Self>where
Self: Sized,
If the entity with id
exists and has the components defined by this concept, returns this concept with all of the values of the components in the entity.
Examples
if let Some(camera) = Camera::get_spawned(id) {
println!("{}", camera.near);
}
sourcefn get_unspawned(entity: &Entity) -> Option<Self>where
Self: Sized,
fn get_unspawned(entity: &Entity) -> Option<Self>where
Self: Sized,
If the entity
has the components defined by this concept, returns this concept with all of the values of the components in the entity.
Examples
if let Some(camera) = Camera::get_unspawned(ent) {
println!("{}", camera.near);
}
sourcefn contained_by_spawned(id: EntityId) -> bool
fn contained_by_spawned(id: EntityId) -> bool
Returns true if id
exists and contains the components defined by this concept.
Examples
if Camera::contained_by_spawned(id) {
// ...
}
sourcefn contained_by_unspawned(entity: &Entity) -> bool
fn contained_by_unspawned(entity: &Entity) -> bool
Returns true if contains the components defined by this concept.
Examples
if Camera::contained_by_unspawned(ent) {
// ...
}
Provided Methods§
Object Safety§
This trait is not object safe.