입력 시스템 개선
각자의 입력 처리 로직을 갖지 않고 NetworkPlayerController로부터 받아서 쓰도록 함
This commit is contained in:
@@ -33,7 +33,6 @@ namespace Northbound
|
||||
[Header("Worker")]
|
||||
public Worker assignedWorker;
|
||||
|
||||
private PlayerInputActions _inputActions;
|
||||
private IInteractable _currentInteractable;
|
||||
private IInteractable _unavailableInteractable;
|
||||
private Camera _mainCamera;
|
||||
@@ -48,6 +47,7 @@ namespace Northbound
|
||||
|
||||
private NetworkPlayerController _networkPlayerController;
|
||||
private PlayerStats _playerStats;
|
||||
private bool _isInputInitialized = false;
|
||||
|
||||
public bool IsInteracting => _isInteracting;
|
||||
public float WorkPower => _playerStats?.GetManpower() ?? 10f;
|
||||
@@ -69,7 +69,7 @@ namespace Northbound
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
_equipmentSocket = GetComponent<EquipmentSocket>();
|
||||
|
||||
|
||||
if (rayOrigin == null)
|
||||
rayOrigin = transform;
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace Northbound
|
||||
if (_networkPlayerController != null)
|
||||
{
|
||||
_networkPlayerController.OnOwnerChanged += OnOwnerPlayerIdChanged;
|
||||
_networkPlayerController.OnInputInitialized += TryInitializeInput;
|
||||
}
|
||||
|
||||
// 이미 로컬 플레이어면 입력 초기화
|
||||
@@ -91,12 +92,12 @@ namespace Northbound
|
||||
private void TryInitializeInput()
|
||||
{
|
||||
if (!IsLocalPlayer) return;
|
||||
if (_inputActions != null) return;
|
||||
if (_isInputInitialized) return; // 이미 초기화됨
|
||||
if (_networkPlayerController.InputActions == null) return; // 아직 InputActions가 없음
|
||||
|
||||
_isInputInitialized = true;
|
||||
_mainCamera = Camera.main;
|
||||
_inputActions = new PlayerInputActions();
|
||||
_inputActions.Player.Interact.performed += OnInteract;
|
||||
_inputActions.Enable();
|
||||
_networkPlayerController.InputActions.Player.Interact.performed += OnInteract;
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
@@ -104,13 +105,13 @@ namespace Northbound
|
||||
if (_networkPlayerController != null)
|
||||
{
|
||||
_networkPlayerController.OnOwnerChanged -= OnOwnerPlayerIdChanged;
|
||||
}
|
||||
_networkPlayerController.OnInputInitialized -= TryInitializeInput;
|
||||
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Player.Interact.performed -= OnInteract;
|
||||
_inputActions.Disable();
|
||||
_inputActions.Dispose();
|
||||
// 입력 이벤트 해제
|
||||
if (_networkPlayerController.InputActions != null)
|
||||
{
|
||||
_networkPlayerController.InputActions.Player.Interact.performed -= OnInteract;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,10 +403,7 @@ namespace Northbound
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Dispose();
|
||||
}
|
||||
// 입력 정리는 NetworkPlayerController에서 담당
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user