From d01763cab217c4938823c6b8b8e21acb17e1f0cc Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Tue, 12 Nov 2024 17:27:47 -0800 Subject: [PATCH] feat: re-enable block destruction animation scheduling 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 --- events/proof-of-concept/src/module/block.rs | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/events/proof-of-concept/src/module/block.rs b/events/proof-of-concept/src/module/block.rs index 02768ae4..35c381ce 100644 --- a/events/proof-of-concept/src/module/block.rs +++ b/events/proof-of-concept/src/module/block.rs @@ -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,