This commit is contained in:
2026-03-22 01:52:20 +00:00
parent 9afcb0f612
commit adc236dc3d
4 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ impl Dorf {
let run_speed = 6.;
let normal_sprite = asset_server.load("dorf.png");
let carry_sprite = asset_server.load("dorf.png");
let origin = (position / TILE_SIZE).as_ivec3();
let origin = position.as_ivec3();
Dorf {
ambulatory: Ambulatory {
@@ -313,10 +313,15 @@ pub fn prepare_paths(
tilemap: Res<TileMap>,
chunk_map: Res<ChunkMap>,
) {
let mut paths_needed = 0;
let mut paths_computed = 0;
for (entity, mut ambulatory, transform) in query.iter_mut() {
if ambulatory.current_path.is_some() || ambulatory.target.is_none() {
continue;
}
paths_needed += 1;
let Some(target) = ambulatory.target else {
continue;
};
@@ -332,6 +337,7 @@ pub fn prepare_paths(
let path = calculate_path_benchmarked(&tilemap, start, goal);
ambulatory.current_path = Some(path);
ambulatory.path_index = 0;
paths_computed += 1;
} else if chunk_distance > PATHFINDER_HIERARCHICAL_THRESHOLD_CHUNKS {
let chunk_path = calculate_chunk_path(&chunk_map, start_chunk, goal_chunk);
let provisional_goal = goal;
-10
View File
@@ -34,23 +34,14 @@ pub fn task_executor_system(
mut completed_writer: MessageWriter<TaskCompleted>,
mut failed_writer: MessageWriter<TaskFailed>,
) {
eprintln!("[TASK_EXEC] Running");
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let mut hasher = DefaultHasher::new();
crate::constants::SEED.hash(&mut hasher);
time.elapsed_secs().to_bits().hash(&mut hasher);
let seed = hasher.finish();
eprintln!("[TASK_EXEC] RNG seed: {}", seed);
let mut rng = WyRand::seed_from_u64(seed);
let count = query.iter().count();
eprintln!("[TASK_EXEC] Query returned {} entities", count);
if count == 0 {
return;
}
for (entity, mut queue, mut state, mut ambulatory, transform) in query.iter_mut() {
// If queue empty, assign default Idle task
if queue.is_empty() {
@@ -86,7 +77,6 @@ pub fn task_executor_system(
&tilemap,
&mut rng,
);
// Idle never completes - it cycles forever
}
Task::GoTo {
target,
+1 -1
View File
@@ -29,7 +29,7 @@ pub(super) fn execute_idle(
return;
};
let entity_pos = (transform.translation / ITILE_SIZE as f32).as_ivec3();
let entity_pos = transform.translation.as_ivec3();
// Track if target actually changed this tick
let mut target_changed = false;