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

# データとソース

## IData と DataBase

すべてのドメインデータは `IData`（= `string Id`）を実装します。`DataBase<T>` は `id → 정의` の
インメモリインデックスで、**すべてのドメインがこの一つのクラスをジェネリックで共有**します。

```csharp
var skills = new DataBase<SkillData>();
skills.Load(loader);              // 전체 교체
skills.Add(loader);               // 병합
SkillData s = skills.Get("fire_slash");
bool has   = skills.Has("fire_slash");
```

## ソース非依存 — IDataLoader\<T>

データをどこから読むにしても、`IDataLoader<T>` という同一の境界を通します。パッケージは2つの実装を提供します。

### JSON

Newtonsoft.Json ベースのため、最上位の配列をそのまま読み込みます。（ラッパークラス不要）

```csharp
// 문자열 직접
skills.Load(new JsonDataLoader<SkillData>(json));

// 읽기 지연 (파일/StreamingAssets/네트워크)
skills.Load(new JsonDataLoader<SkillData>(
    () => File.ReadAllText(path)));
```

```json
[
  { "id": "fire_slash", "cooldown": 5.0, "reactions": [ /* ... */ ] }
]
```

### CSV

先頭行をヘッダーとして使用し、各行を `ICsvMapper<T>` で変換します。引用符/カンマ/改行をサポートします。

```csharp
skills.Load(new CsvDataLoader<SkillData>(
    () => File.ReadAllText(path), new SkillCsvMapper()));
```

`ICsvMapper<T>` の実装体は通常 [Type Designer](/AchReactive/ja/usage/authoring-tools.md) が生成します。

### カスタムソース

バイナリ、ScriptableObject、社内フォーマットなどは `IDataLoader<T>` を実装するだけで済みます。

```csharp
public sealed class MyBinaryLoader<T> : IDataLoader<T> where T : IData
{
    public IReadOnlyList<T> Load() { /* 직접 디코딩 */ }
}
```

> エディタでは JSON、実際の運用では CSV/Remote のように、**ソースだけを差し替えれば**済みます。

## データ形式 (reactions)

ドメインデータは `EntityData` を継承します。共通フィールドは `id`、`stats`、`reactions` です。

```csharp
[Serializable]
public class SkillData : EntityData   // id / stats / reactions 상속
{
    public float cooldown;
    public float castTime;
}
```

```json
{
  "id": "fire_slash",
  "cooldown": 5.0,
  "stats": { "manaCost": 20 },
  "reactions": [
    {
      "trigger": "on_use",
      "conditions": [{ "type": "alive" }],
      "effects": [{ "type": "damage", "params": { "power": 1.8 } }]
    }
  ]
}
```

`params` は任意のキー・値（`ParamBag`）で、effect/condition が `ctx.Params.Get<float>("power")`
のように型変換して読み込みます。
