Command

Trait Command 

Source
pub trait Command {
    // Required methods
    fn register<B: Bundle>(&mut self);
    fn spawn<B: Bundle>(&mut self, b: B) -> Entity;
    fn spawn_many<B: Bundle, I: IntoIterator<Item = B>>(
        &mut self,
        i: I,
    ) -> Vec<Entity>;
    fn alive(&self, entity: Entity) -> Option<bool>;
    fn remove(&mut self, entity: Entity) -> bool;
    fn fetch<F: WorldFetch>(&mut self, entity: Entity) -> Option<F::Item<'_>>;
}

Required Methods§

Source

fn register<B: Bundle>(&mut self)

注册一个Bundle

Bundle生成[BundleMeta]

如果[BundleMeta]已经存在,就什么都不做

Source

fn spawn<B: Bundle>(&mut self, b: B) -> Entity

Bundle放入World

返回代表被放入WorldBundleEntity

Source

fn spawn_many<B: Bundle, I: IntoIterator<Item = B>>( &mut self, i: I, ) -> Vec<Entity>

一次性将大量同类型Bundle放入World

返回代表被放入WorldBundleEntity

Source

fn alive(&self, entity: Entity) -> Option<bool>

检查Entity的有效性

  • 返回None表示Entity指向的Bundle不存在
  • 返回[Some(true)]表示Entity有限并存在
  • 返回[Some(false)]表示Entity有限但是已经过时
Source

fn remove(&mut self, entity: Entity) -> bool

World中删除Entity代表的Bundle

返回Entity代表的Bundle是否存在

Source

fn fetch<F: WorldFetch>(&mut self, entity: Entity) -> Option<F::Item<'_>>

Entity对应的Bundle上进行WorldFetch

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§