> For the complete documentation index, see [llms.txt](https://docs.sparkframework.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sparkframework.dev/documentation/developer-guide/plugins/classes/api.md).

# API

**Assembly:** `Spark.Classes` **Interface:** `IClassesPlugin` **Implementation:** `ClassesPlugin`

## Interface

```csharp
public interface IClassesPlugin
{
    // Database queries
    List<ClassEntry> GetAllClasses();
    ClassEntry GetClass(string classId);

    // Main class
    void SetMainClass(string entityId, string classId,
        GameObject source = null);
    string GetMainClass(string entityId);

    // Secondary classes
    void AddSecondaryClass(string entityId, string classId,
        GameObject source = null);
    void RemoveSecondaryClass(string entityId, string classId);
    List<string> GetSecondaryClasses(string entityId);

    // Unlocking
    void UnlockClass(string entityId, string classId,
        GameObject source = null);
    bool IsClassUnlocked(string entityId, string classId);
    List<string> GetUnlockedClasses(string entityId);
}
```

## ClassEntry

Extends `SparkDatabaseEntry`. Defines a character class (Warrior, Mage, etc.).

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

## Events

| Event                | Fields                                 | Description    |
| -------------------- | -------------------------------------- | -------------- |
| `ClassSelectedEvent` | EntityId, ClassId, IsMainClass, Source | Class assigned |
| `ClassUnlockedEvent` | EntityId, ClassId, Source              | Class unlocked |

Both events are struct-based `ISparkEvent` implementations with a `Timestamp` field.

## Save Data

### ClassesSaveData

Extends `SaveDataEntry`.

| Field               | Type          | Description                   |
| ------------------- | ------------- | ----------------------------- |
| `mainClassId`       | string        | Currently selected main class |
| `secondaryClassIds` | List\<string> | Active secondary classes      |
| `unlockedClassIds`  | List\<string> | All unlocked classes          |

**Methods:**

```csharp
void SetMainClass(string classId)
string GetMainClass()
void AddSecondaryClass(string classId)
void RemoveSecondaryClass(string classId)
void UnlockClass(string classId)
List<string> GetSecondaryClasses()
List<string> GetAllUnlockedClasses()
bool IsClassUnlocked(string classId)
```

Setting a main or secondary class automatically unlocks it.

## Usage

```csharp
var classes = Spark.GetPlugin<IClassesPlugin>();
if (classes != null)
{
    // Set the player's main class
    classes.SetMainClass(entityId, "warrior");

    // Add a secondary class
    classes.AddSecondaryClass(entityId, "mage");

    // Unlock a class without assigning it
    classes.UnlockClass(entityId, "ranger");

    // Query class state
    string main = classes.GetMainClass(entityId);
    var secondary = classes.GetSecondaryClasses(entityId);
    bool hasMage = classes.IsClassUnlocked(entityId, "mage");
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sparkframework.dev/documentation/developer-guide/plugins/classes/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
