fix
This commit is contained in:
@@ -30,6 +30,7 @@ use crate::entities::cargo::{Cargo, HaulSlot, Haulable};
|
|||||||
use crate::entities::tasks::components::{
|
use crate::entities::tasks::components::{
|
||||||
ChopStep, HaulStep, Task, TaskQueue, TaskState, CHOP_TICKS_DEFAULT,
|
ChopStep, HaulStep, Task, TaskQueue, TaskState, CHOP_TICKS_DEFAULT,
|
||||||
};
|
};
|
||||||
|
use crate::entities::tasks::events::TaskFailed;
|
||||||
use crate::world::chunks::ChunkMap;
|
use crate::world::chunks::ChunkMap;
|
||||||
use crate::world::generation::forestry::TreePart;
|
use crate::world::generation::forestry::TreePart;
|
||||||
use crate::world::tiles::TileMap;
|
use crate::world::tiles::TileMap;
|
||||||
@@ -82,7 +83,21 @@ pub fn demo_system(
|
|||||||
cargo_query: Query<(Entity, &Cargo), With<Haulable>>,
|
cargo_query: Query<(Entity, &Cargo), With<Haulable>>,
|
||||||
haul_slot_query: Query<&HaulSlot>,
|
haul_slot_query: Query<&HaulSlot>,
|
||||||
mut dorf_query: Query<(Entity, &mut TaskQueue, &mut TaskState, &Transform)>,
|
mut dorf_query: Query<(Entity, &mut TaskQueue, &mut TaskState, &Transform)>,
|
||||||
|
mut task_failed: MessageReader<TaskFailed>,
|
||||||
) {
|
) {
|
||||||
|
// 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 {
|
match &mut *demo_state {
|
||||||
DemoState::Idle => {
|
DemoState::Idle => {
|
||||||
// Find the nearest standing tree to (0,0).
|
// Find the nearest standing tree to (0,0).
|
||||||
|
|||||||
Reference in New Issue
Block a user