Struct specs::World
[−]
[src]
pub struct World<C = ()> where C: PartialEq + Eq + Hash { /* fields omitted */ }
The World
struct contains all the data, which is entities and their components.
All methods are supposed to be valid for any context they are available in.
The type parameter C is for component identification in addition of their types.
Methods
impl<C> World<C> where C: PartialEq + Eq + Hash
[src]
fn new_w_comp_id() -> World<C>
Creates a new empty World
with the associated component id.
fn register_w_comp_id<T: Component>(&mut self, comp_id: C)
Registers a new component type and id pair.
Does nothing if the type and id pair was already registered.
fn unregister_w_comp_id<T: Component>(&mut self,
comp_id: C)
-> Option<MaskedStorage<T>>
comp_id: C)
-> Option<MaskedStorage<T>>
Unregisters a component type and id pair.
fn read_w_comp_id<T: Component>(&self,
comp_id: C)
-> Storage<T, RwLockReadGuard<Allocator>, ReadLockGuard<MaskedStorage<T>>>
comp_id: C)
-> Storage<T, RwLockReadGuard<Allocator>, ReadLockGuard<MaskedStorage<T>>>
Locks a component's storage for reading.
fn write_w_comp_id<T: Component>(&self,
comp_id: C)
-> Storage<T, RwLockReadGuard<Allocator>, WriteLockGuard<MaskedStorage<T>>>
comp_id: C)
-> Storage<T, RwLockReadGuard<Allocator>, WriteLockGuard<MaskedStorage<T>>>
Locks a component's storage for writing.
fn entities(&self) -> Entities
Returns the entity iterator.
fn create_iter(&mut self) -> CreateEntities
Returns the entity creation iterator. Can be used to create many empty entities at once without paying the locking overhead.
fn create_now(&mut self) -> EntityBuilder<C>
Creates a new entity instantly, locking the generations data.
fn delete_now(&mut self, entity: Entity)
Deletes a new entity instantly, locking the generations data.
fn create_pure(&self) -> Entity
Creates a new entity dynamically.
fn create(&self) -> EntityBuilder<C>
Creates a new entity dynamically, and starts building it.
fn delete_later(&self, entity: Entity)
Deletes an entity dynamically.
fn is_alive(&self, entity: Entity) -> bool
Returns true
if the given Entity
is alive.
fn maintain(&mut self)
Merges in the appendix, recording all the dynamically created and deleted entities into the persistent generations vector. Also removes all the abandoned components.
fn add_resource<T: Any + Send + Sync>(&mut self, resource: T)
Add a new resource to the world.
fn has_resource<T: Any + Send + Sync>(&self) -> bool
Check to see if a resource is present.
fn read_resource_now<T: Any + Send + Sync>(&self) -> ReadLockGuard<T>
Get read-only access to a resource.
fn write_resource_now<T: Any + Send + Sync>(&self) -> WriteLockGuard<T>
Get read-write access to a resource.
impl World<()>
[src]
fn new() -> World<()>
Creates a new empty World
.
fn register<T: Component>(&mut self)
Registers a new component type.
Does nothing if the component type was already registered.
fn unregister<T: Component>(&mut self) -> Option<MaskedStorage<T>>
Unregisters a component type.
impl World<()>
[src]
fn read<T: Component>(&self)
-> GatedStorage<T, RwLockReadGuard<Allocator>, ReadTicket<MaskedStorage<T>>>
-> GatedStorage<T, RwLockReadGuard<Allocator>, ReadTicket<MaskedStorage<T>>>
Request a read ticket for a particular component storage.
fn write<T: Component>(&self)
-> GatedStorage<T, RwLockReadGuard<Allocator>, WriteTicket<MaskedStorage<T>>>
-> GatedStorage<T, RwLockReadGuard<Allocator>, WriteTicket<MaskedStorage<T>>>
Request a write ticket for a particular component storage.
fn read_resource<T: Any + Send + Sync>(&self) -> ReadTicket<T>
Get read-only access to a resource.
fn write_resource<T: Any + Send + Sync>(&self) -> WriteTicket<T>
Get read-write access to a resource.