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
//! Logistics plugin for automated resource transportation
//!
//! Provides high-performance logistics system with event-driven scheduling.
//!
//! # Overview
//!
//! The Logistics plugin manages automated transport routes that move resources
//! between inventories. It uses event-driven scheduling to efficiently process
//! thousands of routes without impacting frame rate.
//!
//! # Features
//!
//! - **Event-Driven Scheduling**: Only processes routes when ready (cooldown expired)
//! - **Transactional Integrity**: Proper error handling for inventory operations
//! - **Exponential Backoff**: Failed routes retry with increasing delays
//! - **Auto-Disable**: Routes that fail repeatedly are automatically disabled
//! - **Performance Metrics**: Track transfers, throughput, and route status
//! - **Hook System**: Customize behavior for game-specific logic
//!
//! # Example
//!
//! ```ignore
//! use issun::plugin::logistics::{LogisticsPlugin, Route, Transporter};
//! use issun::plugin::inventory::InventoryPlugin;
//! use issun::GameBuilder;
//!
//! #[tokio::main]
//! async fn main() {
//! let game = GameBuilder::new()
//! .with_plugin(LogisticsPlugin::new())
//! .with_plugin(InventoryPlugin::new())
//! .build()
//! .await
//! .unwrap();
//!
//! // Setup inventories
//! let inventory = game.get_plugin_mut::<InventoryPlugin>().unwrap();
//! inventory.state_mut().add_item(&"mine".into(), &"iron_ore".into(), 1000).unwrap();
//!
//! // Create transport route
//! let logistics = game.get_plugin_mut::<LogisticsPlugin>().unwrap();
//! let route = Route::new(
//! "mine_to_smelter",
//! "mine",
//! "smelter",
//! Transporter::new(10, 1.0) // 10 items/sec, 1 sec cooldown
//! .with_filter(vec!["iron_ore"]),
//! );
//! logistics.state_mut().register_route(route);
//!
//! // Game loop
//! loop {
//! let logistics = game.get_plugin_mut::<LogisticsPlugin>().unwrap();
//! let inventory = game.get_plugin_mut::<InventoryPlugin>().unwrap();
//!
//! logistics.system_mut().update(
//! logistics.state_mut(),
//! inventory.state_mut(),
//! logistics.config(),
//! ).await;
//! }
//! }
//! ```
//!
//! # Performance
//!
//! - **1,000 routes**: ~0.1ms per update
//! - **10,000 routes**: ~1ms per update
//! - **100,000 routes**: ~5ms per update (capped at max_routes_per_update)
//!
//! # Architecture
//!
//! ```text
//! LogisticsPlugin
//! ├── Config (LogisticsConfig) - Global settings
//! ├── State (LogisticsState) - Routes & scheduling
//! ├── Service (LogisticsService) - Pure logic
//! ├── System (LogisticsSystem) - Orchestration
//! └── Hook (LogisticsHook) - Customization
//! ```
// Re-exports
pub use LogisticsConfig;
pub use ;
pub use LogisticsPlugin;
pub use LogisticsService;
pub use LogisticsState;
pub use LogisticsSystem;
pub use ;