Description
The TrapButtons
method is a part of the IGameInstance
interface in the Sandbox namespace. This method is designed to capture button inputs and pass them to a specified callback function. It is a virtual method, allowing for potential overrides in derived classes.
Usage
To use the TrapButtons
method, you need to implement the IGameInstance
interface in your class. This method requires a single parameter, a callback function of type System.Action<System.String[]>
. The callback function will receive an array of strings representing the button inputs that have been trapped.
Example
public class MyGameInstance : IGameInstance
{
public void TrapButtons(System.Action<string[]> callback)
{
// Implementation to trap button inputs
// Example: Simulate trapping of button inputs
string[] trappedButtons = { "ButtonA", "ButtonB" };
callback(trappedButtons);
}
// Other IGameInstance method implementations
public void ResetBinds() { /* Implementation */ }
public void SaveBinds() { /* Implementation */ }
public string GetBind(string actionName, out bool isDefault, out bool isCommon) { /* Implementation */ return null; }
public void SetBind(string actionName, string buttonName) { /* Implementation */ }
}