# WeaponEvent record

> One entry of a weapon record's events list, which plays a look at a moment in its model's animation (Events). It matches either an event the model's sequence carries, by On, as Source's models carry them, or a point in a sequence, by Sequence and Cycle, never both. It plays one thing: an Effect, a Casing or a Sound.

Namespace `EvilEngine.Formats.Records`, assembly `EvilEngine.Formats`. Engine commit 4ff877b1.

```csharp
public sealed record WeaponEvent
```

One entry of a weapon record's `events` list, which plays a look at a moment in its model's animation ([Events](/docs/plugins/weapons#events)). It matches either an event the model's sequence carries, by [On](#on), as Source's models carry them, or a point in a sequence, by [Sequence](#sequence) and [Cycle](#cycle), never both. It plays one thing: an [Effect](#effect), a [Casing](#casing) or a [Sound](#sound).

```toml
events = [
    { sequence = "reload", cycle = 0.4, casing = "casing", at = "eject" },
    { on = "AE_MUZZLEFLASH", effect = "muzzle", at = "{2}" },
]
```

Each of [Effect](#effect), [Casing](#casing), [Sound](#sound) and [At](#at) may hold `{1}` to `{9}`, which stand for the model event's own words, so Source's events pass their attachment and sound names through. The engine fills them with [Fill](#fill).

## Members

### WeaponEvent (constructor)

```csharp
public WeaponEvent()
```

Makes an event matching nothing and playing nothing, for setting what you need.

### On (property)

```csharp
public string? On { get; init; }
```

The model event matched, from `on`, by its name or number as the model gives it, such as `AE_MUZZLEFLASH` or `6001`, in any case. `null` for an event matched by [Sequence](#sequence).

### Options (property)

```csharp
public string? Options { get; init; }
```

The words the model event's options must start with, from `options`, compared word by word in any case, or `null` to match any. Only an event with [On](#on) has them.

### Sequence (property)

```csharp
public string? Sequence { get; init; }
```

The sequence matched, from `sequence`, by name in any case, such as a glb's `fire` action. `null` for an event matched by [On](#on).

### Cycle (property)

```csharp
public double Cycle { get; init; }
```

How far through the [Sequence](#sequence) it plays, from `cycle`, from 0 at its start to 1 at its end. 0 unless set, and only an event with `Sequence` has one.

### Effect (property)

```csharp
public string? Effect { get; init; }
```

The `effect` record it plays, from `effect`: an id, or `muzzle` or `impact` for the weapon's own in the held mode. Any other bare name warns once and plays nothing.

### Casing (property)

```csharp
public string? Casing { get; init; }
```

The `casing` record it ejects, from `casing`: an id, or `casing` for the weapon's own in the held mode. Any other bare name warns once and plays nothing.

### Sound (property)

```csharp
public string? Sound { get; init; }
```

The sound it plays, from `sound`: an id, or a name from the weapon's `sounds`. A bare name that's none of them is a sound by that name in the model's namespace, as a Source model's events name its game's sounds. Empty once filled, it plays nothing.

### At (property)

```csharp
public string? At { get; init; }
```

The attachment it plays at, from `at`, or `null` for the weapon's muzzle, or its eject port for a casing.

### Matches (method)

```csharp
public bool Matches(string name, string options)
```

Whether the event matches a model event named `name` with `options`: [On](#on) is that name in any case, and `options` starts with every word of [Options](#options). An event with no `On` matches none.

### Fill (method)

```csharp
public static string Fill(string text, string options)
```

`text` with `{1}` to `{9}` replaced by the words of `options` in turn, a missing word by nothing. Text with no `{` comes back as it is.
