[−][src]Struct async_ecs::world::World
Implementations
impl World
[src]
pub fn register_component<T: Component>(&mut self) where
T::Storage: Default,
[src]
T::Storage: Default,
pub fn register_component_with_storage<T, F>(&mut self, storage: F) where
T: Component,
F: FnOnce() -> T::Storage,
[src]
T: Component,
F: FnOnce() -> T::Storage,
pub fn register_resource<T: Resource>(&mut self, res: T)
[src]
pub fn resource<T: Resource>(&self) -> Ref<'_, T>
[src]
pub fn resource_mut<T: Resource>(&self) -> RefMut<'_, T>
[src]
pub fn resource_raw(&self, id: &ResourceId) -> Option<&Cell<Box<dyn Resource>>>
[src]
pub fn entities(&self) -> Read<'_, Entities>
[src]
pub fn entities_mut(&self) -> RefMut<'_, Entities>
[src]
pub fn lazy(&self) -> Read<'_, Lazy>
[src]
pub fn component<T: Component>(&self) -> ReadStorage<'_, T>
[src]
pub fn component_mut<T: Component>(&self) -> WriteStorage<'_, T>
[src]
pub fn create_entity(&mut self) -> EntityBuilder<'_>
[src]
pub fn is_alive(&self, entity: Entity) -> bool
[src]
pub async fn maintain<'_>(&'_ mut self)
[src]
Methods from Deref<Target = Resources>
pub fn entry<R>(&mut self) -> Entry<'_, R> where
R: Resource,
[src]
R: Resource,
Returns an entry for the resource with type R
.
pub fn insert<R>(&mut self, r: R) where
R: Resource,
[src]
R: Resource,
Inserts a resource into this container. If the resource existed before, it will be overwritten.
Examples
Every type satisfying Any + Send + Sync
automatically
implements Resource
, thus can be added:
struct MyRes(i32);
When you have a resource, simply insert it like this:
use async_ecs::World; let mut world = World::default(); world.insert(MyRes(5));
pub fn remove<R>(&mut self) -> Option<R> where
R: Resource,
[src]
R: Resource,
Removes a resource of type R
from this container and returns its
ownership to the caller. In case there is no such resource in this,
container, None
will be returned.
Use this method with caution; other functions and systems might assume this resource still exists. Thus, only use this if you're sure no system will try to access this resource after you removed it (or else you will get a panic).
pub fn contains<R>(&self) -> bool where
R: Resource,
[src]
R: Resource,
Returns true if the specified resource type R
exists in self
.
pub fn borrow<R>(&self) -> Ref<'_, R> where
R: Resource,
[src]
R: Resource,
Fetches the resource with the specified type T
or panics if it doesn't
exist.
Panics
Panics if the resource doesn't exist. Panics if the resource is being accessed mutably.
pub fn try_borrow<R>(&self) -> Option<Ref<'_, R>> where
R: Resource,
[src]
R: Resource,
Like fetch
, but returns an Option
instead of inserting a default
value in case the resource does not exist.
pub fn borrow_mut<R>(&self) -> RefMut<'_, R> where
R: Resource,
[src]
R: Resource,
Fetches the resource with the specified type T
mutably.
Please see fetch
for details.
Panics
Panics if the resource doesn't exist. Panics if the resource is already being accessed.
pub fn try_borrow_mut<R>(&self) -> Option<RefMut<'_, R>> where
R: Resource,
[src]
R: Resource,
Like fetch_mut
, but returns an Option
instead of inserting a default
value in case the resource does not exist.
pub fn get_mut<R: Resource>(&mut self) -> Option<&mut R>
[src]
Retrieves a resource without fetching, which is cheaper, but only
available with &mut self
.
pub fn get_resource_mut(&mut self, id: ResourceId) -> Option<&mut dyn Resource>
[src]
Retrieves a resource without fetching, which is cheaper, but only
available with &mut self
.
pub fn get_raw(&self, id: &ResourceId) -> Option<&Cell<Box<dyn Resource>>>
[src]
Get raw access to the underlying cell.
Trait Implementations
impl Default for World
[src]
impl Deref for World
[src]
type Target = Resources
The resulting type after dereferencing.
pub fn deref(&self) -> &Self::Target
[src]
impl DerefMut for World
[src]
Auto Trait Implementations
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,
pub fn get_type_id(&self) -> TypeId
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
impl<T> TryDefault for T where
T: Default,
[src]
T: Default,
pub fn try_default() -> Result<T, String>
[src]
pub fn unwrap_default() -> Self
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,