pub struct State;
Expand description
The main server state.
This struct is passed to systems and event handlers. It provides access to entities, components, blocks, resources, etc.
Implementations§
Source§impl State
impl State
Sourcepub fn block(&self, _pos: BlockPosition) -> Result<BlockId, ChunkNotLoaded>
pub fn block(&self, _pos: BlockPosition) -> Result<BlockId, ChunkNotLoaded>
Gets the block at the given position.
Returns an error if the block’s chunk is not loaded.
Sourcepub fn set_block(
&self,
_pos: BlockPosition,
_block: BlockId,
) -> Result<(), ChunkNotLoaded>
pub fn set_block( &self, _pos: BlockPosition, _block: BlockId, ) -> Result<(), ChunkNotLoaded>
Sets the block at the given position.
Returns an error if the block’s chunk is not loaded.
Sourcepub fn resource<T: Resource>(&self) -> Result<&T, MissingResource>
pub fn resource<T: Resource>(&self) -> Result<&T, MissingResource>
Gets a reference to a resource.
Returns an error if the resource does not exist.
Sourcepub fn resource_mut<T: Resource>(&self) -> Result<&mut T, MissingResource>
pub fn resource_mut<T: Resource>(&self) -> Result<&mut T, MissingResource>
Gets a mutable reference to a resource.
Returns an error if the resource does not exist.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more