pub fn use_tool(self, input: &ToolInput) -> Result<(Self, UniverseTransaction), ToolError> {
        match self {
            Self::None => Err(ToolError::NotUsable),
            Self::Activate => {
                // TODO: We have nothing to activate yet.
                Err(ToolError::NotUsable)
            }
            Self::DeleteBlock => Ok((
                self,
                input.set_cube(input.cursor().place.cube, input.cursor().block.clone(), AIR)?,
            )),
            Self::PlaceBlock(ref block) => {
                let block = block.clone();
                Ok((
                    self,
                    input.set_cube(input.cursor().place.adjacent(), AIR, block)?,
                ))
            }
            Self::CopyFromSpace => Ok((
                self,
                input.produce_item(Tool::PlaceBlock(
                    input.cursor().block.clone().unspecialize(),
                ))?,
            )),
        }
    }
/// Computes the effect of using the tool.
///
/// The effect consists of both mutations to `self` and a [`UniverseTransaction`].
/// If the transaction does not succeed, the original `Tool` value should be kept.
Computes the effect of using the tool.
The effect consists of both mutations to `self` and a [`UniverseTransaction`].
If the transaction does not succeed, the original `Tool` value should be kept.
Computes the effect of using the tool . The effect consists of both mutations to ` self ` and a [ ` UniverseTransaction ` ] . If the transaction does not succeed the original ` Tool ` value should be kept .
pub fn use_tool(self, input: &ToolInput) -> Result<(Self, UniverseTransaction), ToolError> {
        match self {
            Self::None => Err(ToolError::NotUsable),
            Self::Activate => {
                // TODO: We have nothing to activate yet.
                Err(ToolError::NotUsable)
            }
            Self::DeleteBlock => Ok((
                self,
                input.set_cube(input.cursor().place.cube, input.cursor().block.clone(), AIR)?,
            )),
            Self::PlaceBlock(ref block) => {
                let block = block.clone();
                Ok((
                    self,
                    input.set_cube(input.cursor().place.adjacent(), AIR, block)?,
                ))
            }
            Self::CopyFromSpace => Ok((
                self,
                input.produce_item(Tool::PlaceBlock(
                    input.cursor().block.clone().unspecialize(),
                ))?,
            )),
        }
    }
pub fn use_tool ( self , input : & ToolInput ) -> Result < ( Self , UniverseTransaction ) , ToolError > { match self { Self :: None => Err ( ToolError :: NotUsable ) , Self :: Activate => { // TODO: We have nothing to activate yet. Err ( ToolError :: NotUsable ) } Self :: DeleteBlock => Ok ( ( self , input . set_cube ( input . cursor ( ) . place . cube , input . cursor ( ) . block . clone ( ) , AIR ) ? , ) ) , Self :: PlaceBlock ( ref block ) => { let block = block . clone ( ) ; Ok ( ( self , input . set_cube ( input . cursor ( ) . place . adjacent ( ) , AIR , block ) ? , ) ) } Self :: CopyFromSpace => Ok ( ( self , input . produce_item ( Tool :: PlaceBlock ( input . cursor ( ) . block . clone ( ) . unspecialize ( ) , ) ) ? , ) ) , } }
Computes the effect of using the tool.
Computes the effect of using the tool .
self
input
&ToolInput