> For AI agents: the complete documentation index is available at /AchReactive/en/llms.txt, the full documentation bundle is available at /AchReactive/en/llms-full.txt.

# Core concepts

## Multiplication into addition

Building a dedicated system for each domain (SkillSystem, MonsterSystem, …) means
filling in the `domain × behavior` matrix every time. AchReactive makes the **behavior pool
shared by all domains**, turning this into `domain + behavior`.

- Adding a new domain → 1 data class (0 system code)
- Reusing an existing behavior → 0 code, data only
- A genuinely new behavior → 1 function, then shared by all domains

## The four layers

```
Data Layer       IData · IDataLoader<T> · DataBase<T>      (generic, provided by the package)
Reaction Layer   Reaction · ReactionEngine · Registry      (generic, provided by the package)
Behavior Pool    [Effect("damage")] [Condition("alive")]   (written by the game, domain-agnostic)
Domain Data      SkillData · MonsterData · ItemData         (data, code-gen capable)
```

The top two layers are provided by the package and don't change. You only fill in the bottom two layers.

## Reaction = trigger → condition → effect

Every domain is expressed in the same language.

```
Reaction
 ├─ trigger      "on_use" | "on_hit" | "on_hp_below" ...
 ├─ conditions   evaluated with AND (alive, hp_below, chance ...)
 └─ effects      executed in order (damage, heal, add_modifier ...)
```

The shape is identical even across different domains.

```json
// Skill — damage on use
{ "trigger": "on_use",
  "effects": [{ "type": "damage", "params": { "power": 1.8 } }] }

// Monster — enrage when HP is at or below 30%
{ "trigger": "on_hp_below", "triggerParams": { "threshold": 0.3 },
  "effects": [{ "type": "add_modifier", "params": { "stat": "atk", "modifier": "percent_add", "value": 0.5 } }] }

// Item — aura on equip
{ "trigger": "on_equip",
  "effects": [{ "type": "add_modifier", "params": { "stat": "def", "modifier": "flat", "value": 5 } }] }
```

`add_modifier` is **one and the same code** whether a skill or an item uses it.

## Integration boundary

The game only implements two interfaces.

- **`IEntity`** — `Id`, `Position`, `Stats` (StatSheet), `IsAlive`
- **`IWorld`** — `Spawn`, `Collect`

Effects/conditions access `Source`/`Target`/`Targets`/`World` through the `ReactionContext`.

## We don't use typeof

When grouping multiple domains, we don't use a type-keyed service locator like `Dictionary<Type, object>`.
Each `DataBase<T>` is **held explicitly**, and effects that need cross-domain references are
solved with [manual registration + closure capture](/AchReactive/en/usage/extending.md#cross-domain).

```csharp
public sealed class GameDataContext
{
    public readonly DataBase<SkillData>   Skills   = new();
    public readonly DataBase<MonsterData> Monsters = new();
}
```
