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
166
167
168
169
170
171
172
173
//! Reputation Plugin V2 - Policy-Based Design
//!
//! This plugin integrates issun-core's policy-based reputation mechanic with Bevy's ECS.
//! It demonstrates how to adapt pure, engine-agnostic scalar value management to a game engine.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ issun-bevy (Adapter Layer) │
//! │ │
//! │ ┌──────────────┐ ┌───────────────────┐ │
//! │ │ ECS Data │─────▶│ ReputationInput │ │
//! │ │ (Component) │ │ (Pure Data) │ │
//! │ └──────────────┘ └───────────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌──────────────────┐ │
//! │ │ Mechanic::step() │ ◀─── issun-core │
//! │ │ (Pure Logic) │ │
//! │ └──────────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌─────────────────┐ │
//! │ │ ReputationState │ │
//! │ │ + Events │ │
//! │ └─────────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌──────────────┐ ┌──────────────┐ │
//! │ │ ECS Data │◀─────│ Adapter │ │
//! │ │ (Updated) │ │ Layer │ │
//! │ └──────────────┘ └──────────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Key Design Principles
//!
//! 1. **Separation of Concerns**:
//! - `issun-core`: Pure reputation logic (no ECS, no Bevy)
//! - `issun-bevy`: Adapter layer (queries, components, messages)
//!
//! 2. **Zero-Cost Abstraction**:
//! - All policy composition happens at compile time
//! - No dynamic dispatch (`dyn Trait`)
//! - Equivalent performance to hand-written code
//!
//! 3. **Compile-Time Configuration**:
//! - Different reputation systems = different generic type parameters
//! - Type safety: invalid combinations caught by compiler
//!
//! # Usage
//!
//! ## Basic Setup
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::reputation_v2::ReputationPluginV2;
//! use issun_core::mechanics::reputation::prelude::*;
//!
//! // Define your reputation type
//! type NPCFavorability = ReputationMechanic<
//! LinearChange,
//! NoDecay,
//! HardClamp,
//! >;
//!
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(ReputationPluginV2::<NPCFavorability>::default())
//! .run();
//! ```
//!
//! ## Spawning Reputation Entities
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::reputation_v2::ReputationValue;
//!
//! fn spawn_npc(mut commands: Commands) {
//! commands.spawn((
//! Name::new("Village Elder"),
//! ReputationValue::new(50.0), // Neutral starting reputation
//! ));
//! }
//! ```
//!
//! ## Requesting Reputation Changes
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::reputation_v2::ReputationChangeRequested;
//!
//! fn player_helps_npc(
//! mut commands: Commands,
//! npc: Query<Entity, With<NPC>>,
//! ) {
//! let npc_entity = npc.single();
//!
//! // Good deed increases reputation
//! commands.write_message(ReputationChangeRequested {
//! entity: npc_entity,
//! delta: 10.0,
//! elapsed_time: 0,
//! });
//! }
//! ```
//!
//! # Different Reputation Systems
//!
//! ## Skill Progression (Diminishing Returns)
//!
//! ```ignore
//! type SkillProgression = ReputationMechanic<
//! LogarithmicChange, // Harder to level up at high levels
//! NoDecay,
//! HardClamp,
//! >;
//!
//! App::new()
//! .add_plugins(ReputationPluginV2::<SkillProgression>::default())
//! .run();
//! ```
//!
//! ## Durability System (Linear Decay)
//!
//! ```ignore
//! type DurabilitySystem = ReputationMechanic<
//! LinearChange,
//! LinearDecay, // Tools degrade over time
//! ZeroClamp, // Can't go below zero
//! >;
//!
//! App::new()
//! .add_plugins(ReputationPluginV2::<DurabilitySystem>::default())
//! .run();
//! ```
//!
//! ## Temporary Buff (Exponential Decay)
//!
//! ```ignore
//! type TemporaryBuff = ReputationMechanic<
//! LinearChange,
//! ExponentialDecay, // Fades quickly over time
//! ZeroClamp,
//! >;
//!
//! App::new()
//! .add_plugins(ReputationPluginV2::<TemporaryBuff>::default())
//! .run();
//! ```
//!
//! ## Rank System (Threshold-Based)
//!
//! ```ignore
//! type RankSystem = ReputationMechanic<
//! ThresholdChange, // Different gain rates at different ranks
//! NoDecay,
//! HardClamp,
//! >;
//!
//! App::new()
//! .add_plugins(ReputationPluginV2::<RankSystem>::default())
//! .run();
//! ```
// Re-exports
pub use ReputationPluginV2;
pub use ;