36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
using Code.Infrastructure.Input;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace Code.OfficeGame.BattleMode.CursorControl
|
|
{
|
|
public class BattleModeCursorController : IDisposable
|
|
{
|
|
private IInputService _inputService;
|
|
|
|
public BattleModeCursorController(IInputService inputService)
|
|
{
|
|
_inputService = inputService;
|
|
|
|
_inputService.BindActionPerformed((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, EnableCursor);
|
|
_inputService.BindActionCancelled((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, DisableCursor);
|
|
}
|
|
|
|
private void EnableCursor(InputAction.CallbackContext obj)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Confined;
|
|
}
|
|
|
|
private void DisableCursor(InputAction.CallbackContext obj)
|
|
{
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_inputService.UnbindActionPerformed((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, EnableCursor);
|
|
_inputService.UnbindActionCancelled((int) ActionMappings.BattleMode, (int) BattleModeActions.RightClick, DisableCursor);
|
|
}
|
|
}
|
|
} |