refactor(simulation): replace ad-hoc system ordering with TickPhase pipeline (#843)

10-phase linear pipeline: PreInput → Input → Movement → Simulation →
Economy → Storyteller → Snapshot → PostSnapshot → Knowledge → TickAdvance.

Each system assigned to exactly one phase via .in_set(TickPhase::X).
Cross-phase .after()/.before() eliminated — only intra-phase ordering
remains. Prevents schedule cycles by construction.

SimulationPlugin refactored into sub-plugins by domain:
  - InputPlugin (player actions, interactions, dialogue dispatch)
  - MovementPlugin (pathfinding, movement validation, spatial indexing)
  - SocialPlugin (conversations, sound, voice enrichment, follow state)
  - EconomyPlugin (tâtonnement tick, IPC query serving)
  - TimePlugin (chunk streaming, news ticker, tick advancement)

All other plugins (NPC, Knowledge, Perception, Storyteller, Settings,
Bridge) updated to use TickPhase assignments instead of cross-plugin
ordering constraints. BridgePlugin trimmed to bridge I/O concerns only.

Part A of #843. Parts B (multi-threaded executor) and C (background
workers) follow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 23:51:06 +02:00
co-authored by Claude Opus 4.6
parent d434235985
commit 47d4918cc8
15 changed files with 443 additions and 274 deletions
+41
View File
@@ -0,0 +1,41 @@
//! Movement phase plugin — position resolution and spatial indexing.
//!
//! All systems run in [`TickPhase::Movement`]. Intra-phase ordering:
//! - pathfinding → follow_paths → validate_movement → cleanup_path_blocked
//! - After validate_movement: spatial index, listening focus, zone crossings, tier systems
use bevy_app::prelude::*;
use bevy_ecs::schedule::IntoScheduleConfigs;
use crate::tick_phases::TickPhase;
pub struct MovementPlugin;
impl Plugin for MovementPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<super::spatial::NaiveSpatialIndex>()
.init_resource::<super::zone::ZoneCrossEventQueue>()
.init_resource::<super::zone::PreviousPlayerZone>()
.add_systems(
Update,
(
// Core movement chain (strict sequence)
super::pathfinding::compute_paths,
super::path_follow::follow_paths
.after(super::pathfinding::compute_paths),
super::movement::validate_movement
.after(super::path_follow::follow_paths),
super::path_follow::cleanup_path_blocked
.after(super::movement::validate_movement),
// Post-movement indexing (all after validate_movement, parallel with each other)
super::spatial::sync_spatial_index
.after(super::movement::validate_movement),
super::listening::update_listening_focus
.after(super::movement::validate_movement),
super::zone::detect_zone_crossings
.after(super::movement::validate_movement),
)
.in_set(TickPhase::Movement),
);
}
}