- 드로그 전투 컨텍스트를 BossBehaviorRuntimeState 중심 구조로 정리하고 BossEnemy, 패턴 액션, 조건 노드가 마지막 실행 결과와 phase 상태를 직접 사용하도록 갱신 - BT_Drog와 재빌드 에디터 스크립트를 확장해 phase 전환, 집행 결과 분기, 거리/쿨타임 기반 패턴 선택을 드로그 전용 자산과 노드 파라미터로 재구성 - 드로그 패턴/스킬/이펙트/애니메이션 플레이스홀더 자산을 재생성하고 보스 프리팹이 새 런타임 상태 및 등록 클립 구성을 참조하도록 정리
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
using System;
|
|
|
|
using Colosseum;
|
|
using Colosseum.Combat;
|
|
using Colosseum.Enemy;
|
|
using Colosseum.Player;
|
|
|
|
using Unity.Behavior;
|
|
using Unity.Properties;
|
|
using UnityEngine;
|
|
|
|
using Action = Unity.Behavior.Action;
|
|
|
|
/// <summary>
|
|
/// 일정 반경 내에서 가장 가까운 다운 대상 플레이어를 선택하는 Behavior Action입니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
[NodeDescription(
|
|
name: "Select Nearest Downed Target",
|
|
story: "[SearchRadius] 반경 내 가장 가까운 다운 대상을 [Target]으로 선택",
|
|
category: "Action",
|
|
id: "ee1146ad46ec4730acb4d6c883a5a771")]
|
|
public partial class SelectNearestDownedTargetAction : Action
|
|
{
|
|
[SerializeReference]
|
|
public BlackboardVariable<GameObject> Target;
|
|
|
|
[SerializeReference]
|
|
public BlackboardVariable<float> SearchRadius = new BlackboardVariable<float>(0f);
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
float searchRadius = ResolveSearchRadius();
|
|
HitReactionController[] hitReactionControllers = UnityEngine.Object.FindObjectsByType<HitReactionController>(FindObjectsSortMode.None);
|
|
|
|
GameObject nearestTarget = null;
|
|
float nearestDistance = float.MaxValue;
|
|
|
|
for (int i = 0; i < hitReactionControllers.Length; i++)
|
|
{
|
|
HitReactionController controller = hitReactionControllers[i];
|
|
if (controller == null || !controller.IsDowned)
|
|
continue;
|
|
|
|
GameObject candidate = controller.gameObject;
|
|
if (candidate == null || !candidate.activeInHierarchy)
|
|
continue;
|
|
|
|
if (Team.IsSameTeam(GameObject, candidate))
|
|
continue;
|
|
|
|
IDamageable damageable = candidate.GetComponent<IDamageable>();
|
|
if (damageable != null && damageable.IsDead)
|
|
continue;
|
|
|
|
float distance = Vector3.Distance(GameObject.transform.position, candidate.transform.position);
|
|
if (distance > searchRadius || distance >= nearestDistance)
|
|
continue;
|
|
|
|
nearestDistance = distance;
|
|
nearestTarget = candidate;
|
|
}
|
|
|
|
if (nearestTarget == null)
|
|
return Status.Failure;
|
|
|
|
Target.Value = nearestTarget;
|
|
GameObject.GetComponent<BossBehaviorRuntimeState>()?.SetCurrentTarget(nearestTarget);
|
|
LogDebug($"다운 대상 선택: {nearestTarget.name}");
|
|
return Status.Success;
|
|
}
|
|
|
|
private float ResolveSearchRadius()
|
|
{
|
|
return Mathf.Max(0f, SearchRadius.Value);
|
|
}
|
|
|
|
private void LogDebug(string message)
|
|
{
|
|
BossBehaviorRuntimeState context = GameObject.GetComponent<BossBehaviorRuntimeState>();
|
|
context?.LogDebug(nameof(SelectNearestDownedTargetAction), message);
|
|
}
|
|
}
|