Skip to content

Commit

Permalink
feat: re-enable block destruction animation scheduling
Browse files Browse the repository at this point in the history
Uncomments the block destruction animation code in the `BlockModule`. This code schedules a sequence of stages (0-10) for block destruction animations, using `TOTAL_DESTRUCTION_TIME` divided into equal intervals. The animations are triggered via the `set_level_at` scheduler with a unique `sequence` identifier.

Key changes:
- Re-enables `destroy_at` scheduling for pending air blocks
- Restores animation stage scheduling using `set_level_at`
- Each stage (0-10) is scheduled with progressive delays
- Uses `fastrand` to generate unique sequence IDs
  • Loading branch information
andrewgazelka committed Nov 13, 2024
1 parent 2acf672 commit d01763c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions events/proof-of-concept/src/module/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,23 @@ impl Module for BlockModule {
compose.broadcast(&chat, SystemId(100)).send(&world).unwrap();
});

// pending_air.destroy_at.schedule(Instant::now() + TOTAL_DESTRUCTION_TIME, position);
//
// {
// let sequence = fastrand::i32(..);
// // Schedule destruction stages 0 through 9
// for stage in 0_u8..=10 { // 10 represents no animation
// let delay = TOTAL_DESTRUCTION_TIME / 10 * u32::from(stage);
// pending_air.set_level_at.schedule(
// Instant::now() + delay,
// SetLevel {
// position,
// sequence,
// stage,
// },
// );
// }
// }
pending_air.destroy_at.schedule(Instant::now() + TOTAL_DESTRUCTION_TIME, position);

{
let sequence = fastrand::i32(..);
// Schedule destruction stages 0 through 9
for stage in 0_u8..=10 { // 10 represents no animation
let delay = TOTAL_DESTRUCTION_TIME / 10 * u32::from(stage);
pending_air.set_level_at.schedule(
Instant::now() + delay,
SetLevel {
position,
sequence,
stage,
},
);
}
}
mc.to_confirm.push(EntityAndSequence {
entity: event.from,
sequence: event.sequence,
Expand Down

0 comments on commit d01763c

Please sign in to comment.