Files
Colosseum/Assets/_Game/Scripts/AI/BehaviorActions/Actions/ChaseTargetAction.cs
dal4segno 904bc88d36 feat: 드로그 보스 AI 및 런타임 상태 구조 재구성
- 드로그 전투 컨텍스트를 BossBehaviorRuntimeState 중심 구조로 정리하고 BossEnemy, 패턴 액션, 조건 노드가 마지막 실행 결과와 phase 상태를 직접 사용하도록 갱신
- BT_Drog와 재빌드 에디터 스크립트를 확장해 phase 전환, 집행 결과 분기, 거리/쿨타임 기반 패턴 선택을 드로그 전용 자산과 노드 파라미터로 재구성
- 드로그 패턴/스킬/이펙트/애니메이션 플레이스홀더 자산을 재생성하고 보스 프리팹이 새 런타임 상태 및 등록 클립 구성을 참조하도록 정리
2026-04-06 13:56:47 +09:00

92 lines
2.5 KiB
C#

using System;
using Colosseum.Enemy;
using Unity.Behavior;
using UnityEngine;
using Action = Unity.Behavior.Action;
using Unity.Properties;
[Serializable, GeneratePropertyBag]
[NodeDescription(name: "ChaseTarget", story: "타겟 추적", category: "Action", id: "0889fbb015b8bf414ef569af08bb6868")]
public partial class ChaseTargetAction : Action
{
[SerializeReference]
public BlackboardVariable<GameObject> Target;
[SerializeReference]
public BlackboardVariable<float> Speed = new BlackboardVariable<float>(0f);
[SerializeReference]
public BlackboardVariable<float> StopDistance = new BlackboardVariable<float>(2f);
private UnityEngine.AI.NavMeshAgent agent;
protected override Status OnStart()
{
BossBehaviorRuntimeState context = GameObject.GetComponent<BossBehaviorRuntimeState>();
if (context != null && context.IsBehaviorSuppressed)
{
return Status.Failure;
}
if (Target.Value == null)
{
return Status.Failure;
}
agent = GameObject.GetComponent<UnityEngine.AI.NavMeshAgent>();
if (agent == null)
{
Debug.LogWarning("[ChaseTarget] NavMeshAgent not found");
return Status.Failure;
}
// Speed가 0 이하면 NavMeshAgent의 기존 speed 유지 (EnemyData에서 설정한 값)
if (Speed.Value > 0f)
{
agent.speed = Speed.Value;
}
agent.stoppingDistance = StopDistance.Value;
agent.isStopped = false;
return Status.Running;
}
protected override Status OnUpdate()
{
BossBehaviorRuntimeState context = GameObject.GetComponent<BossBehaviorRuntimeState>();
if (context != null && context.IsBehaviorSuppressed)
{
if (agent != null)
agent.isStopped = true;
return Status.Failure;
}
if (Target.Value == null)
{
return Status.Failure;
}
// 이미 사거리 내에 있으면 성공
float distance = Vector3.Distance(GameObject.transform.position, Target.Value.transform.position);
if (distance <= StopDistance.Value)
{
agent.isStopped = true;
return Status.Success;
}
agent.SetDestination(Target.Value.transform.position);
return Status.Running;
}
protected override void OnEnd()
{
if (agent != null)
{
agent.isStopped = true;
}
}
}