Skip to content
EvilEngine.Api.Weapons

IWeaponBehaviour interface

public interface IWeaponBehaviour

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.

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;
    }
}
Assembly
EvilEngine.Api
Commit
4ff877b1

Members

Deploy method

void Deploy(IWeaponHolder holder)

Runs when the weapon is taken out, before its first Think: play its draw and hold off firing until it’s drawn.

Think method

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. The holder is new each tick, so keep what has to last on the behaviour.

Holster method

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.