pub struct Read<'ticket> { /* private fields */ }Expand description
Read access to a Space that may be currently in a Universe.
Obtain this using Handle::read() or Space::read().
Implementations§
Source§impl Read<'_>
impl Read<'_>
Sourcepub fn bounds(&self) -> GridAab
pub fn bounds(&self) -> GridAab
Returns the GridAab describing the bounds of this space; no blocks may exist
outside it.
Sourcepub fn get_block_index(&self, position: impl Into<Cube>) -> Option<BlockIndex>
pub fn get_block_index(&self, position: impl Into<Cube>) -> Option<BlockIndex>
Returns the internal unstable numeric ID for the block at the given position,
which may be mapped to a Block by Read::block_data().
If you are looking for simple access, use space[position] (the
core::ops::Index trait) instead.
These IDs may be used to perform efficient processing of many blocks, but they may be renumbered after any mutation.
Sourcepub fn get_evaluated(&self, position: impl Into<Cube>) -> &EvaluatedBlock
pub fn get_evaluated(&self, position: impl Into<Cube>) -> &EvaluatedBlock
Returns the EvaluatedBlock of the block in this space at the given position.
If out of bounds, returns the evaluation of AIR.
Sourcepub fn get_lighting(&self, cube: impl Into<Cube>) -> PackedLight
pub fn get_lighting(&self, cube: impl Into<Cube>) -> PackedLight
Returns the light occupying the given cube.
This value may be considered as representing the average of the light reflecting off of all surfaces within, or immediately adjacent to and facing toward, this cube. If there are no such surfaces, or if the given position is out of bounds, the result is arbitrary. If the position is within an opaque block, the result is black.
Lighting is updated asynchronously after modifications, so all above claims about the meaning of this value are actually “will eventually be, if no more changes are made”.
Sourcepub fn extract<'s, C, V>(
&'s self,
bounds: GridAab,
extractor: impl FnMut(Extract<'s>) -> V,
) -> Vol<C>
pub fn extract<'s, C, V>( &'s self, bounds: GridAab, extractor: impl FnMut(Extract<'s>) -> V, ) -> Vol<C>
Copy data out of a portion of the space in a caller-chosen format.
The given bounds must be fully contained within self.bounds().
Sourcepub fn block_data(&self) -> &[SpaceBlockData]
pub fn block_data(&self) -> &[SpaceBlockData]
Returns data about all the blocks assigned internal IDs (indices) in the space, as well as placeholder data for any deallocated indices.
The indices of this slice correspond to the results of Space::get_block_index().
Sourcepub fn fluff(
&self,
) -> impl Listen<Msg = SpaceFluff, Listener = DynListener<SpaceFluff>> + '_
pub fn fluff( &self, ) -> impl Listen<Msg = SpaceFluff, Listener = DynListener<SpaceFluff>> + '_
Returns the source of fluff occurring in this space.
Sourcepub fn physics(&self) -> &SpacePhysics
pub fn physics(&self) -> &SpacePhysics
Returns the current SpacePhysics data, which determines global characteristics
such as the behavior of light and gravity.
Sourcepub fn behaviors(&self) -> &BehaviorSet<Space>
pub fn behaviors(&self) -> &BehaviorSet<Space>
Returns the BehaviorSet of behaviors attached to this space.
Trait Implementations§
Source§impl<T: Into<Cube>> Index<T> for Read<'_>
impl<T: Into<Cube>> Index<T> for Read<'_>
Source§fn index(&self, position: T) -> &Self::Output
fn index(&self, position: T) -> &Self::Output
Gets a reference to the block in this space at the given position.
If the position is out of bounds, returns AIR.
There is no corresponding IndexMut implementation;
use Mutation::set() or Mutation::fill() to modify blocks.
Source§impl Listen for Read<'_>
Registers a listener for mutations of this space.
impl Listen for Read<'_>
Registers a listener for mutations of this space.
Source§type Msg = SpaceChange
type Msg = SpaceChange
Source§type Listener = <Notifier<<Read<'_> as Listen>::Msg, Arc<dyn Listener<<Read<'_> as Listen>::Msg> + Sync + Send>> as Listen>::Listener
type Listener = <Notifier<<Read<'_> as Listen>::Msg, Arc<dyn Listener<<Read<'_> as Listen>::Msg> + Sync + Send>> as Listen>::Listener
Source§fn listen_raw(&self, listener: Self::Listener)
fn listen_raw(&self, listener: Self::Listener)
impl<'ticket> Copy for Read<'ticket>
Auto Trait Implementations§
impl<'ticket> Freeze for Read<'ticket>
impl<'ticket> !RefUnwindSafe for Read<'ticket>
impl<'ticket> Send for Read<'ticket>
impl<'ticket> Sync for Read<'ticket>
impl<'ticket> Unpin for Read<'ticket>
impl<'ticket> !UnwindSafe for Read<'ticket>
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more