From 54236973fc9a87395217ba0c7a9b2efa718a4ca8 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Fri, 2 Aug 2024 17:16:04 -0700 Subject: [PATCH] Use `Operation::StartMove` to implement `Tool::PushPull`. --- all-is-cubes/src/inv/tool.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/all-is-cubes/src/inv/tool.rs b/all-is-cubes/src/inv/tool.rs index c8e4a3935..5a3d2d79c 100644 --- a/all-is-cubes/src/inv/tool.rs +++ b/all-is-cubes/src/inv/tool.rs @@ -197,23 +197,9 @@ impl Tool { } let velocity = 8; - let [move_out, move_in] = block::Move::new(direction, 0, velocity).to_paired(); - let leaving = input.set_cube( - cursor.cube(), - cursor.hit().block.clone(), - cursor.hit().block.clone().with_modifier(move_out), - )?; - let entering = input.set_cube( - cursor.cube() + direction.normal_vector(), - AIR, - cursor.hit().block.clone().with_modifier(move_in), - )?; - Ok(( - Some(self), - entering - .merge(leaving) - .expect("Push transactions conflicted???"), - )) + let op = Operation::StartMove(block::Move::new(direction, 0, velocity)); + + input.apply_operation(self.clone(), &op) } Self::Jetpack { active } => Ok(( Some(Self::Jetpack { active: !active }),