InteractionInputAttribute
Method attribute that marks a method on an Interaction subclass as an input handler. Specifies an optional display name and which input phase to respond to. Used by InteractionInputTable for reflection-based callback discovery.
Definition
Namespace: Paragon.Townskeep.InteractionSystem
Assembly: Townskeep.dll
[AttributeUsage(AttributeTargets.Method)]
public class InteractionInputAttribute : AttributeInherits: System.Attribute
Remarks
This attribute is the declarative entry point for the Interaction Input subsystem. When an InteractionInputTable is constructed or deserialized, it uses reflection to scan the owning Interaction subclass for methods bearing this attribute. Each discovered method becomes a callback on an InteractionInput entry.
The Name parameter controls the input's display name and dictionary key in the InteractionInputTable. If left empty (default), the method name is split from PascalCase into a human-readable form (e.g., OnChopTree → "On Chop Tree").
Quick Lookup
Bind to default phase (performed)
[InteractionInput("ActionName")]
Bind to started phase
[InteractionInput("ActionName", InteractionInputPhase.STARTED)]
Bind to canceled phase
[InteractionInput("ActionName", InteractionInputPhase.CANCELED)]
Auto-name from method
[InteractionInput] — name derived from method name
Fields
Name
The display name and dictionary key for this input. If empty, defaults to the method name split from PascalCase.
InputPhase
The input action phase this handler responds to.
Defaults to InteractionInputPhase.PERFORMED.
Constructor
name
string
Display name and lookup key. Empty string = auto-derived from method name.
inputPhase
InteractionInputPhase
Phase to subscribe to. Defaults to PERFORMED.
Common Pitfalls
Methods only
AttributeUsage(AttributeTargets.Method) restricts this to methods. Applying it to properties, fields, or classes causes a compiler error.
Method must be Action-compatible
The attributed method is converted to a System.Action delegate via MethodInfo.CreateDelegate. It must have no parameters and return void.
Empty name uses SplitPascalCase()
When Name is empty, the method name is split via Odin's SplitPascalCase(). Ensure the method name produces a meaningful display string, as this becomes the dictionary key in the InteractionInputTable.
Examples
Named inputs
Auto-named inputs
Multiple methods on the same input
See Also
InteractionInputTable — discovers and binds methods with this attribute
InteractionInput — the input entry that holds callbacks from discovered methods
InteractionInputPhase — the phase enum used by this attribute
Last updated