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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//! Events for territory system
use crateEvent;
use ;
use ;
/// Request to change territory control (Command Event)
///
/// This is a "command" event that requests a state change.
/// `TerritorySystem` processes this and publishes `TerritoryControlChangedEvent`.
///
/// # Example
///
/// ```ignore
/// use issun::event::EventBus;
/// use issun::plugin::territory::{TerritoryControlChangeRequested, TerritoryId};
///
/// let mut bus = resources.get_mut::<EventBus>().await.unwrap();
/// bus.publish(TerritoryControlChangeRequested {
/// id: TerritoryId::new("nova-harbor"),
/// delta: 0.1, // Increase control by 10%
/// });
/// ```
/// Request to develop a territory (Command Event)
///
/// This is a "command" event that requests development.
/// `TerritorySystem` processes this and publishes `TerritoryDevelopedEvent`.
///
/// # Example
///
/// ```ignore
/// use issun::event::EventBus;
/// use issun::plugin::territory::{TerritoryDevelopmentRequested, TerritoryId};
///
/// let mut bus = resources.get_mut::<EventBus>().await.unwrap();
/// bus.publish(TerritoryDevelopmentRequested {
/// id: TerritoryId::new("nova-harbor"),
/// });
/// ```
/// Published when territory control changes (State Change Event)
///
/// This event is published after territory control has changed.
/// It represents a **confirmed state change** and can be replicated over network.
///
/// # Example
///
/// ```ignore
/// use issun::event::EventBus;
/// use issun::plugin::territory::TerritoryControlChangedEvent;
///
/// // In a system
/// let mut bus = resources.get_mut::<EventBus>().await.unwrap();
/// let reader = bus.reader::<TerritoryControlChangedEvent>();
///
/// for event in reader.iter() {
/// println!(
/// "Territory {} control: {:.1}% → {:.1}%",
/// event.id.as_str(),
/// event.old_control * 100.0,
/// event.new_control * 100.0
/// );
/// }
/// ```
/// Published when territory is developed (State Change Event)
///
/// This event is published after territory development level increases.
/// It represents a **confirmed state change** and can be replicated over network.
///
/// # Example
///
/// ```ignore
/// use issun::event::EventBus;
/// use issun::plugin::territory::TerritoryDevelopedEvent;
///
/// // In a system
/// let mut bus = resources.get_mut::<EventBus>().await.unwrap();
/// let reader = bus.reader::<TerritoryDevelopedEvent>();
///
/// for event in reader.iter() {
/// println!(
/// "Territory {} developed: Lv{} → Lv{}",
/// event.id.as_str(),
/// event.old_level,
/// event.new_level
/// );
/// }
/// ```
/// Published when territory effects are updated (State Change Event)
///
/// This event is published when territory effects are recalculated
/// (e.g., due to policy changes, neighbor bonuses, etc.).
///
/// # Example
///
/// ```ignore
/// use issun::event::EventBus;
/// use issun::plugin::territory::TerritoryEffectsUpdatedEvent;
///
/// // In a system
/// let mut bus = resources.get_mut::<EventBus>().await.unwrap();
/// let reader = bus.reader::<TerritoryEffectsUpdatedEvent>();
///
/// for event in reader.iter() {
/// println!(
/// "Territory {} effects updated: income {:.1}x, cost {:.1}x",
/// event.id.as_str(),
/// event.effects.income_multiplier,
/// event.effects.cost_multiplier
/// );
/// }
/// ```