- Stage 2 collision: convoy skip when entities move same direction (dot>0.7), E/S yield rule for crossings, W/N right-of-way, head-on unchanged - TileChangedEvent (Message) + PathfindingDirtyChunks (Resource) in new tile_changed module - collect_pathfinding_dirty_chunks / invalidate_paths_on_tile_change / clear_pathfinding_dirty_chunks in PathfindingPlugin FixedUpdate chain - TileMap::remove_floor clears HashMap + ChunkData bitsets + tile_ids - RabbitDigTimer component: rabbits dig floor below every 5s, fires TileChangedEvent and TileOcclusionEvent for path invalidation + rendering
75 lines
2.4 KiB
Rust
75 lines
2.4 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 debug;
|
|
mod entities;
|
|
mod game;
|
|
mod system_info;
|
|
mod world;
|
|
|
|
fn main() {
|
|
let game_config = config::GameConfig::load();
|
|
system_info::print_system_info(&game_config);
|
|
|
|
App::new()
|
|
.insert_resource(game_config)
|
|
.insert_resource(game::ZIndex(0.0))
|
|
.insert_resource(camera::CameraMoved(false))
|
|
.init_resource::<SpawnDelay>()
|
|
.add_systems(PreStartup, world::textures::initialize_textures)
|
|
.add_plugins(
|
|
DefaultPlugins
|
|
.set(WindowPlugin {
|
|
primary_window: Some(Window {
|
|
title: String::from("Dorf"),
|
|
present_mode: bevy::window::PresentMode::Mailbox,
|
|
..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,
|
|
entities::livestock::rabbit::rabbit_dig_system,
|
|
),
|
|
)
|
|
.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),
|
|
)
|
|
.add_systems(Update, debug::entity_dump::dump_entity_positions)
|
|
.run();
|
|
}
|