From dd703f05f3946f9e1a3e74bf4c918e92ede7df15 Mon Sep 17 00:00:00 2001 From: popertots Date: Sat, 21 Mar 2026 10:21:44 +0000 Subject: [PATCH] fix: remove collision_delay to eliminate movement deadlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit collision_delay was causing entities to skip step_recovery ticks, freezing movement whenever the next tile was occupied. Combined with the ordering fix (collision_delay placed before step_recovery), entities were stuck at path_index=0 indefinitely in spawn clusters. Remove collision_delay entirely — step_recovery already provides the per-tick pacing, and the natural next-tick retry (via left-step or normal movement) handles occupied tiles without an artificial delay. Actual thresholds (grass weight=50): dorfs move after 6 ticks, pigs after 26 ticks, rabbits after 2 ticks. Without collision_delay interference, movement is now governed purely by step_recovery. --- src/entities/livestock/pig.rs | 1 - src/entities/livestock/rabbit.rs | 1 - src/entities/sentient/dorf.rs | 1 - src/entities/shared_components/ambulatory.rs | 2 -- src/entities/shared_systems/pathfinding.rs | 30 +++++++------------- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/entities/livestock/pig.rs b/src/entities/livestock/pig.rs index 714a975..d5304ab 100644 --- a/src/entities/livestock/pig.rs +++ b/src/entities/livestock/pig.rs @@ -30,7 +30,6 @@ impl Pig { path_index: 0, step_recovery: 0, validation_cooldown: 0, - collision_delay: 0, }, sprite: Sprite { image: asset_server.load("pig.png"), diff --git a/src/entities/livestock/rabbit.rs b/src/entities/livestock/rabbit.rs index 9e8326a..e044043 100644 --- a/src/entities/livestock/rabbit.rs +++ b/src/entities/livestock/rabbit.rs @@ -27,7 +27,6 @@ impl Rabbit { path_index: 0, step_recovery: 0, validation_cooldown: 0, - collision_delay: 0, }, sprite: Sprite { image: asset_server.load("rabbit.png"), diff --git a/src/entities/sentient/dorf.rs b/src/entities/sentient/dorf.rs index 96a66fe..02210c0 100644 --- a/src/entities/sentient/dorf.rs +++ b/src/entities/sentient/dorf.rs @@ -27,7 +27,6 @@ impl Dorf { path_index: 0, step_recovery: 0, validation_cooldown: 0, - collision_delay: 0, }, sprite: Sprite { image: asset_server.load("dorf.png"), diff --git a/src/entities/shared_components/ambulatory.rs b/src/entities/shared_components/ambulatory.rs index a969ed4..e2f4b8d 100644 --- a/src/entities/shared_components/ambulatory.rs +++ b/src/entities/shared_components/ambulatory.rs @@ -10,7 +10,6 @@ pub struct Ambulatory { pub target: Option, pub step_recovery: u32, pub validation_cooldown: u8, - pub collision_delay: u8, } impl Default for Ambulatory { @@ -23,7 +22,6 @@ impl Default for Ambulatory { target: None, step_recovery: 0, validation_cooldown: 0, - collision_delay: 0, } } } diff --git a/src/entities/shared_systems/pathfinding.rs b/src/entities/shared_systems/pathfinding.rs index f62fe46..835b89b 100644 --- a/src/entities/shared_systems/pathfinding.rs +++ b/src/entities/shared_systems/pathfinding.rs @@ -592,11 +592,6 @@ pub fn movement( } } - if ambulatory.collision_delay > 0 { - ambulatory.collision_delay -= 1; - return; - } - if let Some(path) = &ambulatory.current_path { if ambulatory.path_index < path.len() { let next_point = path[ambulatory.path_index]; @@ -624,24 +619,21 @@ pub fn movement( transform.scale.x = -PIXEL_RATIO; } transform.translation = left_point; - return; } } - ambulatory.collision_delay = 1; - return; - } + } else { + let direction = (next_point - transform.translation).normalize(); + transform.translation = next_point; - let direction = (next_point - transform.translation).normalize(); - transform.translation = next_point; + if direction.x > 0.0 { + transform.scale.x = PIXEL_RATIO; + } else if direction.x < 0.0 { + transform.scale.x = -PIXEL_RATIO; + } - if direction.x > 0.0 { - transform.scale.x = PIXEL_RATIO; - } else if direction.x < 0.0 { - transform.scale.x = -PIXEL_RATIO; - } - - if transform.translation.distance(next_point) < TILE_SIZE { - ambulatory.path_index += 1; + if transform.translation.distance(next_point) < TILE_SIZE { + ambulatory.path_index += 1; + } } } else { ambulatory.current_path = None;