# IAgents interface

> Where a Plugin gives brains, through its context's Agents. An agent record names a brain by its id, and a body that attaches the record, as an NPC class's spawns do through NpcClass.Agent, thinks with it. With no Plugin registering the brain, the body stands idle.

Namespace `EvilEngine.Api.Agents`, assembly `EvilEngine.Api`. Engine commit 4ff877b1.

```csharp
public interface IAgents
```

Where a Plugin gives brains, through its context's [Agents](/docs/api/plugincontext#agents). An `agent` record names a brain by its id, and a body that attaches the record, as an NPC class's spawns do through [NpcClass.Agent](/docs/api/npcclass#agent), thinks with it. With no Plugin registering the brain, the body stands idle.

```csharp
context.Agents.Brain(ContentId.Parse("mymod:brain/wanderer"), agent => new Wanderer());
```

## Members

### Brain (method)

```csharp
void Brain(ContentId id, Func<IAgent, IBrain> create)
```

Registers a brain while the Plugin loads: `create` makes one [IBrain](/docs/api/ibrain) for each [agent](/docs/api/iagent) that attaches it. The later Plugin's wins and the earlier's comes back when it unloads. Registering after loading throws.
