> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaworks.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Disease Class

The `Disease` class is the base class used by custom diseases. You create an instance with your disease configuration, then drive its behavior by reacting to state changes and by reading/writing persistent data.

## Creating a disease

Create a disease instance by passing the disease config object to the constructor:

```lua theme={null}
local bleeding = Disease:new(DiseasesConfig['bleeding'])
```

## State management

Diseases are state-driven through the `DiseaseState` enum.

`Disease:setState(state)`

* state (DiseaseState)

`Disease:getState()`

* Returns: DiseaseState

Use state transitions to start/stop symptoms, pause effects, etc. The exact states available depend on your resource version (see the provided `DiseaseState` enum).

## Config access

`Disease:getParameter(key)`

* key (string)
* Returns: any (value from your disease config)

This is the recommended way to read parameters from your disease configuration.

## Severity / progression

`Disease:severityStage()`

* Returns: number

Returns the current severity stage index for the disease, based on its current progression data and configuration.

## Persistent data

Each disease instance has a persistent `data` object used to store state that must survive reconnects/restarts.

<Warning>
  `data` is a proxied object. Writes to it may trigger persistence/synchronization.

  * Avoid storing temporary runtime-only values
  * Keep it small: frequent or large updates can impact performance
</Warning>

## Minimal module skeleton

Your disease module should only load if its config exists:

```lua theme={null}
if DiseasesConfig['bleeding'] then
    local bleeding = Disease:new(DiseasesConfig['bleeding'])
    -- define your behavior and register your module
end
```
