more debug
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::game::SpawnDelay;
|
|||||||
use crate::world::VisibleGameEntity;
|
use crate::world::VisibleGameEntity;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rand::prelude::*;
|
use bevy_rand::prelude::*;
|
||||||
use rand::RngExt;
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
pub struct Pig {
|
pub struct Pig {
|
||||||
@@ -47,7 +47,6 @@ impl Pig {
|
|||||||
pub fn spawn_pigs(
|
pub fn spawn_pigs(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut rng_q: Query<&mut WyRand, With<GlobalRng>>,
|
|
||||||
config: Res<GameConfig>,
|
config: Res<GameConfig>,
|
||||||
mut delay: ResMut<SpawnDelay>,
|
mut delay: ResMut<SpawnDelay>,
|
||||||
mut has_spawned: Local<bool>,
|
mut has_spawned: Local<bool>,
|
||||||
@@ -63,7 +62,12 @@ pub fn spawn_pigs(
|
|||||||
|
|
||||||
*has_spawned = true;
|
*has_spawned = true;
|
||||||
|
|
||||||
if let Ok(mut rng) = rng_q.single_mut() {
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
(crate::constants::SEED + 1).hash(&mut hasher);
|
||||||
|
let seed = hasher.finish();
|
||||||
|
let mut rng = WyRand::seed_from_u64(seed);
|
||||||
for _ in 0..config.spawn_counts.pigs {
|
for _ in 0..config.spawn_counts.pigs {
|
||||||
let raw_x = rng.random_range(-32.0f32..32.0f32);
|
let raw_x = rng.random_range(-32.0f32..32.0f32);
|
||||||
let raw_y = rng.random_range(-32.0f32..32.0f32);
|
let raw_y = rng.random_range(-32.0f32..32.0f32);
|
||||||
@@ -76,5 +80,4 @@ pub fn spawn_pigs(
|
|||||||
.id();
|
.id();
|
||||||
commands.entity(pig).insert(VisibleGameEntity);
|
commands.entity(pig).insert(VisibleGameEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::game::SpawnDelay;
|
|||||||
use crate::world::VisibleGameEntity;
|
use crate::world::VisibleGameEntity;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rand::prelude::*;
|
use bevy_rand::prelude::*;
|
||||||
use rand::RngExt;
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
pub struct Rabbit {
|
pub struct Rabbit {
|
||||||
@@ -49,7 +49,6 @@ impl Rabbit {
|
|||||||
pub fn spawn_rabbits(
|
pub fn spawn_rabbits(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut rng_q: Query<&mut WyRand, With<GlobalRng>>,
|
|
||||||
config: Res<GameConfig>,
|
config: Res<GameConfig>,
|
||||||
mut delay: ResMut<SpawnDelay>,
|
mut delay: ResMut<SpawnDelay>,
|
||||||
mut has_spawned: Local<bool>,
|
mut has_spawned: Local<bool>,
|
||||||
@@ -65,7 +64,12 @@ pub fn spawn_rabbits(
|
|||||||
|
|
||||||
*has_spawned = true;
|
*has_spawned = true;
|
||||||
|
|
||||||
if let Ok(mut rng) = rng_q.single_mut() {
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
(crate::constants::SEED + 2).hash(&mut hasher);
|
||||||
|
let seed = hasher.finish();
|
||||||
|
let mut rng = WyRand::seed_from_u64(seed);
|
||||||
for _ in 0..config.spawn_counts.rabbits {
|
for _ in 0..config.spawn_counts.rabbits {
|
||||||
let raw_x = rng.random_range(-32.0f32..32.0f32);
|
let raw_x = rng.random_range(-32.0f32..32.0f32);
|
||||||
let raw_y = rng.random_range(-32.0f32..32.0f32);
|
let raw_y = rng.random_range(-32.0f32..32.0f32);
|
||||||
@@ -81,5 +85,4 @@ pub fn spawn_rabbits(
|
|||||||
.id();
|
.id();
|
||||||
commands.entity(rab).insert(VisibleGameEntity);
|
commands.entity(rab).insert(VisibleGameEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::game::SpawnDelay;
|
|||||||
use crate::world::VisibleGameEntity;
|
use crate::world::VisibleGameEntity;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rand::prelude::*;
|
use bevy_rand::prelude::*;
|
||||||
use rand::RngExt;
|
use rand::{RngExt, SeedableRng};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
@@ -67,7 +67,6 @@ impl Dorf {
|
|||||||
pub fn spawn_dorfs(
|
pub fn spawn_dorfs(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut rng_q: Query<&mut WyRand, With<GlobalRng>>,
|
|
||||||
config: Res<GameConfig>,
|
config: Res<GameConfig>,
|
||||||
mut delay: ResMut<SpawnDelay>,
|
mut delay: ResMut<SpawnDelay>,
|
||||||
mut has_spawned: Local<bool>,
|
mut has_spawned: Local<bool>,
|
||||||
@@ -83,7 +82,14 @@ pub fn spawn_dorfs(
|
|||||||
|
|
||||||
*has_spawned = true;
|
*has_spawned = true;
|
||||||
|
|
||||||
if let Ok(mut rng) = rng_q.single_mut() {
|
// Create deterministic RNG from SEED - same pattern as forestry.rs
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
crate::constants::SEED.hash(&mut hasher);
|
||||||
|
let seed = hasher.finish();
|
||||||
|
let mut rng = WyRand::seed_from_u64(seed);
|
||||||
|
|
||||||
for _ in 0..config.spawn_counts.dorfs {
|
for _ in 0..config.spawn_counts.dorfs {
|
||||||
let raw_x = rng.random_range(-8.0f32..8.0f32);
|
let raw_x = rng.random_range(-8.0f32..8.0f32);
|
||||||
let raw_y = rng.random_range(-8.0f32..8.0f32);
|
let raw_y = rng.random_range(-8.0f32..8.0f32);
|
||||||
@@ -96,5 +102,4 @@ pub fn spawn_dorfs(
|
|||||||
.id();
|
.id();
|
||||||
commands.entity(cit).insert(VisibleGameEntity);
|
commands.entity(cit).insert(VisibleGameEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,23 @@ pub fn task_executor_system(
|
|||||||
mut completed_writer: MessageWriter<TaskCompleted>,
|
mut completed_writer: MessageWriter<TaskCompleted>,
|
||||||
mut failed_writer: MessageWriter<TaskFailed>,
|
mut failed_writer: MessageWriter<TaskFailed>,
|
||||||
) {
|
) {
|
||||||
|
eprintln!("[TASK_EXEC] Running");
|
||||||
|
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
let mut hasher = DefaultHasher::new();
|
let mut hasher = DefaultHasher::new();
|
||||||
crate::constants::SEED.hash(&mut hasher);
|
crate::constants::SEED.hash(&mut hasher);
|
||||||
time.elapsed_secs().to_bits().hash(&mut hasher);
|
time.elapsed_secs().to_bits().hash(&mut hasher);
|
||||||
let seed = hasher.finish();
|
let seed = hasher.finish();
|
||||||
|
eprintln!("[TASK_EXEC] RNG seed: {}", seed);
|
||||||
let mut rng = WyRand::seed_from_u64(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() {
|
for (entity, mut queue, mut state, mut ambulatory, transform) in query.iter_mut() {
|
||||||
// If queue empty, assign default Idle task
|
// If queue empty, assign default Idle task
|
||||||
if queue.is_empty() {
|
if queue.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user