네트워크 멀티플레이 대응

This commit is contained in:
2026-01-31 20:49:23 +09:00
parent 1152093521
commit c5bcf265d0
69 changed files with 2766 additions and 1392 deletions

View File

@@ -5,10 +5,7 @@ using System.Collections.Generic;
namespace Northbound
{
/// <summary>
/// 상호작용 대상 없이 실행 가능한 액션들을 관리
/// </summary>
public class PlayerActionSystem : NetworkBehaviour
public class PlayerActionSystem : InputActionManager
{
[Header("Actions")]
public List<MonoBehaviour> actionComponents = new List<MonoBehaviour>();
@@ -16,7 +13,6 @@ namespace Northbound
[Header("Animation")]
public bool playAnimations = true;
private PlayerInputActions _inputActions;
private Dictionary<string, IAction> _actions = new Dictionary<string, IAction>();
private Animator _animator;
@@ -27,9 +23,10 @@ namespace Northbound
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
if (!IsOwner) return;
// 액션 컴포넌트들을 딕셔너리에 등록
foreach (var component in actionComponents)
{
if (component is IAction action)
@@ -37,21 +34,16 @@ namespace Northbound
_actions[action.GetActionName()] = action;
}
}
_inputActions = new PlayerInputActions();
_inputActions.Player.Attack.performed += OnAttack;
// 다른 액션들도 여기에 바인딩
_inputActions.Enable();
}
public override void OnNetworkDespawn()
protected override void BindInputActions()
{
if (IsOwner && _inputActions != null)
{
_inputActions.Player.Attack.performed -= OnAttack;
_inputActions.Disable();
_inputActions.Dispose();
}
_inputActions.Player.Attack.performed += OnAttack;
}
protected override void UnbindInputActions()
{
_inputActions.Player.Attack.performed -= OnAttack;
}
private void OnAttack(InputAction.CallbackContext context)
@@ -65,7 +57,6 @@ namespace Northbound
{
if (action.CanExecute(OwnerClientId))
{
// 애니메이션 재생 (액션 실행 전)
if (playAnimations && _animator != null)
{
string animTrigger = action.GetActionAnimation();
@@ -79,15 +70,5 @@ namespace Northbound
}
}
}
override public void OnDestroy()
{
if (_inputActions != null)
{
_inputActions.Dispose();
}
base.OnDestroy();
}
}
}
}