# IWeaponBehaviour interface

> What a weapon does while it's held, registered with IWeapons.Register. The server makes one for each carried item of the weapon and runs it on the server only. A behaviour whose Deploy or Think throws, or whose factory throws making it, is switched off for that item with a note, as a brain that throws is: the weapon stays in hand doing nothing, keeping what it last set, until a new one is given. A Holster that throws is noted and the switch goes on. Each kind of throw is noted once.

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

```csharp
public interface IWeaponBehaviour
```

What a weapon does while it's held, registered with [IWeapons.Register](/docs/api/iweapons#register). The server makes one for each carried item of the weapon and runs it on the server only. A behaviour whose [Deploy](#deploy) or [Think](#think) throws, or whose factory throws making it, is switched off for that item with a note, as a brain that throws is: the weapon stays in hand doing nothing, keeping what it last set, until a new one is given. A [Holster](#holster) that throws is noted and the switch goes on. Each kind of throw is noted once.

```csharp
public sealed class Torch : IWeaponBehaviour
{
    public void Think(IWeaponHolder holder)
    {
        holder.Beam = holder.Held.HasFlag(WeaponButtons.Attack)
            ? WeaponBeam.At(holder.Trace(holder.Eye, Far(holder)).End)
            : null;
    }

    public void Holster(IWeaponHolder holder)
    {
        holder.Beam = null;
    }
}
```

## Members

### Deploy (method)

```csharp
void Deploy(IWeaponHolder holder)
```

Runs when the weapon is taken out, before its first [Think](#think): play its draw and hold off firing until it's drawn.

### Think (method)

```csharp
void Think(IWeaponHolder holder)
```

Runs each tick the weapon is held, after its holder's body has moved on the tick's command, with that command's [IWeaponHolder](/docs/api/iweaponholder). The holder is new each tick, so keep what has to last on the behaviour.

### Holster (method)

```csharp
void Holster(IWeaponHolder holder)
```

Runs when the holder switches to another item, dies or loses this one. Let go of anything held and clear the beam here.
