#[non_exhaustive]pub enum Modifier {
Attributes(Arc<BlockAttributes>),
Tag(Be),
Quote(Quote),
Rotate(GridRotation),
Composite(Composite),
Zoom(Zoom),
Move(Move),
Inventory(Inventory),
}Expand description
Modifiers can be applied to a Block to change the result of
evaluate()ing it, and thus create variations, such as rotations
or combinations of multiple blocks.
§Usage
Most modifiers have their own dedicated structs, such as Composite; these may
be converted to Modifier using their From implementations, or by constructing
the enum variant (Modifier::Composite) explicitly. Some modifiers have specific
functions for constructing their typical usages, such as Block::rotate().
Block::with_modifier() is provided to conveniently add a single modifier to a block;
Block::modifiers() and Block::modifiers_mut() provide general direct access.
Note that Block is a clone-on-write type for when modifiers are changed.
§Arranging modifiers
Operations which add or remove modifiers, such as Block::rotate(),
follow some general principles and special cases:
- There should not be consecutive
Rotatemodifiers, but a single one with the combined rotation.Block::rotate()maintains this property. - It is preferable to have
Rotateappear last, since rotation and unrotation is part of player interaction, and the identity of block modifiers, not just their final result, determines whether blocks are equal for purposes of inventory management.Composite::compose_or_replace()avoids applyingCompositeafterRotate, so that rotated versions of the same combination are represented identically.
There is not yet any general “algebra” defining all cases where combinations of
modifiers should be canonicalized to other forms. Future versions of All is Cubes may
do so; that will be a breaking change (particularly since Block::modifiers_mut()
exists, so no rules are currently enforceable).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Attributes(Arc<BlockAttributes>)
Sets or overrides the attributes of the block.
Tag(Be)
Applies the given tag to this block.
Quote(Quote)
Suppresses all behaviors of the Block that might affect the space around it,
(or itself).
Rotate(GridRotation)
Rotate the block about its cube center by the given rotation.
This modifier should normally be used by means of Block::rotate().
Composite(Composite)
Combine the voxels of multiple blocks using some per-voxel rule.
Zoom(Zoom)
Zoom in on a portion of the block; become part of a multi-block structure whose parts are parts of the original block.
Move(Move)
Displace the block out of the grid, cropping it.
Inventory(Inventory)
The block has an inventory (e.g. a chest, a dropped item, a machine).
The effects this inventory has on the evaluation of this block are determined by
the InvInBlock stored in BlockAttributes::inventory.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Modifier
impl<'arbitrary> Arbitrary<'arbitrary> for Modifier
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl From<BlockAttributes> for Modifier
impl From<BlockAttributes> for Modifier
Source§fn from(value: BlockAttributes) -> Self
fn from(value: BlockAttributes) -> Self
Converts BlockAttributes to a modifier that applies them to a block.
Source§impl VisitHandles for Modifier
impl VisitHandles for Modifier
Source§fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
impl Eq for Modifier
impl StructuralPartialEq for Modifier
Auto Trait Implementations§
impl Freeze for Modifier
impl RefUnwindSafe for Modifier
impl Send for Modifier
impl Sync for Modifier
impl Unpin for Modifier
impl UnwindSafe for Modifier
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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