# IAgent interface

> A body a brain thinks for: what it is, where it is and where it's going. Distances are metres, angles degrees, times seconds. A goal, facing or command that isn't finite throws ArgumentOutOfRangeException, and so do a move's distance or speed below 0 and buttons that aren't AgentButtons; a move with no gait throws ArgumentException. Either drops the brain that asked, as any throw does.

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

```csharp
public interface IAgent
```

A body a brain thinks for: what it is, where it is and where it's going. Distances are metres, angles degrees, times seconds. A goal, facing or command that isn't finite throws `ArgumentOutOfRangeException`, and so do a move's distance or speed below 0 and buttons that aren't [AgentButtons](/docs/api/agentbuttons); a move with no gait throws `ArgumentException`. Either drops the brain that asked, as any throw does.

## Members

### Record (property)

```csharp
ContentId Record { get; }
```

The agent record the body attached, with its base and the engine's `evil:agent/default` merged under it.

### Class (property)

```csharp
ContentId? Class { get; }
```

The NPC class the body spawned as, or `null` for any other body.

### Hull (property)

```csharp
ContentId? Hull { get; }
```

The hull record its navigation and its body's size come from, or `null` when the record names none.

### Time (property)

```csharp
double Time { get; }
```

The session's time now.

### Interval (property)

```csharp
double Interval { get; }
```

How often it thinks.

### Alive (property)

```csharp
bool Alive { get; }
```

Whether the body is alive. A body that dies lets go of its agent.

### Health (property)

```csharp
int Health { get; }
```

The body's health.

### Feet (property)

```csharp
MapVector Feet { get; }
```

Where the body's feet are.

### Velocity (property)

```csharp
MapVector Velocity { get; }
```

How fast the body is moving.

### OnGround (property)

```csharp
bool OnGround { get; }
```

Whether the body stands on the ground.

### Yaw (property)

```csharp
double Yaw { get; }
```

Which way the body faces, turning towards where it moves or was asked to face at the record's `turn` rate.

### Motion (property)

```csharp
AgentMotion Motion { get; }
```

How its last [MoveTo](#moveto) is going, as an [AgentMotion](/docs/api/agentmotion).

### Goal (property)

```csharp
MapVector? Goal { get; }
```

Where it's going, or `null` when it was never sent or was stopped.

### Gait (property)

```csharp
string Gait { get; }
```

The gait its body plays: the [move](/docs/api/agentmove#gait)'s while it's moving, `idle` otherwise.

### Route (property)

```csharp
IReadOnlyList<MapVector> Route { get; }
```

The corners of its route still ahead.

### MoveTo (method)

```csharp
void MoveTo(MapVector goal, AgentMove? move = null)
```

Sends it to a point at the [move](/docs/api/agentmove)'s gait: a route over the map's navigation for its hull, followed every tick, slowing to arrive, turning, stepping round other bodies, and ending [Arrived](/docs/api/agentmotion#arrived), [Unreachable](/docs/api/agentmotion#unreachable) or [Stuck](/docs/api/agentmotion#stuck). Sending it again replaces the goal.

### Stop (method)

```csharp
void Stop()
```

Stops where it is.

### Face (method)

```csharp
void Face(double? yaw)
```

Turns it to face a yaw, even while it moves, or back to facing where it moves with `null`.

### Command (method)

```csharp
void Command(AgentCommand? command)
```

Drives the body with a raw [command](/docs/api/agentcommand) every tick, as a player's input does, while locomotion stands aside, or hands it back to locomotion with `null`.
