- 다중 젬 슬롯용 타입을 별도 스크립트로 분리하고 테스트 젬/로드아웃 자산 생성 경로를 정리 - 젬 테스트 전용 공격 스킬과 분리된 애니메이션 자산을 추가해 베이스 스킬 검증 경로를 마련 - PlayerSkillDebugMenu와 MPP 디버그 메뉴를 보강해 젬 프리셋 적용, 원격 테스트, 보스 기절 디버그 메뉴를 추가 - BossCombatBehaviorContext와 공통 BT 액션이 기절 상태를 존중하도록 수정해 보스 추적과 패턴 실행을 중단 - Unity 리프레시와 외부 빌드 통과를 확인하고 드로그전 및 MPP 기준 젬 프리셋 적용 흐름을 검증
262 lines
7.6 KiB
C#
262 lines
7.6 KiB
C#
using System;
|
|
|
|
using Colosseum;
|
|
using Colosseum.AI;
|
|
using Colosseum.Combat;
|
|
using Colosseum.Enemy;
|
|
using Colosseum.Player;
|
|
using Colosseum.Skills;
|
|
|
|
using Unity.Behavior;
|
|
using Unity.Properties;
|
|
using UnityEngine;
|
|
|
|
using Action = Unity.Behavior.Action;
|
|
|
|
/// <summary>
|
|
/// 보스 공통 패턴 실행용 Behavior Action 기반 클래스입니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
public abstract partial class BossPatternActionBase : Action
|
|
{
|
|
[SerializeReference]
|
|
public BlackboardVariable<GameObject> Target;
|
|
|
|
protected BossEnemy bossEnemy;
|
|
protected EnemyBase enemyBase;
|
|
protected SkillController skillController;
|
|
protected BossCombatBehaviorContext combatBehaviorContext;
|
|
protected UnityEngine.AI.NavMeshAgent navMeshAgent;
|
|
|
|
private BossPatternData activePattern;
|
|
private GameObject activeTarget;
|
|
private int currentStepIndex;
|
|
private bool isWaiting;
|
|
private float waitEndTime;
|
|
|
|
/// <summary>
|
|
/// 액션 시작 시 실제로 실행할 패턴과 대상을 결정합니다.
|
|
/// </summary>
|
|
protected abstract bool TryResolvePattern(out BossPatternData pattern, out GameObject target);
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
ResolveReferences();
|
|
ClearRuntimeState();
|
|
|
|
if (!IsReady())
|
|
return Status.Failure;
|
|
|
|
if (combatBehaviorContext.IsBehaviorSuppressed)
|
|
{
|
|
StopMovement();
|
|
return Status.Failure;
|
|
}
|
|
|
|
if (bossEnemy.IsDead || bossEnemy.IsTransitioning)
|
|
return Status.Failure;
|
|
|
|
if (skillController.IsPlayingAnimation)
|
|
return Status.Failure;
|
|
|
|
if (!TryResolvePattern(out BossPatternData pattern, out GameObject target))
|
|
return Status.Failure;
|
|
|
|
activePattern = pattern;
|
|
activeTarget = target;
|
|
|
|
if (Target != null)
|
|
Target.Value = target;
|
|
|
|
StopMovement();
|
|
return ExecuteCurrentStep();
|
|
}
|
|
|
|
protected override Status OnUpdate()
|
|
{
|
|
if (!IsReady() || activePattern == null)
|
|
return Status.Failure;
|
|
|
|
if (combatBehaviorContext.IsBehaviorSuppressed)
|
|
{
|
|
StopMovement();
|
|
return Status.Failure;
|
|
}
|
|
|
|
if (bossEnemy.IsDead || bossEnemy.IsTransitioning)
|
|
return Status.Failure;
|
|
|
|
if (isWaiting)
|
|
{
|
|
if (Time.time < waitEndTime)
|
|
return Status.Running;
|
|
|
|
isWaiting = false;
|
|
}
|
|
else if (skillController.IsPlayingAnimation)
|
|
{
|
|
return Status.Running;
|
|
}
|
|
|
|
currentStepIndex++;
|
|
if (currentStepIndex >= activePattern.Steps.Count)
|
|
{
|
|
UsePatternAction.MarkPatternUsed(GameObject, activePattern);
|
|
return Status.Success;
|
|
}
|
|
|
|
return ExecuteCurrentStep();
|
|
}
|
|
|
|
protected override void OnEnd()
|
|
{
|
|
ClearRuntimeState();
|
|
}
|
|
|
|
protected virtual GameObject ResolveStepTarget(GameObject fallbackTarget)
|
|
{
|
|
return fallbackTarget;
|
|
}
|
|
|
|
protected GameObject FindNearestLivingPlayer()
|
|
{
|
|
PlayerNetworkController[] players = UnityEngine.Object.FindObjectsByType<PlayerNetworkController>(FindObjectsSortMode.None);
|
|
GameObject nearestTarget = null;
|
|
float nearestDistance = float.MaxValue;
|
|
float maxDistance = enemyBase != null && enemyBase.Data != null ? enemyBase.Data.AggroRange : Mathf.Infinity;
|
|
|
|
for (int i = 0; i < players.Length; i++)
|
|
{
|
|
PlayerNetworkController player = players[i];
|
|
if (player == null || player.IsDead || !player.gameObject.activeInHierarchy)
|
|
continue;
|
|
|
|
GameObject candidate = player.gameObject;
|
|
if (Team.IsSameTeam(GameObject, candidate))
|
|
continue;
|
|
|
|
float distance = Vector3.Distance(GameObject.transform.position, candidate.transform.position);
|
|
if (distance > maxDistance || distance >= nearestDistance)
|
|
continue;
|
|
|
|
nearestDistance = distance;
|
|
nearestTarget = candidate;
|
|
}
|
|
|
|
return nearestTarget;
|
|
}
|
|
|
|
protected GameObject ResolvePrimaryTarget()
|
|
{
|
|
GameObject highestThreatTarget = enemyBase != null
|
|
? enemyBase.GetHighestThreatTarget(Target?.Value, null, enemyBase.Data != null ? enemyBase.Data.AggroRange : Mathf.Infinity)
|
|
: null;
|
|
|
|
GameObject target = highestThreatTarget != null ? highestThreatTarget : FindNearestLivingPlayer();
|
|
if (Target != null)
|
|
Target.Value = target;
|
|
|
|
return target;
|
|
}
|
|
|
|
protected bool IsValidHostileTarget(GameObject candidate)
|
|
{
|
|
if (candidate == null || !candidate.activeInHierarchy)
|
|
return false;
|
|
|
|
if (Team.IsSameTeam(GameObject, candidate))
|
|
return false;
|
|
|
|
IDamageable damageable = candidate.GetComponent<IDamageable>();
|
|
return damageable == null || !damageable.IsDead;
|
|
}
|
|
|
|
protected void StopMovement()
|
|
{
|
|
if (navMeshAgent == null || !navMeshAgent.enabled)
|
|
return;
|
|
|
|
navMeshAgent.isStopped = true;
|
|
navMeshAgent.ResetPath();
|
|
}
|
|
|
|
protected void LogDebug(string message)
|
|
{
|
|
combatBehaviorContext?.LogDebug(GetType().Name, message);
|
|
}
|
|
|
|
private Status ExecuteCurrentStep()
|
|
{
|
|
if (activePattern == null || currentStepIndex < 0 || currentStepIndex >= activePattern.Steps.Count)
|
|
return Status.Failure;
|
|
|
|
PatternStep step = activePattern.Steps[currentStepIndex];
|
|
if (step.Type == PatternStepType.Wait)
|
|
{
|
|
isWaiting = true;
|
|
waitEndTime = Time.time + step.Duration;
|
|
return Status.Running;
|
|
}
|
|
|
|
if (step.Skill == null)
|
|
{
|
|
Debug.LogWarning($"[{GetType().Name}] 스킬이 비어 있는 패턴 스텝입니다: {activePattern.PatternName} / Step={currentStepIndex}");
|
|
return Status.Failure;
|
|
}
|
|
|
|
GameObject skillTarget = activeTarget;
|
|
if (step.Skill.JumpToTarget)
|
|
{
|
|
skillTarget = ResolveStepTarget(activeTarget);
|
|
if (skillTarget == null)
|
|
{
|
|
LogDebug($"점프 타겟을 찾지 못해 실패: {activePattern.PatternName}");
|
|
return Status.Failure;
|
|
}
|
|
|
|
enemyBase?.SetJumpTarget(skillTarget.transform.position);
|
|
}
|
|
|
|
if (!skillController.ExecuteSkill(step.Skill))
|
|
{
|
|
Debug.LogWarning($"[{GetType().Name}] 스킬 실행 실패: {step.Skill.SkillName}");
|
|
return Status.Failure;
|
|
}
|
|
|
|
LogDebug($"패턴 실행: {activePattern.PatternName} / Step={currentStepIndex} / Skill={step.Skill.SkillName}");
|
|
return Status.Running;
|
|
}
|
|
|
|
private bool IsReady()
|
|
{
|
|
return bossEnemy != null && enemyBase != null && skillController != null && combatBehaviorContext != null;
|
|
}
|
|
|
|
private void ResolveReferences()
|
|
{
|
|
if (bossEnemy == null)
|
|
bossEnemy = GameObject.GetComponent<BossEnemy>();
|
|
|
|
if (enemyBase == null)
|
|
enemyBase = GameObject.GetComponent<EnemyBase>();
|
|
|
|
if (skillController == null)
|
|
skillController = GameObject.GetComponent<SkillController>();
|
|
|
|
if (combatBehaviorContext == null)
|
|
combatBehaviorContext = GameObject.GetComponent<BossCombatBehaviorContext>();
|
|
|
|
if (navMeshAgent == null)
|
|
navMeshAgent = GameObject.GetComponent<UnityEngine.AI.NavMeshAgent>();
|
|
}
|
|
|
|
private void ClearRuntimeState()
|
|
{
|
|
activePattern = null;
|
|
activeTarget = null;
|
|
currentStepIndex = 0;
|
|
isWaiting = false;
|
|
waitEndTime = 0f;
|
|
}
|
|
}
|