From bf81f42cedd6db2723ad134402d7d76cf3129e74 Mon Sep 17 00:00:00 2001 From: popertots Date: Sun, 22 Mar 2026 22:10:00 +0000 Subject: [PATCH] fix --- src/entities/tasks/demo.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/entities/tasks/demo.rs b/src/entities/tasks/demo.rs index ada4e72..1452226 100644 --- a/src/entities/tasks/demo.rs +++ b/src/entities/tasks/demo.rs @@ -30,6 +30,7 @@ use crate::entities::cargo::{Cargo, HaulSlot, Haulable}; use crate::entities::tasks::components::{ ChopStep, HaulStep, Task, TaskQueue, TaskState, CHOP_TICKS_DEFAULT, }; +use crate::entities::tasks::events::TaskFailed; use crate::world::chunks::ChunkMap; use crate::world::generation::forestry::TreePart; use crate::world::tiles::TileMap; @@ -82,7 +83,21 @@ pub fn demo_system( cargo_query: Query<(Entity, &Cargo), With>, haul_slot_query: Query<&HaulSlot>, mut dorf_query: Query<(Entity, &mut TaskQueue, &mut TaskState, &Transform)>, + mut task_failed: MessageReader, ) { + // Handle task failures that should reset the demo state for retry + for event in task_failed.read() { + if event.reason == "no adjacent standable tile to approach tree" { + if let DemoState::Chopping { trunk_pos, chopper } = *demo_state { + warn!( + "[DEMO] ChopTree failed for tree at {:?} (chopper={:?}): {}, resetting to Idle", + trunk_pos, chopper, event.reason + ); + *demo_state = DemoState::Idle; + } + } + } + match &mut *demo_state { DemoState::Idle => { // Find the nearest standing tree to (0,0).