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
//! Combat Plugin V2 - Policy-Based Design
//!
//! This plugin integrates issun-core's policy-based combat mechanic with Bevy's ECS.
//! It demonstrates how to adapt pure, engine-agnostic logic to a specific game engine.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ issun-bevy (Adapter Layer) │
//! │ │
//! │ ┌──────────────┐ ┌──────────────┐ │
//! │ │ ECS Data │─────▶│ CombatInput │ │
//! │ │ (Components) │ │ (Pure Data) │ │
//! │ └──────────────┘ └──────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌──────────────────┐ │
//! │ │ Mechanic::step() │ ◀─── issun-core │
//! │ │ (Pure Logic) │ │
//! │ └──────────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌──────────────┐ │
//! │ │ CombatState │ │
//! │ │ + Events │ │
//! │ └──────────────┘ │
//! │ │ │
//! │ ▼ │
//! │ ┌──────────────┐ ┌──────────────┐ │
//! │ │ ECS Data │◀─────│ Adapter │ │
//! │ │ (Updated) │ │ Layer │ │
//! │ └──────────────┘ └──────────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Key Design Principles
//!
//! 1. **Separation of Concerns**:
//! - `issun-core`: Pure combat 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 combat systems = different generic type parameters
//! - Type safety: invalid combinations caught by compiler
//!
//! # Usage
//!
//! ## Basic Setup
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::combat_v2::CombatPluginV2;
//! use issun_core::mechanics::combat::prelude::*;
//!
//! // Define your combat type
//! type MyGameCombat = CombatMechanic<
//! LinearDamageCalculation,
//! SubtractiveDefense,
//! NoElemental,
//! >;
//!
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(CombatPluginV2::<MyGameCombat>::default())
//! .run();
//! ```
//!
//! ## Spawning Combat Entities
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::combat_v2::{Health, Attack, Defense};
//!
//! fn spawn_knight(mut commands: Commands) {
//! commands.spawn((
//! Name::new("Knight"),
//! Health::new(100),
//! Attack { power: 30 },
//! Defense { value: 15 },
//! ));
//! }
//! ```
//!
//! ## Requesting Damage
//!
//! ```ignore
//! use bevy::prelude::*;
//! use issun_bevy::plugins::combat_v2::DamageRequested;
//!
//! fn player_attack(
//! mut commands: Commands,
//! player: Query<Entity, With<Player>>,
//! target: Query<Entity, With<Enemy>>,
//! ) {
//! let player_entity = player.single();
//! let enemy_entity = target.single();
//!
//! commands.write_message(DamageRequested {
//! attacker: player_entity,
//! target: enemy_entity,
//! });
//! }
//! ```
//!
//! # Different Combat Systems
//!
//! ## Elemental Combat (Pokémon-style)
//!
//! ```ignore
//! type ElementalCombat = CombatMechanic<
//! LinearDamageCalculation,
//! SubtractiveDefense,
//! ElementalAffinity, // Fire > Ice > Water > Fire
//! >;
//!
//! App::new()
//! .add_plugins(CombatPluginV2::<ElementalCombat>::default())
//! .run();
//! ```
//!
//! ## Modern Action RPG
//!
//! ```ignore
//! type ModernARPG = CombatMechanic<
//! ScalingDamageCalculation, // Damage = attack^1.2
//! PercentageReduction, // Defense = % reduction
//! ElementalAffinity,
//! >;
//!
//! App::new()
//! .add_plugins(CombatPluginV2::<ModernARPG>::default())
//! .run();
//! ```
// Re-exports
pub use CombatPluginV2;
pub use ;