diff options
Diffstat (limited to 'Assets/Scripts/InputSystem')
| -rw-r--r-- | Assets/Scripts/InputSystem/PlayerControls.cs | 100 | ||||
| -rw-r--r-- | Assets/Scripts/InputSystem/PlayerControls.inputactions | 39 |
2 files changed, 110 insertions, 29 deletions
diff --git a/Assets/Scripts/InputSystem/PlayerControls.cs b/Assets/Scripts/InputSystem/PlayerControls.cs index c77acf2..128521d 100644 --- a/Assets/Scripts/InputSystem/PlayerControls.cs +++ b/Assets/Scripts/InputSystem/PlayerControls.cs @@ -44,15 +44,6 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable ""processors"": """", ""interactions"": """", ""initialStateCheck"": true - }, - { - ""name"": ""Roll"", - ""type"": ""Button"", - ""id"": ""5e423815-95ec-43c1-9718-224f86c8f24e"", - ""expectedControlType"": ""Button"", - ""processors"": """", - ""interactions"": """", - ""initialStateCheck"": false } ], ""bindings"": [ @@ -132,10 +123,38 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable ""action"": ""Camera"", ""isComposite"": false, ""isPartOfComposite"": false + } + ] + }, + { + ""name"": ""Player Actions"", + ""id"": ""e698248c-d44d-4c32-9308-df1fb8952042"", + ""actions"": [ + { + ""name"": ""Roll"", + ""type"": ""Button"", + ""id"": ""b5381d00-a598-472a-96b6-e7a5ed618a96"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + } + ], + ""bindings"": [ + { + ""name"": """", + ""id"": ""8af511c9-0a47-4f49-b1e0-a98500b70c9d"", + ""path"": ""<Gamepad>/buttonEast"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Roll"", + ""isComposite"": false, + ""isPartOfComposite"": false }, { ""name"": """", - ""id"": ""4690e573-c6d7-4c20-bbee-ba5d11ca8a18"", + ""id"": ""a76c6730-3d6e-4609-a3fb-450fe20ef6e2"", ""path"": ""<Keyboard>/space"", ""interactions"": """", ""processors"": """", @@ -153,7 +172,9 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable m_PlayerMovement = asset.FindActionMap("Player Movement", throwIfNotFound: true); m_PlayerMovement_Movement = m_PlayerMovement.FindAction("Movement", throwIfNotFound: true); m_PlayerMovement_Camera = m_PlayerMovement.FindAction("Camera", throwIfNotFound: true); - m_PlayerMovement_Roll = m_PlayerMovement.FindAction("Roll", throwIfNotFound: true); + // Player Actions + m_PlayerActions = asset.FindActionMap("Player Actions", throwIfNotFound: true); + m_PlayerActions_Roll = m_PlayerActions.FindAction("Roll", throwIfNotFound: true); } public void Dispose() @@ -217,14 +238,12 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable private List<IPlayerMovementActions> m_PlayerMovementActionsCallbackInterfaces = new List<IPlayerMovementActions>(); private readonly InputAction m_PlayerMovement_Movement; private readonly InputAction m_PlayerMovement_Camera; - private readonly InputAction m_PlayerMovement_Roll; public struct PlayerMovementActions { private @PlayerControls m_Wrapper; public PlayerMovementActions(@PlayerControls wrapper) { m_Wrapper = wrapper; } public InputAction @Movement => m_Wrapper.m_PlayerMovement_Movement; public InputAction @Camera => m_Wrapper.m_PlayerMovement_Camera; - public InputAction @Roll => m_Wrapper.m_PlayerMovement_Roll; public InputActionMap Get() { return m_Wrapper.m_PlayerMovement; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } @@ -240,9 +259,6 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable @Camera.started += instance.OnCamera; @Camera.performed += instance.OnCamera; @Camera.canceled += instance.OnCamera; - @Roll.started += instance.OnRoll; - @Roll.performed += instance.OnRoll; - @Roll.canceled += instance.OnRoll; } private void UnregisterCallbacks(IPlayerMovementActions instance) @@ -253,9 +269,6 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable @Camera.started -= instance.OnCamera; @Camera.performed -= instance.OnCamera; @Camera.canceled -= instance.OnCamera; - @Roll.started -= instance.OnRoll; - @Roll.performed -= instance.OnRoll; - @Roll.canceled -= instance.OnRoll; } public void RemoveCallbacks(IPlayerMovementActions instance) @@ -273,10 +286,59 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable } } public PlayerMovementActions @PlayerMovement => new PlayerMovementActions(this); + + // Player Actions + private readonly InputActionMap m_PlayerActions; + private List<IPlayerActionsActions> m_PlayerActionsActionsCallbackInterfaces = new List<IPlayerActionsActions>(); + private readonly InputAction m_PlayerActions_Roll; + public struct PlayerActionsActions + { + private @PlayerControls m_Wrapper; + public PlayerActionsActions(@PlayerControls wrapper) { m_Wrapper = wrapper; } + public InputAction @Roll => m_Wrapper.m_PlayerActions_Roll; + public InputActionMap Get() { return m_Wrapper.m_PlayerActions; } + public void Enable() { Get().Enable(); } + public void Disable() { Get().Disable(); } + public bool enabled => Get().enabled; + public static implicit operator InputActionMap(PlayerActionsActions set) { return set.Get(); } + public void AddCallbacks(IPlayerActionsActions instance) + { + if (instance == null || m_Wrapper.m_PlayerActionsActionsCallbackInterfaces.Contains(instance)) return; + m_Wrapper.m_PlayerActionsActionsCallbackInterfaces.Add(instance); + @Roll.started += instance.OnRoll; + @Roll.performed += instance.OnRoll; + @Roll.canceled += instance.OnRoll; + } + + private void UnregisterCallbacks(IPlayerActionsActions instance) + { + @Roll.started -= instance.OnRoll; + @Roll.performed -= instance.OnRoll; + @Roll.canceled -= instance.OnRoll; + } + + public void RemoveCallbacks(IPlayerActionsActions instance) + { + if (m_Wrapper.m_PlayerActionsActionsCallbackInterfaces.Remove(instance)) + UnregisterCallbacks(instance); + } + + public void SetCallbacks(IPlayerActionsActions instance) + { + foreach (var item in m_Wrapper.m_PlayerActionsActionsCallbackInterfaces) + UnregisterCallbacks(item); + m_Wrapper.m_PlayerActionsActionsCallbackInterfaces.Clear(); + AddCallbacks(instance); + } + } + public PlayerActionsActions @PlayerActions => new PlayerActionsActions(this); public interface IPlayerMovementActions { void OnMovement(InputAction.CallbackContext context); void OnCamera(InputAction.CallbackContext context); + } + public interface IPlayerActionsActions + { void OnRoll(InputAction.CallbackContext context); } } diff --git a/Assets/Scripts/InputSystem/PlayerControls.inputactions b/Assets/Scripts/InputSystem/PlayerControls.inputactions index f3edee9..0878606 100644 --- a/Assets/Scripts/InputSystem/PlayerControls.inputactions +++ b/Assets/Scripts/InputSystem/PlayerControls.inputactions @@ -22,15 +22,6 @@ "processors": "", "interactions": "", "initialStateCheck": true - }, - { - "name": "Roll", - "type": "Button", - "id": "5e423815-95ec-43c1-9718-224f86c8f24e", - "expectedControlType": "Button", - "processors": "", - "interactions": "", - "initialStateCheck": false } ], "bindings": [ @@ -110,10 +101,38 @@ "action": "Camera", "isComposite": false, "isPartOfComposite": false + } + ] + }, + { + "name": "Player Actions", + "id": "e698248c-d44d-4c32-9308-df1fb8952042", + "actions": [ + { + "name": "Roll", + "type": "Button", + "id": "b5381d00-a598-472a-96b6-e7a5ed618a96", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + } + ], + "bindings": [ + { + "name": "", + "id": "8af511c9-0a47-4f49-b1e0-a98500b70c9d", + "path": "<Gamepad>/buttonEast", + "interactions": "", + "processors": "", + "groups": "", + "action": "Roll", + "isComposite": false, + "isPartOfComposite": false }, { "name": "", - "id": "4690e573-c6d7-4c20-bbee-ba5d11ca8a18", + "id": "a76c6730-3d6e-4609-a3fb-450fe20ef6e2", "path": "<Keyboard>/space", "interactions": "", "processors": "", |
