feat: 플레이어 행동 상태 통합 및 이상상태 디버그 추가
- PlayerActionState로 이동, 점프, 스킬 입력 가능 여부를 통합 - 기절과 침묵 이상상태 데이터 및 효과 에셋을 추가 - 로컬 플레이어용 이상상태 디버그 HUD와 자동 검증 러너를 추가 - 플레이어 이동, 스킬 입력, 네트워크 상태를 새 행동 상태 기준으로 정리
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Colosseum.Player
|
||||
/// 플레이어 스킬 입력 처리.
|
||||
/// 논타겟 방식: 입력 시 즉시 스킬 시전
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerActionState))]
|
||||
public class PlayerSkillInput : NetworkBehaviour
|
||||
{
|
||||
[Header("Skill Slots")]
|
||||
@@ -24,6 +25,8 @@ namespace Colosseum.Player
|
||||
[SerializeField] private PlayerNetworkController networkController;
|
||||
[Tooltip("WeaponEquipment (없으면 자동 검색)")]
|
||||
[SerializeField] private WeaponEquipment weaponEquipment;
|
||||
[Tooltip("행동 상태 관리자 (없으면 자동 검색)")]
|
||||
[SerializeField] private PlayerActionState actionState;
|
||||
|
||||
private InputSystem_Actions inputActions;
|
||||
|
||||
@@ -61,36 +64,54 @@ namespace Colosseum.Player
|
||||
weaponEquipment = GetComponent<WeaponEquipment>();
|
||||
}
|
||||
|
||||
if (actionState == null)
|
||||
{
|
||||
actionState = GetOrCreateActionState();
|
||||
}
|
||||
|
||||
InitializeInputActions();
|
||||
}
|
||||
|
||||
private void InitializeInputActions()
|
||||
{
|
||||
inputActions = new InputSystem_Actions();
|
||||
inputActions.Player.Enable();
|
||||
if (inputActions == null)
|
||||
{
|
||||
inputActions = new InputSystem_Actions();
|
||||
inputActions.Player.Skill1.performed += OnSkill1Performed;
|
||||
inputActions.Player.Skill2.performed += OnSkill2Performed;
|
||||
inputActions.Player.Skill3.performed += OnSkill3Performed;
|
||||
inputActions.Player.Skill4.performed += OnSkill4Performed;
|
||||
inputActions.Player.Skill5.performed += OnSkill5Performed;
|
||||
inputActions.Player.Skill6.performed += OnSkill6Performed;
|
||||
inputActions.Player.Evade.performed += OnEvadePerformed;
|
||||
}
|
||||
|
||||
// 스킬 액션 콜백 등록
|
||||
inputActions.Player.Skill1.performed += _ => OnSkillInput(0);
|
||||
inputActions.Player.Skill2.performed += _ => OnSkillInput(1);
|
||||
inputActions.Player.Skill3.performed += _ => OnSkillInput(2);
|
||||
inputActions.Player.Skill4.performed += _ => OnSkillInput(3);
|
||||
inputActions.Player.Skill5.performed += _ => OnSkillInput(4);
|
||||
inputActions.Player.Skill6.performed += _ => OnSkillInput(5);
|
||||
inputActions.Player.Evade.performed += _ => OnSkillInput(6);
|
||||
inputActions.Player.Enable();
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
CleanupInputActions();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
CleanupInputActions();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (IsOwner && inputActions != null)
|
||||
{
|
||||
inputActions.Player.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanupInputActions()
|
||||
{
|
||||
if (inputActions != null)
|
||||
{
|
||||
inputActions.Player.Skill1.performed -= _ => OnSkillInput(0);
|
||||
inputActions.Player.Skill2.performed -= _ => OnSkillInput(1);
|
||||
inputActions.Player.Skill3.performed -= _ => OnSkillInput(2);
|
||||
inputActions.Player.Skill4.performed -= _ => OnSkillInput(3);
|
||||
inputActions.Player.Skill5.performed -= _ => OnSkillInput(4);
|
||||
inputActions.Player.Skill6.performed -= _ => OnSkillInput(5);
|
||||
inputActions.Player.Evade.performed -= _ => OnSkillInput(6);
|
||||
inputActions.Disable();
|
||||
inputActions.Player.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +131,7 @@ namespace Colosseum.Player
|
||||
}
|
||||
|
||||
// 사망 상태 체크
|
||||
if (networkController != null && networkController.IsDead)
|
||||
if (actionState != null && !actionState.CanUseSkills)
|
||||
return;
|
||||
|
||||
// 로컬 체크 (빠른 피드백용)
|
||||
@@ -152,7 +173,7 @@ namespace Colosseum.Player
|
||||
|
||||
// 서버에서 다시 검증
|
||||
// 사망 상태 체크
|
||||
if (networkController != null && networkController.IsDead)
|
||||
if (actionState != null && !actionState.CanUseSkills)
|
||||
return;
|
||||
|
||||
if (skillController.IsExecutingSkill || skillController.IsOnCooldown(skill))
|
||||
@@ -242,7 +263,33 @@ namespace Colosseum.Player
|
||||
SkillData skill = GetSkill(slotIndex);
|
||||
if (skill == null) return false;
|
||||
|
||||
if (actionState != null && !actionState.CanUseSkills)
|
||||
return false;
|
||||
|
||||
return !skillController.IsOnCooldown(skill) && !skillController.IsExecutingSkill;
|
||||
}
|
||||
|
||||
private void OnSkill1Performed(InputAction.CallbackContext context) => OnSkillInput(0);
|
||||
|
||||
private void OnSkill2Performed(InputAction.CallbackContext context) => OnSkillInput(1);
|
||||
|
||||
private void OnSkill3Performed(InputAction.CallbackContext context) => OnSkillInput(2);
|
||||
|
||||
private void OnSkill4Performed(InputAction.CallbackContext context) => OnSkillInput(3);
|
||||
|
||||
private void OnSkill5Performed(InputAction.CallbackContext context) => OnSkillInput(4);
|
||||
|
||||
private void OnSkill6Performed(InputAction.CallbackContext context) => OnSkillInput(5);
|
||||
|
||||
private void OnEvadePerformed(InputAction.CallbackContext context) => OnSkillInput(6);
|
||||
|
||||
private PlayerActionState GetOrCreateActionState()
|
||||
{
|
||||
var foundState = GetComponent<PlayerActionState>();
|
||||
if (foundState != null)
|
||||
return foundState;
|
||||
|
||||
return gameObject.AddComponent<PlayerActionState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user