Files
dorf/src/main.rs
T
popertots 9535d65bd7 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
2026-03-19 19:15:36 +00:00

73 lines
2.3 KiB
Rust

use bevy::prelude::*;
use bevy_rand::prelude::*;
use crate::entities::{
item::{initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer},
livestock::pig::pig_drop_system,
};
use crate::game::SpawnDelay;
mod camera;
mod config;
mod constants;
mod cursor;
mod entities;
mod game;
mod world;
fn main() {
let game_config = config::GameConfig::load();
App::new()
.insert_resource(game_config)
.insert_resource(game::ZIndex(0.0))
.insert_resource(world::tiles::CurrentWorldSpriteState {
state: world::tiles::TerrainSpriteState::Inactive,
})
.insert_resource(camera::CameraMoved(false))
.insert_resource(world::tiles::QuiltCache::default())
.init_resource::<SpawnDelay>()
.add_systems(PreStartup, world::textures::initialize_textures)
.add_plugins(
DefaultPlugins
.set(WindowPlugin {
primary_window: Some(Window {
title: String::from("Dorf"),
..Default::default()
}),
..Default::default()
})
.set(ImagePlugin::default_nearest()),
)
.add_plugins(EntropyPlugin::<WyRand>::with_seed(
(constants::SEED as u64).to_le_bytes(),
))
.insert_resource(ClearColor(Color::srgb(0., 0., 0.)))
.add_plugins(world::WorldPlugin)
.add_plugins(entities::pathfinding::PathfindingPlugin)
.add_systems(
Startup,
(camera::spawn_panning_camera, cursor::setup_cursor),
)
.add_systems(
Update,
(
camera::scroll_events,
camera::camera_z_movement,
camera::camera_movement,
cursor::move_cursor,
entities::sentient::dorf::spawn_dorfs,
entities::livestock::pig::spawn_pigs,
entities::livestock::rabbit::spawn_rabbits,
),
)
.add_systems(Update, pig_drop_system)
.insert_resource(ItemRotationTimer::default())
.add_systems(Update, initialize_item_rotation_state)
.add_systems(
Update,
item_tile_management_system.after(initialize_item_rotation_state),
)
.run();
}