From 93933c547cde3ebbfa1295e942b80864e971fc38 Mon Sep 17 00:00:00 2001 From: Lordfirespeed <28568841+Lordfirespeed@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:03:51 +0000 Subject: [PATCH] use a way simpler way to do it all --- Free2Move/Features/MoveInAnyDirection.cs | 23 +++----------- .../Features/MoveInCardinalDirections.cs | 31 +++---------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/Free2Move/Features/MoveInAnyDirection.cs b/Free2Move/Features/MoveInAnyDirection.cs index 0c3de02..72b2d22 100644 --- a/Free2Move/Features/MoveInAnyDirection.cs +++ b/Free2Move/Features/MoveInAnyDirection.cs @@ -13,28 +13,13 @@ ManualLogSource IFeature.Logger { public void OnEnable() { - RemoveCompositeBinding(); - AddDirectBinding(); + SetAnalogBindingMode(); } - private void RemoveCompositeBinding() + private void SetAnalogBindingMode() { - var context = IPlayerInputActionFeature.PlayerMoveAction - .ChangeCompositeBinding("Gamepad"); - - if (!context.valid) return; - - context.Erase(); - } - - private void AddDirectBinding() - { - var existingBindingIndex = IPlayerInputActionFeature.PlayerMoveAction - .GetBindingIndex(path: "/leftStick"); - - if (existingBindingIndex > 0) return; - IPlayerInputActionFeature.PlayerMoveAction - .AddBinding("/leftStick"); + .ChangeCompositeBinding("Gamepad") + .WithPath("2DVector(mode=2)"); } } diff --git a/Free2Move/Features/MoveInCardinalDirections.cs b/Free2Move/Features/MoveInCardinalDirections.cs index 93e0050..fe2a1e4 100644 --- a/Free2Move/Features/MoveInCardinalDirections.cs +++ b/Free2Move/Features/MoveInCardinalDirections.cs @@ -13,36 +13,13 @@ ManualLogSource IFeature.Logger { public void OnEnable() { - RemoveDirectBinding(); - AddCompositeBinding(); + ResetBindingMode(); } - private void RemoveDirectBinding() + private void ResetBindingMode() { - var context = IPlayerInputActionFeature.PlayerMoveAction - .ChangeBindingWithPath("/leftStick"); - - if (!context.valid) return; - - context.Erase(); - } - - private void AddCompositeBinding() - { - var testContext = IPlayerInputActionFeature.PlayerMoveAction - .ChangeCompositeBinding("Gamepad"); - - if (testContext.valid) return; - - var context = IPlayerInputActionFeature.PlayerMoveAction - .AddCompositeBinding("2DVector") - .With("up", "/leftStick/up") - .With("down", "/leftStick/down") - .With("left", "/leftStick/left") - .With("right", "/leftStick/right"); - IPlayerInputActionFeature.PlayerMoveAction - .ChangeCompositeBinding("2DVector") - .WithName("Gamepad"); + .ChangeCompositeBinding("Gamepad") + .WithPath("2DVector"); } }