Skip to main content

Entity I/O

Namespace: DeadworksManaged.Api

Hook into the Valve entity I/O system to observe output firings and input dispatches by entity designer name.

EntityIO

Hooking Outputs

Subscribe to outputs fired by entities with a given designer name:

var handle = EntityIO.HookOutput("trigger_multiple", "OnTrigger", ev =>
{
Console.WriteLine($"Trigger fired by entity {ev.Entity.EntityIndex}");
Console.WriteLine($"Activator: {ev.Activator?.Classname}");
});

// Cancel later
handle.Cancel();

Hooking Inputs

Subscribe to inputs dispatched to entities:

var handle = EntityIO.HookInput("func_button", "Kill", ev =>
{
Console.WriteLine($"Kill input received by {ev.Entity.Classname}");
Console.WriteLine($"Value: {ev.Value}");
});

Methods

MethodReturnsDescription
HookOutput(string designerName, string outputName, Action<EntityOutputEvent>)IHandleSubscribe to outputs by designer name and output name
HookInput(string designerName, string inputName, Action<EntityInputEvent>)IHandleSubscribe to inputs by designer name and input name

Both return an IHandle that cancels the hook when disposed or cancelled.

Limited Entity I/O Support

Entity I/O hooks work with map-placed entities that use the Source 2 I/O system (e.g. trigger_multiple, func_button). Player entities ("player") do not fire standard I/O outputs like "OnDeath" — use OnTakeDamage or GameEvents.AddListener("player_death") instead for player death detection.

EntityOutputEvent

Data for a fired entity output.

PropertyTypeDescription
EntityCBaseEntityThe entity that fired the output
ActivatorCBaseEntity?The entity that activated the output
CallerCBaseEntity?The entity that called the output
OutputNamestringName of the output (e.g. "OnTrigger")

EntityInputEvent

Data for a received entity input.

PropertyTypeDescription
EntityCBaseEntityThe entity receiving the input
ActivatorCBaseEntity?The activating entity
CallerCBaseEntity?The calling entity
InputNamestringName of the input (e.g. "Kill")
Valuestring?Optional string value passed with the input

AcceptInput

You can also fire inputs directly on entities. See Entities:

entity.AcceptInput("Start", activator: null, caller: null, value: "");
entity.AcceptInput("Kill", activator: null, caller: null, value: "");

See Also