Plugin cleanup
This commit is contained in:
@@ -4,3 +4,5 @@ pub mod systems;
|
||||
pub use crate::world::tiles::tilemap::CargoPlaceError;
|
||||
pub use components::{Cargo, CarryVisualState, HaulSlot, Haulable};
|
||||
pub use systems::{any_hauling, carry_visual_system, haul_encumbrance_system};
|
||||
|
||||
pub use crate::plugins::cargo::CargoPlugin;
|
||||
|
||||
@@ -63,7 +63,7 @@ use crate::constants::{
|
||||
ITILE_SIZE, PATHFINDER_HIERARCHICAL_THRESHOLD_CHUNKS, PATHFINDER_MAX_NODES,
|
||||
PATHFINDER_PROVISIONAL_NODE_LIMIT, PIXEL_RATIO, TILE_SIZE,
|
||||
};
|
||||
use crate::entities::cargo::haul_encumbrance_system;
|
||||
|
||||
use crate::entities::item::inventory::{update_encumbrance, InventoryChangedEvent};
|
||||
use crate::entities::shared_systems::constants::{
|
||||
CONVOY_DOT_THRESHOLD, ES_DIRECTION_THRESHOLD, HEAD_ON_DOT_THRESHOLD, OCCUPANCY_CROWD_THRESHOLD,
|
||||
@@ -71,7 +71,7 @@ use crate::entities::shared_systems::constants::{
|
||||
WALK_SPEED_DIVISOR,
|
||||
};
|
||||
use crate::entities::shared_systems::occupancy::{rebuild_tile_occupancy, TileOccupancy};
|
||||
use crate::entities::tasks::task_executor_system;
|
||||
|
||||
use crate::world::tiles::tile_changed::{PathfindingDirtyChunks, TileChangedEvent};
|
||||
use crate::world::tiles::TileMap;
|
||||
use crate::world::{
|
||||
@@ -232,7 +232,6 @@ impl Plugin for PathfindingPlugin {
|
||||
FixedUpdate,
|
||||
(
|
||||
rebuild_tile_occupancy,
|
||||
haul_encumbrance_system,
|
||||
update_encumbrance,
|
||||
collect_pathfinding_dirty_chunks,
|
||||
invalidate_paths_on_tile_change,
|
||||
@@ -240,7 +239,6 @@ impl Plugin for PathfindingPlugin {
|
||||
// DEPRECATED: Wandering now handled by Task::Idle in task executor
|
||||
update_wandering_targets,
|
||||
movement,
|
||||
task_executor_system,
|
||||
)
|
||||
.chain(),
|
||||
)
|
||||
|
||||
@@ -6,3 +6,5 @@ pub mod idle;
|
||||
pub use components::{Task, TaskQueue, TaskState};
|
||||
pub use events::{TaskBlocked, TaskClaimed, TaskCompleted, TaskDropped, TaskFailed};
|
||||
pub use executor::task_executor_system;
|
||||
|
||||
pub use crate::plugins::tasks::TasksPlugin;
|
||||
|
||||
+13
-15
@@ -1,14 +1,12 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_rand::prelude::*;
|
||||
|
||||
use crate::entities::{
|
||||
cargo::carry_visual_system,
|
||||
cargo::any_hauling,
|
||||
item::{initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer},
|
||||
shared_systems::digging::dig_system,
|
||||
tasks::{TaskClaimed, TaskCompleted, TaskFailed, TaskDropped, TaskBlocked},
|
||||
use crate::entities::item::{
|
||||
initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer,
|
||||
};
|
||||
use crate::game::SpawnDelay;
|
||||
use crate::plugins::{CargoPlugin, TasksPlugin, EntitiesPlugin};
|
||||
use crate::world::WorldPlugin;
|
||||
|
||||
mod camera;
|
||||
mod config;
|
||||
@@ -17,6 +15,7 @@ mod cursor;
|
||||
mod debug;
|
||||
mod entities;
|
||||
mod game;
|
||||
mod plugins;
|
||||
mod system_info;
|
||||
mod world;
|
||||
|
||||
@@ -46,13 +45,13 @@ fn main() {
|
||||
(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_message::<TaskClaimed>()
|
||||
.add_message::<TaskCompleted>()
|
||||
.add_message::<TaskFailed>()
|
||||
.add_message::<TaskDropped>()
|
||||
.add_message::<TaskBlocked>()
|
||||
.add_plugins((
|
||||
WorldPlugin,
|
||||
EntitiesPlugin,
|
||||
CargoPlugin,
|
||||
TasksPlugin,
|
||||
entities::pathfinding::PathfindingPlugin,
|
||||
))
|
||||
.add_systems(
|
||||
Startup,
|
||||
(camera::spawn_panning_camera, cursor::setup_cursor),
|
||||
@@ -67,7 +66,7 @@ fn main() {
|
||||
entities::sentient::dorf::spawn_dorfs,
|
||||
entities::livestock::pig::spawn_pigs,
|
||||
entities::livestock::rabbit::spawn_rabbits,
|
||||
dig_system,
|
||||
entities::shared_systems::digging::dig_system,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -78,6 +77,5 @@ fn main() {
|
||||
item_tile_management_system.after(initialize_item_rotation_state),
|
||||
)
|
||||
.add_systems(Update, debug::entity_dump::dump_entity_positions)
|
||||
.add_systems(Update, carry_visual_system.run_if(any_hauling))
|
||||
.run();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//! CargoPlugin — registers cargo/haul systems and events.
|
||||
//!
|
||||
//! Systems:
|
||||
//! - haul_encumbrance_system (FixedUpdate, before update_encumbrance)
|
||||
//! - carry_visual_system (Update, run_if any_hauling)
|
||||
|
||||
use crate::entities::cargo::{any_hauling, carry_visual_system, haul_encumbrance_system};
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct CargoPlugin;
|
||||
|
||||
impl Plugin for CargoPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
FixedUpdate,
|
||||
haul_encumbrance_system.before(crate::entities::item::inventory::update_encumbrance),
|
||||
)
|
||||
.add_systems(Update, carry_visual_system.run_if(any_hauling));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//! EntitiesPlugin — aggregates entity-type plugins for clean composition.
|
||||
//!
|
||||
//! This is a meta-plugin that adds sub-plugins for each entity category.
|
||||
//! Keeps main.rs from needing to know about every entity submodule.
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct EntitiesPlugin;
|
||||
|
||||
impl Plugin for EntitiesPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
// Placeholder — entity bundles are added at spawn time via component bundles.
|
||||
// Future: add SentientPlugin, LivestockPlugin, ItemPlugin as they're created.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//! Plugin composition layer — re-exports all game plugins.
|
||||
//!
|
||||
//! main.rs should only import from this module, not reach into src/entities/*.
|
||||
|
||||
pub mod cargo;
|
||||
pub mod tasks;
|
||||
pub mod entities;
|
||||
|
||||
pub use cargo::CargoPlugin;
|
||||
pub use tasks::TasksPlugin;
|
||||
pub use entities::EntitiesPlugin;
|
||||
@@ -0,0 +1,27 @@
|
||||
//! TasksPlugin — registers task infrastructure: executor, events, idle logic.
|
||||
//!
|
||||
//! Systems:
|
||||
//! - task_executor_system (FixedUpdate, after pathfinding movement setup)
|
||||
|
||||
use crate::entities::tasks::{
|
||||
task_executor_system, TaskBlocked, TaskClaimed, TaskCompleted, TaskDropped, TaskFailed,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct TasksPlugin;
|
||||
|
||||
impl Plugin for TasksPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_message::<TaskClaimed>()
|
||||
.add_message::<TaskCompleted>()
|
||||
.add_message::<TaskFailed>()
|
||||
.add_message::<TaskDropped>()
|
||||
.add_message::<TaskBlocked>()
|
||||
.add_systems(
|
||||
FixedUpdate,
|
||||
task_executor_system
|
||||
.after(crate::entities::shared_systems::pathfinding::prepare_paths)
|
||||
.before(crate::entities::shared_systems::pathfinding::movement),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user