# Character

## 🧍 Character Class

Represents a character that can speak, display emotions, and interact with localized systems in the **FeelSpeak** framework.

> Namespace: `Esper.FeelSpeak`\
> Inherits from: `FeelSpeakObject`\
> \
> Type: `class`

***

### 📦 Fields

| Access   | Field               | Type                     | Description                                                       |
| -------- | ------------------- | ------------------------ | ----------------------------------------------------------------- |
| `public` | `sprite`            | `Sprite`                 | The base sprite that represents the character.                    |
| `public` | `characterName`     | `string`                 | Used when localization is disabled and/or for searching purposes. |
| `public` | `textSound`         | `AudioClip`              | The sound that plays for each dialogue character.                 |
| `public` | `textColor`         | `Color`                  | The text color of this character.                                 |
| `public` | `characterEmotions` | `List<CharacterEmotion>` | All character emotion data.                                       |

***

### 🧾 Properties

| Access   | Property         | Type              | Description                                      |
| -------- | ---------------- | ----------------- | ------------------------------------------------ |
| `public` | `DatabaseRecord` | `CharacterRecord` | Snapshot of the character data for the database. |

***

### 📁 Static Fields

| Access          | Field           | Type     | Description                                                                 |
| --------------- | --------------- | -------- | --------------------------------------------------------------------------- |
| `public static` | `resourcesPath` | `string` | Path to all generated character objects relative to the `Resources` folder. |

***

### 🧰 Methods

| Access   | Method                                                 | Returns     | Description                                                                     |
| -------- | ------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------- |
| `public` | `CreateCopy()`                                         | `Character` | Creates a copy of this character.                                               |
| `public` | `CopyData(Character other)`                            | `void`      | Copies all data from another character (excluding ID).                          |
| `public` | `GetName()`                                            | `string`    | Gets the character name for the selected locale or the fallback name.           |
| `public` | `GetSprite(Emotion emotion = null)`                    | `Sprite`    | Gets the sprite associated with the given emotion, or the default.              |
| `public` | `GetAnimationNameOverride(Emotion emotion)`            | `string`    | Returns the animation name override for the specified emotion, or empty string. |
| `public` | `RebuildCharacterEmotionsList(List<Emotion> emotions)` | `void`      | Rebuilds the emotion list from a given list of emotions.                        |

***

### 🧩 Nested Structs

#### `public struct CharacterEmotion`

Represents emotion-specific overrides for this character.

| Access   | Field                    | Type              | Description                                             |
| -------- | ------------------------ | ----------------- | ------------------------------------------------------- |
| `public` | `emotion`                | `Emotion`         | The emotion reference.                                  |
| `public` | `sprite`                 | `Sprite`          | Sprite for this emotion.                                |
| `public` | `idleSpriteAnimation`    | `SpriteAnimation` | The sprite animation for this emotion when not talking. |
| `public` | `talkingSpriteAnimation` | `SpriteAnimation` | The sprite animation for this emotion when talking.     |
| `public` | `soundOverride`          | `AudioClip`       | Optional override for the emotion sound.                |
| `public` | `textSoundOverride`      | `AudioClip`       | Optional override for the text sound.                   |
| `public` | `animationNameOverride`  | `string`          | Optional override for the animation name.               |
| `public` | `animationLayerOveride`  | `int`             | Optional override for the animation layer index.        |

## Getting a Character

You can get a `Character` at runtime with their ID or name with the `FeelSpeak.GetCharacter` method.

```csharp
var myCharacter = FeelSpeak.GetCharacter("character name");
```
