2026-03-26 20:27:19 +07:00
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
|
|
namespace OnlyScove.Scripts
|
|
|
|
|
{
|
|
|
|
|
public class InputReader : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
// Continuous Inputs
|
|
|
|
|
public virtual Vector2 MoveInput { get; protected set; }
|
|
|
|
|
public virtual Vector2 LookInput { get; protected set; }
|
|
|
|
|
public virtual Vector2 ScrollInput { get; protected set; }
|
|
|
|
|
public virtual bool IsSprintHeld { get; protected set; } // Left Shift
|
|
|
|
|
public virtual bool IsAttackHeld { get; protected set; } // Left Mouse Button
|
|
|
|
|
|
|
|
|
|
// One-shot Events
|
|
|
|
|
public event Action OnJumpEvent; // Space
|
|
|
|
|
public event Action OnDodgeEvent; // Right Mouse Button (RMB)
|
|
|
|
|
public event Action OnAttackEvent; // Left Mouse Button (LMB)
|
|
|
|
|
public event Action OnCrouchEvent; // C Key
|
|
|
|
|
public event Action OnInteractEvent; // E Key
|
|
|
|
|
public event Action OnNextInteractEvent; // R Key
|
|
|
|
|
public event Action OnPreviousInteractEvent; // Q Key
|
2026-03-27 12:08:16 +07:00
|
|
|
public event Action OnToggleViewEvent; // F2 - New event for toggling camera view
|
2026-03-26 20:27:19 +07:00
|
|
|
|
|
|
|
|
public void OnAttack(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed)
|
|
|
|
|
{
|
|
|
|
|
OnAttackEvent?.Invoke();
|
|
|
|
|
IsAttackHeld = true;
|
|
|
|
|
}
|
|
|
|
|
if (context.canceled)
|
|
|
|
|
{
|
|
|
|
|
IsAttackHeld = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnMove(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
MoveInput = context.ReadValue<Vector2>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnLook(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
LookInput = context.ReadValue<Vector2>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnScroll(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
ScrollInput = context.ReadValue<Vector2>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnSprint(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) IsSprintHeld = true;
|
|
|
|
|
if (context.canceled) IsSprintHeld = false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 12:08:16 +07:00
|
|
|
// New method for ToggleView input
|
|
|
|
|
public void OnToggleView(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed)
|
|
|
|
|
{
|
|
|
|
|
OnToggleViewEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 20:27:19 +07:00
|
|
|
public void OnJump(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnJumpEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDodgeOrThrust(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnDodgeEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnCrouch(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnCrouchEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnInteract(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnInteractEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnNext(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnNextInteractEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnPrevious(InputAction.CallbackContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.performed) OnPreviousInteractEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|