입력 시스템 개선
각자의 입력 처리 로직을 갖지 않고 NetworkPlayerController로부터 받아서 쓰도록 함
This commit is contained in:
@@ -17,11 +17,11 @@ namespace Northbound
|
||||
[Header("Animation")]
|
||||
public bool playAnimations = true;
|
||||
|
||||
private PlayerInputActions _inputActions;
|
||||
private Dictionary<string, IAction> _actions = new Dictionary<string, IAction>();
|
||||
private Animator _animator;
|
||||
private NetworkAnimator _networkAnimator;
|
||||
private NetworkPlayerController _networkPlayerController;
|
||||
private bool _isInputInitialized = false;
|
||||
|
||||
// 로컬 플레이어인지 확인
|
||||
private bool IsLocalPlayer => _networkPlayerController != null && _networkPlayerController.IsLocalPlayer;
|
||||
@@ -49,6 +49,7 @@ namespace Northbound
|
||||
if (_networkPlayerController != null)
|
||||
{
|
||||
_networkPlayerController.OnOwnerChanged += OnOwnerPlayerIdChanged;
|
||||
_networkPlayerController.OnInputInitialized += TryInitializeInput;
|
||||
}
|
||||
|
||||
// 이미 로컬 플레이어면 입력 초기화
|
||||
@@ -63,11 +64,11 @@ namespace Northbound
|
||||
private void TryInitializeInput()
|
||||
{
|
||||
if (!IsLocalPlayer) return;
|
||||
if (_inputActions != null) return;
|
||||
if (_isInputInitialized) return; // 이미 초기화됨
|
||||
if (_networkPlayerController.InputActions == null) return; // 아직 InputActions가 없음
|
||||
|
||||
_inputActions = new PlayerInputActions();
|
||||
_inputActions.Player.Attack.performed += OnAttack;
|
||||
_inputActions.Enable();
|
||||
_isInputInitialized = true;
|
||||
_networkPlayerController.InputActions.Player.Attack.performed += OnAttack;
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
@@ -75,13 +76,13 @@ namespace Northbound
|
||||
if (_networkPlayerController != null)
|
||||
{
|
||||
_networkPlayerController.OnOwnerChanged -= OnOwnerPlayerIdChanged;
|
||||
}
|
||||
_networkPlayerController.OnInputInitialized -= TryInitializeInput;
|
||||
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Player.Attack.performed -= OnAttack;
|
||||
_inputActions.Disable();
|
||||
_inputActions.Dispose();
|
||||
// 입력 이벤트 해제
|
||||
if (_networkPlayerController.InputActions != null)
|
||||
{
|
||||
_networkPlayerController.InputActions.Player.Attack.performed -= OnAttack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,11 +127,7 @@ namespace Northbound
|
||||
|
||||
override public void OnDestroy()
|
||||
{
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Dispose();
|
||||
}
|
||||
|
||||
// 입력 정리는 NetworkPlayerController에서 담당
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user