1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//! World map plugin for spatial navigation and travel simulation
//!
//! # Overview
//!
//! The WorldMap plugin manages large-scale world maps with travel simulation,
//! spatial positioning, and encounter systems. It separates static world geography
//! from dynamic travel state, enabling rich exploration gameplay with time/distance mechanics.
//!
//! # Features
//!
//! - **Graph-Based Spatial Model**: Locations connected by routes with terrain effects
//! - **Time-Based Travel Simulation**: Progress tracking with speed modifiers
//! - **Dynamic Encounter System**: Probabilistic encounters during travel
//! - **Fog of War Support**: Discover locations as you travel
//! - **Scene Integration**: Seamless transitions between world map and scenes
//! - **Pathfinding**: Dijkstra-based shortest path calculation
//!
//! # Example
//!
//! ```ignore
//! use issun::prelude::*;
//! use issun::plugin::worldmap::{WorldMapPlugin, Location, Route, Position, TerrainType};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let game = GameBuilder::new()
//! .with_plugin(WorldMapPlugin::new())
//! .build()
//! .await?;
//!
//! // Setup world map
//! let worldmap = game.get_plugin_mut::<WorldMapPlugin>().unwrap();
//!
//! // Register locations
//! worldmap.registry_mut().register_location(
//! Location::new("city_a", "City A")
//! .with_position(Position::new(0.0, 0.0))
//! .with_type(LocationType::City)
//! );
//!
//! worldmap.registry_mut().register_location(
//! Location::new("city_b", "City B")
//! .with_position(Position::new(100.0, 0.0))
//! .with_type(LocationType::Town)
//! );
//!
//! // Register route
//! worldmap.registry_mut().register_route(
//! Route::new("route_1", "city_a", "city_b")
//! .with_terrain(TerrainType::Road)
//! .with_danger(0.3)
//! );
//!
//! // Start travel
//! let travel_id = worldmap.system_mut().start_travel(
//! worldmap.state_mut(),
//! worldmap.registry(),
//! worldmap.config(),
//! "player_1",
//! "city_a",
//! "city_b",
//! ).await?;
//!
//! println!("Travel started: {}", travel_id);
//!
//! // Game loop
//! loop {
//! let delta_time = 1.0 / 60.0; // 60 FPS
//!
//! let worldmap = game.get_plugin_mut::<WorldMapPlugin>().unwrap();
//! let events = worldmap.system_mut().update(
//! worldmap.state_mut(),
//! worldmap.registry(),
//! worldmap.config(),
//! delta_time,
//! ).await;
//!
//! for event in events {
//! match event {
//! TravelEvent::Arrived { entity_id, location_id } => {
//! println!("{} arrived at {}", entity_id, location_id);
//! break;
//! }
//! TravelEvent::EncounterTriggered { entity_id, encounter } => {
//! println!("{} encountered: {}", entity_id, encounter.encounter_type);
//! }
//! _ => {}
//! }
//! }
//!
//! // Check if travel complete
//! if worldmap.state().active_travel_count() == 0 {
//! break;
//! }
//!
//! tokio::time::sleep(tokio::time::Duration::from_millis(16)).await;
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! # Performance
//!
//! - **Pathfinding**: O(E log V) with Dijkstra's algorithm
//! - **Travel Update**: O(n) where n = active travels
//! - **Encounter Check**: O(n) amortized over time
//!
//! # Architecture
//!
//! ```text
//! WorldMapPlugin
//! ├── Config (WorldMapConfig) - Global settings
//! ├── Registry (WorldMapRegistry) - Locations & routes
//! ├── State (WorldMapState) - Active travels & positions
//! ├── Service (WorldMapService) - Pure pathfinding logic
//! ├── System (WorldMapSystem) - Travel orchestration
//! └── Hook (WorldMapHook) - Customization points
//! ```
// Re-exports
pub use WorldMapConfig;
pub use *;
pub use ;
pub use WorldMapPlugin;
pub use WorldMapRegistry;
pub use WorldMapService;
pub use ;
pub use ;
pub use ;