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§

source

fn make(self) -> Entity

Creates an entity with the components defined by this concept.

source

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);
}
source

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);
}
source

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) {
   // ...
}
source

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§

source

fn spawn(self) -> EntityId
where Self: Sized,

Spawns this concept into the world. If you want to modify state before spawning, use make instead.

Object Safety§

This trait is not object safe.

Implementors§