2022-08-08 15:55:27 +03:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
using static UnityEngine.InputSystem.InputAction;
|
|
|
|
|
|
2022-08-09 16:02:14 +03:00
|
|
|
public class InputManager : MonoBehaviour
|
2022-08-08 15:55:27 +03:00
|
|
|
{
|
2022-09-22 19:17:03 +03:00
|
|
|
[HideInInspector] public UnityEvent OnInputChange;
|
|
|
|
|
[SerializeField] private PlayerInput _playerInput;
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2023-03-06 23:26:04 +02:00
|
|
|
public PromptsInput CurrentPrompts;
|
2023-08-29 17:42:32 +03:00
|
|
|
public PromptsInput PreviousPrompts;
|
2022-09-22 19:17:03 +03:00
|
|
|
public Vector2 NavigationInput { get; private set; }
|
|
|
|
|
public string InputScheme { get { return _playerInput.devices[0].displayName; } set { } }
|
|
|
|
|
public PlayerInput PlayerInput { get { return _playerInput; } private set { } }
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2023-08-28 02:38:39 +03:00
|
|
|
public void InputChange(PlayerInput playerInput) => OnInputChange?.Invoke();
|
|
|
|
|
public void Navigation(CallbackContext callbackContext) => NavigationInput = callbackContext.ReadValue<Vector2>();
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2023-08-29 17:42:32 +03:00
|
|
|
public void SetPrompts(PromptsInput prompts)
|
|
|
|
|
{
|
|
|
|
|
PreviousPrompts = CurrentPrompts;
|
|
|
|
|
CurrentPrompts = prompts;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Confirm(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnConfirm?.Invoke();
|
|
|
|
|
}
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Back(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnBack?.Invoke();
|
|
|
|
|
}
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Stage(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnStage?.Invoke();
|
|
|
|
|
}
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Coop(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnCoop?.Invoke();
|
|
|
|
|
}
|
2022-08-08 15:55:27 +03:00
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Rebind(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnRebind?.Invoke();
|
|
|
|
|
}
|
2022-08-12 23:12:55 +03:00
|
|
|
|
2022-09-22 19:17:03 +03:00
|
|
|
public void Controls(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnControls?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToggleFramedata(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnToggleFramedata?.Invoke();
|
|
|
|
|
}
|
2023-03-18 11:54:03 +02:00
|
|
|
|
|
|
|
|
public void PageLeft(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnLeftPage?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PageRight(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnRightPage?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 16:12:16 +02:00
|
|
|
public void NavigationRight(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnRightNavigation?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void NavigationLeft(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnLeftNavigation?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 17:42:32 +03:00
|
|
|
public void Options(CallbackContext callbackContext)
|
|
|
|
|
{
|
|
|
|
|
if (callbackContext.performed)
|
|
|
|
|
CurrentPrompts?.OnOptions?.Invoke();
|
|
|
|
|
}
|
2022-08-08 15:55:27 +03:00
|
|
|
}
|