more debug
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::game::SpawnDelay;
|
||||
use crate::world::VisibleGameEntity;
|
||||
use bevy::prelude::*;
|
||||
use bevy_rand::prelude::*;
|
||||
use rand::RngExt;
|
||||
use rand::{RngExt, SeedableRng};
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Bundle)]
|
||||
@@ -67,7 +67,6 @@ impl Dorf {
|
||||
pub fn spawn_dorfs(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut rng_q: Query<&mut WyRand, With<GlobalRng>>,
|
||||
config: Res<GameConfig>,
|
||||
mut delay: ResMut<SpawnDelay>,
|
||||
mut has_spawned: Local<bool>,
|
||||
@@ -83,18 +82,24 @@ pub fn spawn_dorfs(
|
||||
|
||||
*has_spawned = true;
|
||||
|
||||
if let Ok(mut rng) = rng_q.single_mut() {
|
||||
for _ in 0..config.spawn_counts.dorfs {
|
||||
let raw_x = rng.random_range(-8.0f32..8.0f32);
|
||||
let raw_y = rng.random_range(-8.0f32..8.0f32);
|
||||
let grid_x = (raw_x / TILE_SIZE).round() * TILE_SIZE;
|
||||
let grid_y = (raw_y / TILE_SIZE).round() * TILE_SIZE;
|
||||
let grid_z = 35.0 * TILE_SIZE;
|
||||
// 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);
|
||||
|
||||
let cit = commands
|
||||
.spawn(Dorf::new(&asset_server, Vec3::new(grid_x, grid_y, grid_z)))
|
||||
.id();
|
||||
commands.entity(cit).insert(VisibleGameEntity);
|
||||
}
|
||||
for _ in 0..config.spawn_counts.dorfs {
|
||||
let raw_x = rng.random_range(-8.0f32..8.0f32);
|
||||
let raw_y = rng.random_range(-8.0f32..8.0f32);
|
||||
let grid_x = (raw_x / TILE_SIZE).round() * TILE_SIZE;
|
||||
let grid_y = (raw_y / TILE_SIZE).round() * TILE_SIZE;
|
||||
let grid_z = 35.0 * TILE_SIZE;
|
||||
|
||||
let cit = commands
|
||||
.spawn(Dorf::new(&asset_server, Vec3::new(grid_x, grid_y, grid_z)))
|
||||
.id();
|
||||
commands.entity(cit).insert(VisibleGameEntity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user