Add interaction input handling

This commit is contained in:
BuyMyMojo 2023-02-28 03:19:49 +11:00
parent 72a0daf486
commit 5772da3965
5 changed files with 116 additions and 2 deletions

View file

@ -35,6 +35,15 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Interact"",
""type"": ""Button"",
""id"": ""6d76184b-c071-44cb-b813-020b6a80a5eb"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@ -158,6 +167,28 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""748d47d0-26ed-4681-b4e6-444c65489c76"",
""path"": ""<Keyboard>/e"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Interact"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""f3791e57-b19a-4a65-ba91-e9f4484e7581"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Interact"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@ -167,6 +198,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
// Player
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Move = m_Player.FindAction("Move", throwIfNotFound: true);
m_Player_Interact = m_Player.FindAction("Interact", throwIfNotFound: true);
}
public void Dispose()
@ -229,11 +261,13 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
private readonly InputActionMap m_Player;
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
private readonly InputAction m_Player_Move;
private readonly InputAction m_Player_Interact;
public struct PlayerActions
{
private @PlayerInputActions m_Wrapper;
public PlayerActions(@PlayerInputActions wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Player_Move;
public InputAction @Interact => m_Wrapper.m_Player_Interact;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@ -246,6 +280,9 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
}
private void UnregisterCallbacks(IPlayerActions instance)
@ -253,6 +290,9 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
@Move.started -= instance.OnMove;
@Move.performed -= instance.OnMove;
@Move.canceled -= instance.OnMove;
@Interact.started -= instance.OnInteract;
@Interact.performed -= instance.OnInteract;
@Interact.canceled -= instance.OnInteract;
}
public void RemoveCallbacks(IPlayerActions instance)
@ -273,5 +313,6 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
public interface IPlayerActions
{
void OnMove(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
}
}