feat: data-oriented chunks optimization with tile registry
- Phase 1: Bit-packed standability (ChunkData with bitsets) - Phase 2: Reactive connectivity (dirty chunks) - Phase 3: Async terrain baking (AsyncComputeTaskPool) - Pathfinding weight system (rock=50 preferred, bedrock=150 avoided) - Movement speed affected by tile weight - External tiles.toml for hot-reloadable tile definitions - TileRegistry singleton for async-safe tile lookups - Fixed world_to_chunk to use CHUNK_SIZE_TILE (128) not CHUNK_SIZE (8) - Fixed infinite spawner with Local<bool> state guards - Fixed spawn coordinate grid alignment Note: Zigzag pathfinding bug introduced - needs investigation
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::config::GameConfig;
|
||||
use crate::constants::TILE_SIZE;
|
||||
use crate::constants::*;
|
||||
use crate::entities::shared_components::Ambulatory;
|
||||
use crate::game::SpawnDelay;
|
||||
use crate::world::VisibleGameEntity;
|
||||
use bevy::prelude::*;
|
||||
use bevy_rand::prelude::*;
|
||||
@@ -42,18 +43,30 @@ pub fn spawn_dorfs(
|
||||
asset_server: Res<AssetServer>,
|
||||
mut rng_q: Query<&mut WyRand, With<GlobalRng>>,
|
||||
config: Res<GameConfig>,
|
||||
mut delay: ResMut<SpawnDelay>,
|
||||
mut has_spawned: Local<bool>,
|
||||
) {
|
||||
if *has_spawned {
|
||||
return;
|
||||
}
|
||||
|
||||
if delay.0 < 60 {
|
||||
delay.0 += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
*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;
|
||||
|
||||
let cit = commands
|
||||
.spawn(Dorf::new(
|
||||
&asset_server,
|
||||
Vec3::new(
|
||||
rng.random_range(-8.0f32..8.0f32).round(),
|
||||
rng.random_range(-8.0f32..8.0f32).round(),
|
||||
35.0,
|
||||
) * TILE_SIZE,
|
||||
))
|
||||
.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