pub struct World { /* private fields */ }

Implementations§

source§

impl World

source

pub fn new(name: &'static str) -> World

source

pub fn new_with_config(name: &'static str, resources: bool) -> World

source

pub fn from_entities( world: &World, entities: impl IntoIterator<Item = EntityId>, serializable_only: bool ) -> World

Clones all entities specified in the source world and returns a new world with them

source

pub async fn from_file( path: impl AsRef<Path> ) -> impl Future<Output = Result<World, Error>>

source

pub fn from_slice(content: &[u8]) -> Result<World, Error>

source

pub fn spawn(&mut self, entity_data: Entity) -> EntityId

source

pub fn batch_spawn( &mut self, entity_data: Entity, count: usize ) -> Vec<EntityId, Global>

source

pub fn spawn_with_id( &mut self, entity_id: EntityId, entity_data: Entity ) -> bool

Returns false if the id already exists

source

pub fn batch_spawn_with_ids( &mut self, entity_data: Entity, ids: Vec<EntityId, Global> )

source

pub fn despawn(&mut self, entity_id: EntityId) -> Option<Entity>

source

pub fn despawn_all(&mut self)

source

pub fn next_frame(&mut self)

source

pub fn set<T>( &mut self, entity_id: EntityId, component: Component<T>, value: T ) -> Result<T, ECSError>where T: ComponentValue,

source

pub fn set_entry( &mut self, entity_id: EntityId, entry: ComponentEntry ) -> Result<ComponentEntry, ECSError>

source

pub fn set_components( &mut self, entity_id: EntityId, data: Entity ) -> Result<(), ECSError>

source

pub fn set_if_changed<T>( &mut self, entity_id: EntityId, component: Component<T>, value: T ) -> Result<(), ECSError>where T: ComponentValue + PartialEq<T>,

Sets the value iff it is different to the current

source

pub fn get_mut<T>( &mut self, entity_id: EntityId, component: Component<T> ) -> Result<&mut T, ECSError>where T: ComponentValue,

source

pub fn get<T>( &self, entity_id: EntityId, component: Component<T> ) -> Result<T, ECSError>where T: Copy + ComponentValue,

source

pub fn get_cloned<T>( &self, entity_id: EntityId, component: Component<T> ) -> Result<T, ECSError>where T: Clone + ComponentValue,

source

pub fn get_ref<T>( &self, entity_id: EntityId, component: Component<T> ) -> Result<&T, ECSError>where T: ComponentValue,

source

pub fn get_entry( &self, entity_id: EntityId, component: ComponentDesc ) -> Result<ComponentEntry, ECSError>

source

pub fn has_component_index( &self, entity_id: EntityId, component_index: u32 ) -> bool

source

pub fn has_component_ref( &self, entity_id: EntityId, component: impl Into<ComponentDesc> ) -> bool

source

pub fn has_component( &self, entity_id: EntityId, component: impl Into<ComponentDesc> ) -> bool

source

pub fn has_components( &self, entity_id: EntityId, components: &ComponentSet ) -> bool

source

pub fn get_components( &self, entity_id: EntityId ) -> Result<Vec<ComponentDesc, Global>, ECSError>

source

pub fn clone_entity(&self, entity_id: EntityId) -> Result<Entity, ECSError>

source

pub fn entities(&self) -> Vec<(EntityId, Entity), Global>

source

pub fn exists(&self, entity_id: EntityId) -> bool

source

pub fn add_components( &mut self, entity_id: EntityId, data: Entity ) -> Result<(), ECSError>

source

pub fn add_component<T>( &mut self, entity_id: EntityId, component: Component<T>, value: T ) -> Result<(), ECSError>where T: ComponentValue,

source

pub fn add_resource<T>(&mut self, component: Component<T>, value: T)where T: ComponentValue,

source

pub fn remove_component( &mut self, entity_id: EntityId, component: impl Into<ComponentDesc> ) -> Result<(), ECSError>

Does nothing if the component does not exist

source

pub fn remove_components( &mut self, entity_id: EntityId, components: Vec<ComponentDesc, Global> ) -> Result<(), ECSError>

source

pub fn resource_entity(&self) -> EntityId

source

pub fn resource_opt<T>(&self, component: Component<T>) -> Option<&T>where T: ComponentValue,

source

pub fn resource<T>(&self, component: Component<T>) -> &Twhere T: ComponentValue,

source

pub fn resource_mut_opt<T>(&mut self, component: Component<T>) -> Option<&mut T>where T: ComponentValue,

source

pub fn resource_mut<T>(&mut self, component: Component<T>) -> &mut Twhere T: ComponentValue,

source

pub fn archetypes(&self) -> &Vec<Archetype, Global>

source

pub fn entity_loc(&self, id: EntityId) -> Option<&EntityLocation>

source

pub fn get_component_content_version( &self, entity_id: EntityId, index: u32 ) -> Result<u64, ECSError>

Returns the content version of this component, which only changes when the component is written to (not when the entity changes archetype)

source

pub fn loc_changed(&self) -> &FramedEvents<EntityId>

source

pub fn init_shape_change_tracking(&mut self)

source

pub fn reset_events(&mut self)

source

pub fn spawn_into_world( &self, world: &mut World, components: Option<Entity> ) -> Vec<EntityId, Global>

Spawn all entities of this world into the destination world

source

pub fn len(&self) -> usize

Number of entities in the world, including the resource entity

source

pub fn is_empty(&self) -> bool

source

pub fn debug_archetypes(&self) -> DebugWorldArchetypes<'_>

source

pub fn dump(&self, f: &mut dyn Write)

source

pub fn dump_to_tmp_file(&self)

source

pub fn dump_entity(&self, entity_id: EntityId, indent: usize, f: &mut dyn Write)

source

pub fn dump_entity_to_yml( &self, entity_id: EntityId ) -> Option<(String, LinkedHashMap<Yaml, Yaml, RandomState>)>

source

pub fn set_name(&mut self, name: &'static str)

source

pub fn name(&self) -> &'static str

source

pub fn add_entry( &mut self, id: EntityId, entry: ComponentEntry ) -> Result<(), ECSError>

Trait Implementations§

source§

impl Clone for World

source§

fn clone(&self) -> World

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for World

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for World

source§

fn deserialize<D>( deserializer: D ) -> Result<World, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl IndexExt for World

source§

fn sync_index( &mut self, index: Component<Index>, id: EntityId, filter: ArchetypeFilter )

source§

impl Serialize for World

source§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Send for World

source§

impl Sync for World

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for Twhere T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Gets the type name of self
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ComponentValueBase for Twhere T: Send + Sync + 'static,

source§

fn type_name(&self) -> &'static str

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> ElementComponentName for T

source§

fn element_component_name(&self) -> &'static str

Returns the name of the type implementing ElementComponent.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> AnyCloneable for Twhere T: Clone + Debug + Any + 'static,

source§

impl<T> ComponentValue for Twhere T: ComponentValueBase + Clone,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,