refactor: 드로그 BT 의사결정 투명화 — 모든 조건을 BT 노드로 표시
- BossCombatPatternRole enum 완전 제거, BossPatternData에 직접 필드 추가 - 14개 패턴별 Check*/Use*Action → CheckPatternReadyCondition + UsePatternByRoleAction으로 통합 - BT 계단식 Branch 체인 구조 도입 (BranchingConditionComposite + FloatingPort) - 패턴별 고유 전제 조건을 BT Condition으로 분리 - Punish: IsDownedTargetInRangeCondition (다운 대상 반경) - Mobility: IsTargetBeyondDistanceCondition (원거리 대상) - Utility: IsTargetBeyondDistanceCondition (원거리 대상) - Primary: IsTargetInAttackRangeCondition (사거리 이내) - Phase 진입 조건을 BT에서 확인 가능하도록 IsMinPhaseSatisfiedCondition 추가 - IsPatternReady()에서 minPhase 체크 분리 → 전용 Condition으로 노출 - Secondary 패턴 개념 제거 (secondaryPattern, 보조 차례, 교대 카운터 로직 전부 삭제) - CanResolvePatternTargetCondition 삭제 (7개 중 5개가 노이즈) - RebuildDrogBehaviorAuthoringGraph로 BT 에셋 자동 재구성 메뉴 제공
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
using Colosseum.AI;
|
||||
|
||||
using Unity.Behavior;
|
||||
using Unity.Properties;
|
||||
using UnityEngine;
|
||||
|
||||
using Condition = Unity.Behavior.Condition;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 지정된 패턴이 준비되었는지 확인하는 범용 조건 노드입니다.
|
||||
/// Pattern 필드에 BossPatternData 에셋을 직접 할당합니다.
|
||||
/// </summary>
|
||||
[Serializable, GeneratePropertyBag]
|
||||
[Condition(name: "Check Pattern Ready", story: "[Pattern] 패턴이 준비되었는가?", id: "a1b2c3d4-1111-2222-3333-444455556666")]
|
||||
[NodeDescription(
|
||||
name: "Check Pattern Ready",
|
||||
story: "Check [Pattern] pattern ready",
|
||||
category: "Condition/Pattern")]
|
||||
public partial class CheckPatternReadyCondition : Condition
|
||||
{
|
||||
[SerializeReference]
|
||||
[Tooltip("준비 여부를 확인할 패턴")]
|
||||
public BlackboardVariable<BossPatternData> Pattern;
|
||||
|
||||
public override bool IsTrue()
|
||||
{
|
||||
BossPatternData pattern = Pattern?.Value;
|
||||
if (pattern == null)
|
||||
return false;
|
||||
|
||||
return PatternReadyHelper.IsPatternReady(GameObject, pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1a4d12e73d0f4a40a3a1d5a9c1fce6e
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
|
||||
using Colosseum.Combat;
|
||||
using Colosseum.Player;
|
||||
|
||||
using Unity.Behavior;
|
||||
using Unity.Properties;
|
||||
using UnityEngine;
|
||||
|
||||
using Condition = Unity.Behavior.Condition;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 다운된 적대 대상이 지정 반경 이내에 존재하는지 확인합니다.
|
||||
/// 징벌(Punish) 패턴의 전제 조건으로 사용됩니다.
|
||||
/// </summary>
|
||||
[Serializable, GeneratePropertyBag]
|
||||
[Condition(name: "Downed Target In Range", story: "다운된 대상이 [{SearchRadius}]m 이내에 있는가?", id: "d4e5f6a7-3333-4444-555566667777")]
|
||||
[NodeDescription(
|
||||
name: "Downed Target In Range",
|
||||
story: "Downed target within [{SearchRadius}]m",
|
||||
category: "Condition/Pattern")]
|
||||
public partial class IsDownedTargetInRangeCondition : Condition
|
||||
{
|
||||
[Min(0f)]
|
||||
[Tooltip("다운된 대상을 탐색할 최대 반경")]
|
||||
[SerializeField]
|
||||
private float searchRadius = 6f;
|
||||
|
||||
public override bool IsTrue()
|
||||
{
|
||||
HitReactionController[] controllers = UnityEngine.Object.FindObjectsByType<HitReactionController>(FindObjectsSortMode.None);
|
||||
|
||||
for (int i = 0; i < controllers.Length; i++)
|
||||
{
|
||||
HitReactionController controller = controllers[i];
|
||||
if (controller == null || !controller.IsDowned)
|
||||
continue;
|
||||
|
||||
GameObject candidate = controller.gameObject;
|
||||
if (candidate == null || !candidate.activeInHierarchy)
|
||||
continue;
|
||||
|
||||
if (candidate == GameObject)
|
||||
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)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc4fae13a78a0fb46863950d1c6b5b8d
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
using Colosseum.Enemy;
|
||||
|
||||
using Unity.Behavior;
|
||||
using Unity.Properties;
|
||||
using UnityEngine;
|
||||
|
||||
using Condition = Unity.Behavior.Condition;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 현재 보스 페이즈가 지정된 최소 페이즈 이상인지 확인하는 조건 노드입니다.
|
||||
/// 패턴의 Phase 진입 조건을 BT에서 시각적으로 확인할 수 있습니다.
|
||||
/// </summary>
|
||||
[Serializable, GeneratePropertyBag]
|
||||
[Condition(name: "Min Phase Satisfied", story: "현재 페이즈가 [MinPhase] 이상인가?", id: "e3f4a5b6-7777-8888-9999-ddddddddeeee")]
|
||||
[NodeDescription(
|
||||
name: "Min Phase Satisfied",
|
||||
story: "현재 페이즈가 [MinPhase] 이상인가?",
|
||||
category: "Condition/Phase")]
|
||||
public partial class IsMinPhaseSatisfiedCondition : Condition
|
||||
{
|
||||
[SerializeReference]
|
||||
[Tooltip("최소 요구 페이즈 (1=Phase 1부터)")]
|
||||
public BlackboardVariable<int> MinPhase;
|
||||
|
||||
public override bool IsTrue()
|
||||
{
|
||||
int minPhase = MinPhase?.Value ?? 1;
|
||||
if (minPhase <= 1)
|
||||
return true;
|
||||
|
||||
BossCombatBehaviorContext context = GameObject.GetComponent<BossCombatBehaviorContext>();
|
||||
return context != null && context.CurrentPatternPhase >= minPhase;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46c95824ad6561f44833252a6f25852a
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Colosseum.Combat;
|
||||
|
||||
using Unity.Behavior;
|
||||
using Unity.Properties;
|
||||
using UnityEngine;
|
||||
|
||||
using Condition = Unity.Behavior.Condition;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 지정 거리 이상 떨어진 적대 대상이 존재하는지 확인합니다.
|
||||
/// 기동(도약) 또는 유틸리티(투척) 패턴의 전제 조건으로 사용됩니다.
|
||||
/// </summary>
|
||||
[Serializable, GeneratePropertyBag]
|
||||
[Condition(name: "Target Beyond Distance", story: "[{MinDistance}]m 이상 떨어진 대상이 있는가?", id: "e5f6a7b8-4444-5555-666677778888")]
|
||||
[NodeDescription(
|
||||
name: "Target Beyond Distance",
|
||||
story: "Target beyond [{MinDistance}]m exists",
|
||||
category: "Condition/Pattern")]
|
||||
public partial class IsTargetBeyondDistanceCondition : Condition
|
||||
{
|
||||
[Min(0f)]
|
||||
[Tooltip("이 거리 이상 떨어진 대상이 있는지 확인")]
|
||||
[SerializeField]
|
||||
private float minDistance = 8f;
|
||||
|
||||
public override bool IsTrue()
|
||||
{
|
||||
IDamageable[] targets = UnityEngine.Object.FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None)
|
||||
.OfType<IDamageable>()
|
||||
.ToArray();
|
||||
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
IDamageable target = targets[i];
|
||||
if (target == null)
|
||||
continue;
|
||||
|
||||
Component component = target as Component;
|
||||
if (component == null || !component.gameObject.activeInHierarchy)
|
||||
continue;
|
||||
|
||||
GameObject candidate = component.gameObject;
|
||||
if (candidate == GameObject)
|
||||
continue;
|
||||
|
||||
if (Team.IsSameTeam(GameObject, candidate))
|
||||
continue;
|
||||
|
||||
if (target.IsDead)
|
||||
continue;
|
||||
|
||||
float distance = Vector3.Distance(GameObject.transform.position, candidate.transform.position);
|
||||
if (distance >= minDistance)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e40fb41bbe354f4dafbe5b94fc6f9da
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
using Colosseum.Enemy;
|
||||
|
||||
using Unity.Behavior;
|
||||
using Unity.Properties;
|
||||
using UnityEngine;
|
||||
|
||||
using Condition = Unity.Behavior.Condition;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 현재 타겟이 보스의 공격 사거리 안에 있는지 확인하는 조건 노드입니다.
|
||||
/// </summary>
|
||||
[Serializable, GeneratePropertyBag]
|
||||
[Condition(name: "Is Target In Attack Range", story: "타겟이 공격 사거리 안에 있는가?", id: "57370b5b23f82a54dabc4f189a23286a")]
|
||||
[NodeDescription(
|
||||
name: "Is Target In Attack Range",
|
||||
story: "Is [Target] in attack range",
|
||||
category: "Condition/Combat")]
|
||||
public partial class IsTargetInAttackRangeCondition : Condition
|
||||
{
|
||||
[SerializeReference]
|
||||
public BlackboardVariable<GameObject> Target;
|
||||
|
||||
public override bool IsTrue()
|
||||
{
|
||||
if (Target?.Value == null)
|
||||
return false;
|
||||
|
||||
EnemyBase enemyBase = GameObject.GetComponent<EnemyBase>();
|
||||
float attackRange = enemyBase != null && enemyBase.Data != null ? enemyBase.Data.AttackRange : 2f;
|
||||
float distance = Vector3.Distance(GameObject.transform.position, Target.Value.transform.position);
|
||||
return distance <= attackRange + 0.25f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57370b5b23f82a54dabc4f189a23286a
|
||||
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
|
||||
using Colosseum.AI;
|
||||
using Colosseum.Enemy;
|
||||
|
||||
namespace Colosseum.AI.BehaviorActions.Conditions
|
||||
{
|
||||
/// <summary>
|
||||
/// 패턴 준비 여부를 확인하는 공통 헬퍼 메서드를 제공합니다.
|
||||
/// </summary>
|
||||
public static class PatternReadyHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 지정된 패턴이 현재 실행 가능한지 확인합니다.
|
||||
/// 패턴의 특성 필드를 사용하여 grace period 등을 판단합니다.
|
||||
/// </summary>
|
||||
public static bool IsPatternReady(GameObject gameObject, BossPatternData pattern)
|
||||
{
|
||||
if (pattern == null)
|
||||
return false;
|
||||
|
||||
if (pattern.IsSignature)
|
||||
return IsSignatureReady(gameObject);
|
||||
|
||||
BossCombatBehaviorContext context = gameObject.GetComponent<BossCombatBehaviorContext>();
|
||||
if (context == null)
|
||||
return false;
|
||||
|
||||
if (context.IsBehaviorSuppressed)
|
||||
return false;
|
||||
|
||||
if (context.CurrentPatternPhase < pattern.MinPhase)
|
||||
return false;
|
||||
|
||||
if (!context.IsPatternGracePeriodAllowed(pattern))
|
||||
return false;
|
||||
|
||||
return UsePatternAction.IsPatternReady(gameObject, pattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 시그니처 패턴 전용 준비 여부 확인.
|
||||
/// </summary>
|
||||
private static bool IsSignatureReady(GameObject gameObject)
|
||||
{
|
||||
BossCombatBehaviorContext context = gameObject.GetComponent<BossCombatBehaviorContext>();
|
||||
if (context == null)
|
||||
return false;
|
||||
|
||||
return context.IsSignaturePatternReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a0f2fd53cb729c4f97223570292e25c
|
||||
Reference in New Issue
Block a user