81 lines
2.5 KiB
Rust
81 lines
2.5 KiB
Rust
use bevy::prelude::*;
|
|
use bevy_rand::prelude::*;
|
|
|
|
use crate::entities::item::{
|
|
initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer,
|
|
};
|
|
use crate::game::SpawnDelay;
|
|
use crate::plugins::{CargoPlugin, EntitiesPlugin, TasksPlugin};
|
|
use crate::world::WorldPlugin;
|
|
|
|
mod camera;
|
|
mod config;
|
|
mod constants;
|
|
mod cursor;
|
|
mod debug;
|
|
mod entities;
|
|
mod game;
|
|
mod plugins;
|
|
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::AutoVsync,
|
|
..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((
|
|
WorldPlugin,
|
|
EntitiesPlugin,
|
|
CargoPlugin,
|
|
TasksPlugin,
|
|
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::shared_systems::digging::dig_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();
|
|
}
|