aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/InputSystem/PlayerControls.cs
diff options
context:
space:
mode:
authorSmallFox <2806143047@qq.com>2026-05-31 17:42:01 +0800
committerSmallFox <2806143047@qq.com>2026-05-31 17:42:01 +0800
commitff1e4698f877ead17ee723ff465f26fad58cd0a0 (patch)
tree14a97ffbf7e360c8676ba81037d582b9c0aaaec6 /Assets/Scripts/InputSystem/PlayerControls.cs
parentdca6ed8a79a1b4df00720a02f5ae96b2ec9e7283 (diff)
合并最新分支,重构Roll,增加了Step_Back,有点手感问题后面调
Diffstat (limited to 'Assets/Scripts/InputSystem/PlayerControls.cs')
-rw-r--r--Assets/Scripts/InputSystem/PlayerControls.cs100
1 files changed, 81 insertions, 19 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);
}
}