codeAPI Reference

s&box ToolAction: Toolgun input binding

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

ToolAction Enums and ToolActionEntry API Reference

ToolInput, InputMode, and ToolActionEntry are used by the toolgun system to bind actions to input slots with configurable input sampling modes.

Type Signatures

CSHARP
public enum ToolInput
{
    Primary,
    Secondary,
    Reload
}

public enum InputMode
{
    Pressed,
    Down
}

public sealed record ToolActionEntry(
    ToolInput Input,
    Func<string> Name,
    Action Callback,
    InputMode Mode = InputMode.Pressed
)
{
    public string InputAction => Input switch
    {
        ToolInput.Primary => "attack1",
        ToolInput.Secondary => "attack2",
        ToolInput.Reload => "reload",
        _ => null
    };
}

ToolInput Values

InputMode Values

  • Pressed - Fires once when the button is first pressed (edge detection)
  • Down - Fires every frame while the button is held (continuous)

ToolActionEntry Properties

Usage

CSHARP
// Register a tool action that fires on primary press
var action = new ToolActionEntry(
    ToolInput.Primary,
    () => "My Action",
    () => DoSomething(),
    InputMode.Pressed
);

// Register a continuous action on secondary
var continuousAction = new ToolActionEntry(
    ToolInput.Secondary,
    () => "Continuous",
    () => DoSomethingContinuous(),
    InputMode.Down
);

Notes

  • Used by toolgun modes to register actions for the toolgun UI
  • InputAction maps ToolInput to engine input action strings
  • Pressed is for single-trigger actions (shoot, place)
  • Down is for continuous actions (hold to charge, continuous fire)
Was this helpful?