Enum all_is_cubes::block::Modifier
source · #[non_exhaustive]pub enum Modifier {
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
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).
TODO(inventory): Define means for a block definition to specify the properties the inventory should have (its size, at least), and how it is rendered into the block.
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§impl PartialEq for Modifier
impl PartialEq for Modifier
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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