Skip to content

Commit

Permalink
Use Operation::StartMove to implement Tool::PushPull.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Aug 3, 2024
1 parent e9a4a35 commit 5423697
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions all-is-cubes/src/inv/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down

0 comments on commit 5423697

Please sign in to comment.