# ICrosshair interface

> One crosshair, everyone's or one player's (ICrosshairs): the layers over it and the motion played on it.

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

```csharp
public interface ICrosshair
```

One crosshair, everyone's or one player's ([ICrosshairs](/docs/api/icrosshairs)): the layers over it and the motion played on it.

Layers stay until cleared and reach the player as soon as they change. Events, reactions, holds and releases play once, in the player's next snapshot, and ease on their screen at its frame rate. Every method throws `ArgumentException` naming what's wrong when what it's given isn't a layer, a name or a reaction.

```csharp
crosshair.Play("shot");
crosshair.Hold("reload");
crosshair.Release("reload");
```

## Members

### Layers (property)

```csharp
IReadOnlyList<CrosshairLayer> Layers { get; }
```

The layers set on this crosshair, in the order they were set. What the player sees stacks them by [priority](/docs/api/crosshairlayer#priority) over everyone's.

### Set (method)

```csharp
void Set(CrosshairLayer layer)
```

Sets a [CrosshairLayer](/docs/api/crosshairlayer), replacing the one with the same [Source](/docs/api/crosshairlayer#source). Setting one equal to what's there sends nothing.

### Clear (method)

```csharp
bool Clear(string source)
```

Drops the layer with that source, and with it its locks. Returns `false` when there was none.

### Play (method)

```csharp
void Play(string name)
```

```csharp
void Play(CrosshairReaction reaction)
```

Plays a reaction once. Given an event name, `shot`, `reload` or a name of your own, it plays the shown style's reaction to that event from its record's `on` table, and nothing when the style has none, so Garry's Mod's styles stay still as Garry's Mod's do. Given a [CrosshairReaction](/docs/api/crosshairreaction), it plays that whatever the style.

An event name is lowercase letters, digits, `_` and `.`, starting with a letter, at most 64 long.

### Hold (method)

```csharp
void Hold(string name)
```

```csharp
void Hold(string key, CrosshairReaction reaction)
```

Rises to a reaction's peak and stays there until [Release](#release) with the same key, as a reload dims the crosshair for as long as it lasts. Given only a name, it holds the shown style's reaction to that event under that name. Holding a key already held does nothing; holding one that's easing back picks up from where it is.

### Release (method)

```csharp
void Release(string key)
```

Eases a held reaction back over its release seconds from wherever it is. Releasing a key nothing holds does nothing.
