# API

**Assembly:** `Spark.Character` **Interface:** `ICharacterPlugin` **Implementation:** `CharacterPlugin`

## Interface

```csharp
public interface ICharacterPlugin
{
    List<CharacterEntry> GetAllCharacterEntries();
    CharacterEntry GetCharacterEntry(string characterId);
    bool HasCharacterEntry(string characterId);
}
```

## Methods

### GetAllCharacterEntries

```csharp
List<CharacterEntry> GetAllCharacterEntries()
```

Returns all character entries in the database.

### GetCharacterEntry

```csharp
CharacterEntry GetCharacterEntry(string characterId)
```

Returns the character entry with the given ID, or `null` if not found.

### HasCharacterEntry

```csharp
bool HasCharacterEntry(string characterId)
```

Returns `true` if a character entry with the given ID exists.

## CharacterEntry

Inherits from `SparkDatabaseEntry`. Defines a character template.

Standard fields inherited from `SparkDatabaseEntry`:

* `id` (string): Unique identifier
* `entryName` (string): Internal name
* `displayName` (string): Player-facing name
* `description` (string): Player-facing description
* `icon` (Sprite): Character portrait/icon

The Character entry is intentionally minimal. Character depth comes from extensions added by other plugins (Combat stats, Progression, Items, etc.).

## Components

### CharacterEntity

MonoBehaviour that links a scene GameObject to a `CharacterEntry`.

```csharp
// Attach to a GameObject with SparkEntity
public class CharacterEntity : MonoBehaviour
{
    // Set in inspector: reference to the character entry
    // Provides runtime access to character data
}
```

### PlayerAvatarEntity

MonoBehaviour that marks an entity as the local player character. Registers with `SparkEntityRegistry` as the player entity.

## Save Data

| Class                           | Description                              |
| ------------------------------- | ---------------------------------------- |
| `CharacterSaveData`             | Stores character state for persistence   |
| `CharacterSaveDataRegistration` | Registers save/load with the Save plugin |

## Usage

```csharp
var charPlugin = Spark.GetPlugin<ICharacterPlugin>();
if (charPlugin != null)
{
    CharacterEntry entry = charPlugin.GetCharacterEntry("warrior_01");
    Debug.Log($"Character: {entry.DisplayName}");

    List<CharacterEntry> all = charPlugin.GetAllCharacterEntries();
    Debug.Log($"Total characters: {all.Count}");
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sparkframework.dev/documentation/developer-guide/core-systems/characters/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
