feat: 드로그 보스 AI 및 런타임 상태 구조 재구성
- 드로그 전투 컨텍스트를 BossBehaviorRuntimeState 중심 구조로 정리하고 BossEnemy, 패턴 액션, 조건 노드가 마지막 실행 결과와 phase 상태를 직접 사용하도록 갱신 - BT_Drog와 재빌드 에디터 스크립트를 확장해 phase 전환, 집행 결과 분기, 거리/쿨타임 기반 패턴 선택을 드로그 전용 자산과 노드 파라미터로 재구성 - 드로그 패턴/스킬/이펙트/애니메이션 플레이스홀더 자산을 재생성하고 보스 프리팹이 새 런타임 상태 및 등록 클립 구성을 참조하도록 정리
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Reflection;
|
||||
using Colosseum.AI;
|
||||
using Colosseum.AI.BehaviorActions.Conditions;
|
||||
using Colosseum.Enemy;
|
||||
using Colosseum.Skills;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -20,6 +21,26 @@ namespace Colosseum.Editor
|
||||
public static class RebuildDrogBehaviorAuthoringGraph
|
||||
{
|
||||
private const string GraphAssetPath = "Assets/_Game/AI/BT_Drog.asset";
|
||||
private const string DefaultPunishPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_밟기.asset";
|
||||
private const string DefaultSignaturePatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_집행.asset";
|
||||
private const string DefaultMobilityPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_도약.asset";
|
||||
private const string DefaultSecondaryPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_연타2.asset";
|
||||
private const string DefaultComboPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_연타3-강타.asset";
|
||||
private const string DefaultPrimaryPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_연타1.asset";
|
||||
private const string DefaultPressurePatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_연타4-발구르기.asset";
|
||||
private const string DefaultUtilityPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_투척.asset";
|
||||
private const string DefaultPhase3TransitionSkillPath = "Assets/_Game/Data/Skills/Data_Skill_Drog_포효.asset";
|
||||
|
||||
private const float DefaultDownedTargetSearchRadius = 6f;
|
||||
private const float DefaultLeapTargetMinDistance = 8f;
|
||||
private const float DefaultThrowTargetMinDistance = 5f;
|
||||
private const float DefaultPrimaryBranchAttackRange = 3f;
|
||||
private const float DefaultTargetSearchRange = 20f;
|
||||
private const float DefaultThrowAvailabilityDelay = 4f;
|
||||
private const float DefaultPhaseTransitionLockDuration = 1.25f;
|
||||
private const float DefaultPhase3SignatureDelay = 0.25f;
|
||||
private const float DefaultPhase2EnterHealthPercent = 75f;
|
||||
private const float DefaultPhase3EnterHealthPercent = 40f;
|
||||
|
||||
[MenuItem("Tools/Colosseum/Rebuild Drog Behavior Authoring Graph")]
|
||||
private static void Rebuild()
|
||||
@@ -172,7 +193,7 @@ namespace Colosseum.Editor
|
||||
}
|
||||
authoringGraphType = graphAsset.GetType();
|
||||
|
||||
object targetVariable = FindBlackboardVariableModel("Target");
|
||||
object targetVariable = EnsureBlackboardVariable<GameObject>("Target", null);
|
||||
if (targetVariable == null)
|
||||
{
|
||||
Debug.LogError("[DrogBTRebuild] Target 블랙보드 변수를 찾지 못했습니다.");
|
||||
@@ -180,43 +201,48 @@ namespace Colosseum.Editor
|
||||
}
|
||||
|
||||
// 구조 노드
|
||||
object startNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.Start", true), new Vector2(420f, -800f));
|
||||
object repeatNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.RepeaterModifier", true), new Vector2(420f, -620f));
|
||||
object startNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.Start", true), new Vector2(-1320f, -920f));
|
||||
object repeatNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.RepeaterModifier", true), new Vector2(-1320f, -720f));
|
||||
|
||||
// ── 프리팹에서 패턴 에셋 로드 ──
|
||||
const string prefabPath = "Assets/_Game/Prefabs/Bosses/Prefab_Boss_Drog.prefab";
|
||||
GameObject prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath) as GameObject;
|
||||
BossCombatBehaviorContext context = prefab?.GetComponent<BossCombatBehaviorContext>();
|
||||
if (context == null)
|
||||
{
|
||||
Debug.LogError("[DrogBTRebuild] 드로그 프리팹에서 BossCombatBehaviorContext를 찾지 못했습니다.");
|
||||
return;
|
||||
}
|
||||
// ── 드로그 패턴과 판단 수치는 노드 로컬 값으로 두고, Target만 블랙보드로 공유합니다. ──
|
||||
RemoveBlackboardVariables(
|
||||
"PunishPattern",
|
||||
"SignaturePattern",
|
||||
"MobilityPattern",
|
||||
"ComboPattern",
|
||||
"PrimaryPattern",
|
||||
"UtilityPattern",
|
||||
"PunishSearchRadius",
|
||||
"MobilityTriggerDistance",
|
||||
"UtilityTriggerDistance",
|
||||
"PrimaryAttackRange",
|
||||
"Phase2HealthPercent",
|
||||
"Phase3HealthPercent",
|
||||
"SightRange",
|
||||
"AttackRange",
|
||||
"MoveSpeed");
|
||||
|
||||
// protected 필드에서 BossPatternData 에셋 읽기 (리플렉션)
|
||||
BossPatternData punishPattern = ReadProtectedField<BossPatternData>(context, "punishPattern");
|
||||
BossPatternData signaturePattern = ReadProtectedField<BossPatternData>(context, "signaturePattern");
|
||||
BossPatternData mobilityPattern = ReadProtectedField<BossPatternData>(context, "mobilityPattern");
|
||||
BossPatternData comboPattern = ReadProtectedField<BossPatternData>(context, "comboPattern");
|
||||
BossPatternData primaryPattern = ReadProtectedField<BossPatternData>(context, "primaryPattern");
|
||||
BossPatternData utilityPattern = ReadProtectedField<BossPatternData>(context, "utilityPattern");
|
||||
float punishSearchRadius = ReadProtectedFieldValue<float>(context, "punishSearchRadius", 6f);
|
||||
BossPatternData punishPattern = LoadRequiredAsset<BossPatternData>(DefaultPunishPatternPath, "밟기 패턴");
|
||||
BossPatternData signaturePattern = LoadRequiredAsset<BossPatternData>(DefaultSignaturePatternPath, "집행 개시 패턴");
|
||||
BossPatternData mobilityPattern = LoadRequiredAsset<BossPatternData>(DefaultMobilityPatternPath, "점프 패턴");
|
||||
BossPatternData secondaryPattern = LoadRequiredAsset<BossPatternData>(DefaultSecondaryPatternPath, "연타2 패턴");
|
||||
BossPatternData comboPattern = LoadRequiredAsset<BossPatternData>(DefaultComboPatternPath, "연타3-강타 패턴");
|
||||
BossPatternData primaryPattern = LoadRequiredAsset<BossPatternData>(DefaultPrimaryPatternPath, "기본 근접 패턴");
|
||||
BossPatternData pressurePattern = LoadRequiredAsset<BossPatternData>(DefaultPressurePatternPath, "연타4-발구르기 패턴");
|
||||
BossPatternData utilityPattern = LoadRequiredAsset<BossPatternData>(DefaultUtilityPatternPath, "투척 패턴");
|
||||
SkillData phase3TransitionSkill = LoadRequiredAsset<SkillData>(DefaultPhase3TransitionSkillPath, "Phase 3 포효 스킬");
|
||||
|
||||
// 필수 패턴 검증 (combo는 선택 — 할당되지 않은 경우 해당 Branch만 생략)
|
||||
if (punishPattern == null || signaturePattern == null || mobilityPattern == null ||
|
||||
primaryPattern == null || utilityPattern == null)
|
||||
secondaryPattern == null || comboPattern == null || primaryPattern == null || pressurePattern == null ||
|
||||
utilityPattern == null || phase3TransitionSkill == null)
|
||||
{
|
||||
Debug.LogError("[DrogBTRebuild] 프리팹에서 필수 패턴 에셋을 읽지 못했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboPattern == null)
|
||||
Debug.LogWarning("[DrogBTRebuild] comboPattern이 할당되지 않았습니다. 해당 Branch를 생략합니다.");
|
||||
|
||||
// ── 계단식 우선순위 체인 ──
|
||||
// 설계안 우선순위: 다운 추가타 > 도약 > 집행 개시 > 기본 루프 > 조합 > 유틸리티
|
||||
// 각 Branch: CheckPatternReady → true → UsePatternByRole
|
||||
// false → 다음 우선순위 Branch 시도
|
||||
// 설계안 우선순위: 밟기 > 집행 개시 > 조합 > 도약 > 기본 루프 > 유틸리티
|
||||
// 각 Branch는 조건만 판정하고, 실제 대상 선택/검증/실행은 Sequence 내부 노드로 드러냅니다.
|
||||
// 마지막까지 모든 조건이 false이면 Chase (fallback)
|
||||
//
|
||||
// 연결 흐름: Branch.True → FloatingPort(True).InputPort → FloatingPort(True).OutputPort → Action.InputPort
|
||||
@@ -229,149 +255,257 @@ namespace Colosseum.Editor
|
||||
// Action: (-598, y + 199)
|
||||
|
||||
const float branchX = -800f;
|
||||
const float rootRefreshX = branchX - 540f;
|
||||
const float mainSequenceX = branchX + 340f;
|
||||
const float mainValidateX = branchX + 700f;
|
||||
const float mainUseX = branchX + 1100f;
|
||||
const float truePortOffsetX = 203f;
|
||||
const float truePortOffsetY = 120f;
|
||||
const float falsePortOffsetX = -211f;
|
||||
const float falsePortOffsetY = 124f;
|
||||
const float actionOffsetX = 202f;
|
||||
const float actionOffsetY = 219f;
|
||||
const float startY = -800f;
|
||||
const float stepY = 320f;
|
||||
const float startY = -700f;
|
||||
const float rootRefreshY = startY - 120f;
|
||||
const float stepY = 620f;
|
||||
const float nestedBranchOffsetY = 180f;
|
||||
const float nestedActionOffsetY = 360f;
|
||||
|
||||
// #1 Punish — 다운 추가타 (전제 조건: 다운된 대상이 반경 이내에 있어야 함)
|
||||
// 루프 시작마다 주 대상을 블랙보드에 동기화한 뒤 패턴 우선순위 체인으로 들어갑니다.
|
||||
object rootRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(rootRefreshX, rootRefreshY));
|
||||
SetNodeFieldValue(rootRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
|
||||
|
||||
// #1 Punish — 밟기 (전제 조건: 다운된 대상이 반경 이내에 있어야 함)
|
||||
object downBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY));
|
||||
AttachPatternReadyCondition(downBranch, punishPattern, authoringAssembly);
|
||||
AttachConditionWithValue(downBranch, typeof(IsDownedTargetInRangeCondition), "searchRadius", punishSearchRadius, authoringAssembly);
|
||||
AttachConditionWithValue(downBranch, typeof(IsDownedTargetInRangeCondition), "SearchRadius", DefaultDownedTargetSearchRadius, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(downBranch, punishPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(downBranch, true);
|
||||
object downUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + actionOffsetX, startY + actionOffsetY));
|
||||
|
||||
object downSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY));
|
||||
object downSelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectNearestDownedTargetAction), new Vector2(mainValidateX, startY));
|
||||
SetNodeFieldValue(downSelectNode, "SearchRadius", DefaultDownedTargetSearchRadius, setFieldValueMethod);
|
||||
LinkTarget(downSelectNode, targetVariable);
|
||||
object downUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY));
|
||||
SetNodeFieldValue(downUseNode, "Pattern", punishPattern, setFieldValueMethod);
|
||||
LinkTarget(downUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, downSequence, downSelectNode, downUseNode);
|
||||
|
||||
// #2 Mobility — 도약 (전제 조건: 지나치게 먼 대상이 존재해야 함)
|
||||
float mobilityTriggerDistance = ReadProtectedFieldValue<float>(context, "mobilityTriggerDistance", 8f);
|
||||
object leapBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY));
|
||||
AttachPatternReadyCondition(leapBranch, mobilityPattern, authoringAssembly);
|
||||
AttachConditionWithValue(leapBranch, typeof(IsTargetBeyondDistanceCondition), "minDistance", mobilityTriggerDistance, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(leapBranch, mobilityPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(leapBranch, true);
|
||||
object leapUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + actionOffsetX, startY + stepY + actionOffsetY));
|
||||
SetNodeFieldValue(leapUseNode, "Pattern", mobilityPattern, setFieldValueMethod);
|
||||
LinkTarget(leapUseNode, targetVariable);
|
||||
|
||||
// #3 Signature — 집행 개시 (Sequence: 패턴 실행 → 결과 분기)
|
||||
// #2 Signature — 집행 개시 (Sequence: 패턴 실행 → 결과 분기)
|
||||
// signatureBranch.True → Sequence:
|
||||
// Child 1: 집행개시 패턴 실행 (ChargeWait 포함)
|
||||
// Child 2: Branch(패턴 성공? = 차단 안 됨) → 범위 효과 또는 보스 경직
|
||||
// 패턴이 Failure 반환(차단 성공) → Sequence Failure → signatureBranch False → 다음 우선순위
|
||||
object signatureBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 2));
|
||||
// Child 1: 현재 주 대상 검증
|
||||
// Child 2: 집행개시 패턴 실행 (ChargeWait 포함)
|
||||
// Child 3: Branch(차단 성공 여부) → 보스 경직 또는 범위 효과
|
||||
object signatureBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY));
|
||||
AttachPatternReadyCondition(signatureBranch, signaturePattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(signatureBranch, signaturePattern, authoringAssembly);
|
||||
AttachConditionWithValue(signatureBranch, typeof(IsPhaseElapsedTimeAboveCondition), "Seconds", DefaultPhase3SignatureDelay, authoringAssembly);
|
||||
SetBranchRequiresAll(signatureBranch, true);
|
||||
|
||||
// Sequence: 패턴 실행 → 결과 분기
|
||||
object signatureSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(branchX + 220f, startY + stepY * 2));
|
||||
new Vector2(mainSequenceX, startY + stepY));
|
||||
|
||||
// Child 1: 집행개시 패턴 실행
|
||||
object signatureUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + 400f, startY + stepY * 2));
|
||||
object signatureValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(mainValidateX, startY + stepY));
|
||||
LinkTarget(signatureValidateNode, targetVariable);
|
||||
|
||||
// Child 2: 집행 패턴 실행
|
||||
object signatureUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY));
|
||||
SetNodeFieldValue(signatureUseNode, "Pattern", signaturePattern, setFieldValueMethod);
|
||||
SetNodeFieldValue(signatureUseNode, "ContinueOnResolvedFailure", true, setFieldValueMethod);
|
||||
LinkTarget(signatureUseNode, targetVariable);
|
||||
|
||||
// Child 2: 패턴 완료 시 결과 분기
|
||||
// 패턴이 Success 반환(차단 안 됨 = 충전 완료) → True → 실패 효과 적용
|
||||
// 패턴이 Failure 반환(차단 성공) → False → 보스 경직
|
||||
object outcomeBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX + 220f, startY + stepY * 2 + 180f));
|
||||
// Child 3: 패턴 완료 시 결과 분기
|
||||
// 패턴이 실패 결과로 끝나면 True → 보스 경직, 성공적으로 완수되면 False → 범위 효과 적용
|
||||
object outcomeBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(mainUseX + 320f, startY + stepY));
|
||||
AttachConditionWithValue(outcomeBranch, typeof(IsPatternExecutionResultCondition), "Result", BossPatternExecutionResult.Failed, authoringAssembly);
|
||||
|
||||
object failureEffectsNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SignatureFailureEffectsAction), new Vector2(branchX + 400f, startY + stepY * 2 + 180f));
|
||||
object staggerNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(BossStaggerAction), new Vector2(branchX + 400f, startY + stepY * 2 + 360f));
|
||||
object staggerNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(BossStaggerAction), new Vector2(mainUseX + 520f, startY + stepY + nestedBranchOffsetY));
|
||||
object failureEffectsNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SignatureFailureEffectsAction), new Vector2(mainUseX + 520f, startY + stepY + nestedActionOffsetY));
|
||||
|
||||
// outcomeBranch True → 실패 효과 (충전 완료 = 플레이어들이 차단 실패)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, outcomeBranch, "True", failureEffectsNode);
|
||||
// outcomeBranch False → 보스 경직 (차단 성공)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, outcomeBranch, "False", staggerNode);
|
||||
// outcomeBranch True → 보스 경직 (패턴 실패 결과)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, outcomeBranch, "True", staggerNode);
|
||||
// outcomeBranch False → 실패 효과 (패턴 성공 완수)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, outcomeBranch, "False", failureEffectsNode);
|
||||
|
||||
// Sequence에 자식 연결
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, signatureSequence, signatureUseNode, outcomeBranch);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, signatureSequence, signatureValidateNode, signatureUseNode, outcomeBranch);
|
||||
|
||||
// 메인 체인: signatureBranch.True → Sequence
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, signatureBranch, "True", signatureSequence);
|
||||
|
||||
// #4 Combo — 콤보 패턴 + 조건부 도약 (Sequence)
|
||||
// comboBranch.True → Sequence:
|
||||
// Child 1: 연타2-강타 실행
|
||||
// Child 2: Branch(거리 초과 대상 존재) → 도약 실행
|
||||
// 거리 초과 대상이 없으면 Branch Failure → Sequence Failure → comboBranch Failure → primaryBranch로 연결
|
||||
object comboBranch = null;
|
||||
object comboUseNode = null;
|
||||
if (comboPattern != null)
|
||||
{
|
||||
// 메인 체인용 Branch (콤보 준비 + 페이즈 조건)
|
||||
comboBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 3));
|
||||
AttachPatternReadyCondition(comboBranch, comboPattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(comboBranch, comboPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(comboBranch, true);
|
||||
// #3 Combo — 연타3-강타
|
||||
object comboBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 2));
|
||||
AttachPatternReadyCondition(comboBranch, comboPattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(comboBranch, comboPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(comboBranch, true);
|
||||
|
||||
// Sequence: 콤보 실행 → 조건부 도약
|
||||
object comboSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(branchX + 220f, startY + stepY * 3));
|
||||
object comboSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 2));
|
||||
object comboValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(mainValidateX, startY + stepY * 2));
|
||||
LinkTarget(comboValidateNode, targetVariable);
|
||||
object comboUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 2));
|
||||
SetNodeFieldValue(comboUseNode, "Pattern", comboPattern, setFieldValueMethod);
|
||||
LinkTarget(comboUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, comboSequence, comboValidateNode, comboUseNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboBranch, "True", comboSequence);
|
||||
|
||||
// Child 1: 콤보 패턴 실행 (연타2-강타 + 대기)
|
||||
comboUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + 400f, startY + stepY * 3));
|
||||
SetNodeFieldValue(comboUseNode, "Pattern", comboPattern, setFieldValueMethod);
|
||||
LinkTarget(comboUseNode, targetVariable);
|
||||
// #4 Mobility — 도약 (전제 조건: 지나치게 먼 대상이 존재해야 함)
|
||||
object leapBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 3));
|
||||
AttachPatternReadyCondition(leapBranch, mobilityPattern, authoringAssembly);
|
||||
AttachConditionWithValue(leapBranch, typeof(IsTargetBeyondDistanceCondition), "MinDistance", DefaultLeapTargetMinDistance, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(leapBranch, mobilityPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(leapBranch, true);
|
||||
object leapSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 3));
|
||||
object leapSelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectTargetByDistanceAction), new Vector2(mainValidateX, startY + stepY * 3));
|
||||
SetNodeFieldValue(leapSelectNode, "MinRange", DefaultLeapTargetMinDistance, setFieldValueMethod);
|
||||
SetNodeFieldValue(leapSelectNode, "MaxRange", DefaultTargetSearchRange, setFieldValueMethod);
|
||||
SetNodeFieldValue(leapSelectNode, "SelectionMode", DistanceTargetSelectionMode.Farthest, setFieldValueMethod);
|
||||
LinkTarget(leapSelectNode, targetVariable);
|
||||
object leapUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 3));
|
||||
SetNodeFieldValue(leapUseNode, "Pattern", mobilityPattern, setFieldValueMethod);
|
||||
LinkTarget(leapUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, leapSequence, leapSelectNode, leapUseNode);
|
||||
|
||||
// Child 2: 조건부 도약 (거리 초과 대상 있을 때만)
|
||||
object comboLeapBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX + 220f, startY + stepY * 3 + 180f));
|
||||
AttachConditionWithValue(comboLeapBranch, typeof(IsTargetBeyondDistanceCondition), "minDistance", mobilityTriggerDistance, authoringAssembly);
|
||||
object comboLeapUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + 400f, startY + stepY * 3 + 180f));
|
||||
SetNodeFieldValue(comboLeapUseNode, "Pattern", mobilityPattern, setFieldValueMethod);
|
||||
LinkTarget(comboLeapUseNode, targetVariable);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboLeapBranch, "True", comboLeapUseNode);
|
||||
|
||||
// Sequence에 자식 연결
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, comboSequence, comboUseNode, comboLeapBranch);
|
||||
|
||||
// 메인 체인: comboBranch.True → Sequence
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboBranch, "True", comboSequence);
|
||||
}
|
||||
|
||||
// #5 Primary — 사거리 + 기본 패턴 준비 (모두 충족)
|
||||
// #5 Primary — 연타1
|
||||
object primaryBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 4));
|
||||
object primaryRangeCondModel = AttachCondition(primaryBranch, typeof(IsTargetInAttackRangeCondition), authoringAssembly);
|
||||
if (primaryRangeCondModel != null) setFieldMethod.Invoke(primaryRangeCondModel, new object[] { "Target", targetVariable, typeof(GameObject) });
|
||||
if (primaryRangeCondModel != null) SetConditionFieldValue(primaryRangeCondModel, "AttackRange", DefaultPrimaryBranchAttackRange);
|
||||
AttachPatternReadyCondition(primaryBranch, primaryPattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(primaryBranch, primaryPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(primaryBranch, true);
|
||||
object primaryUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + actionOffsetX, startY + stepY * 4 + actionOffsetY));
|
||||
object primarySequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 4));
|
||||
object primaryValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(mainValidateX, startY + stepY * 4));
|
||||
LinkTarget(primaryValidateNode, targetVariable);
|
||||
object primaryUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 4));
|
||||
SetNodeFieldValue(primaryUseNode, "Pattern", primaryPattern, setFieldValueMethod);
|
||||
LinkTarget(primaryUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, primarySequence, primaryValidateNode, primaryUseNode);
|
||||
|
||||
// #6 Utility — 유틸리티 (전제 조건: 원거리 대상이 존재해야 함)
|
||||
float utilityTriggerDistance = ReadProtectedFieldValue<float>(context, "utilityTriggerDistance", 5f);
|
||||
object utilityBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 5));
|
||||
// #6 Secondary Basic — 연타2
|
||||
object secondaryBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 5));
|
||||
object secondaryRangeCondModel = AttachCondition(secondaryBranch, typeof(IsTargetInAttackRangeCondition), authoringAssembly);
|
||||
if (secondaryRangeCondModel != null) setFieldMethod.Invoke(secondaryRangeCondModel, new object[] { "Target", targetVariable, typeof(GameObject) });
|
||||
if (secondaryRangeCondModel != null) SetConditionFieldValue(secondaryRangeCondModel, "AttackRange", DefaultPrimaryBranchAttackRange);
|
||||
AttachPatternReadyCondition(secondaryBranch, secondaryPattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(secondaryBranch, secondaryPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(secondaryBranch, true);
|
||||
object secondarySequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 5));
|
||||
object secondaryValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(mainValidateX, startY + stepY * 5));
|
||||
LinkTarget(secondaryValidateNode, targetVariable);
|
||||
object secondaryUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 5));
|
||||
SetNodeFieldValue(secondaryUseNode, "Pattern", secondaryPattern, setFieldValueMethod);
|
||||
LinkTarget(secondaryUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, secondarySequence, secondaryValidateNode, secondaryUseNode);
|
||||
|
||||
// #7 Pressure — 연타4-발구르기
|
||||
object pressureBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 6));
|
||||
object pressureRangeCondModel = AttachCondition(pressureBranch, typeof(IsTargetInAttackRangeCondition), authoringAssembly);
|
||||
if (pressureRangeCondModel != null) setFieldMethod.Invoke(pressureRangeCondModel, new object[] { "Target", targetVariable, typeof(GameObject) });
|
||||
if (pressureRangeCondModel != null) SetConditionFieldValue(pressureRangeCondModel, "AttackRange", DefaultPrimaryBranchAttackRange);
|
||||
AttachPatternReadyCondition(pressureBranch, pressurePattern, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(pressureBranch, pressurePattern, authoringAssembly);
|
||||
SetBranchRequiresAll(pressureBranch, true);
|
||||
object pressureSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 6));
|
||||
object pressureValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(mainValidateX, startY + stepY * 6));
|
||||
LinkTarget(pressureValidateNode, targetVariable);
|
||||
object pressureUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 6));
|
||||
SetNodeFieldValue(pressureUseNode, "Pattern", pressurePattern, setFieldValueMethod);
|
||||
LinkTarget(pressureUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, pressureSequence, pressureValidateNode, pressureUseNode);
|
||||
|
||||
// #8 Utility — 유틸리티 (전제 조건: 원거리 대상이 존재해야 함)
|
||||
object utilityBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 7));
|
||||
AttachPatternReadyCondition(utilityBranch, utilityPattern, authoringAssembly);
|
||||
AttachConditionWithValue(utilityBranch, typeof(IsTargetBeyondDistanceCondition), "minDistance", utilityTriggerDistance, authoringAssembly);
|
||||
AttachConditionWithValue(utilityBranch, typeof(IsTargetBeyondDistanceCondition), "MinDistance", DefaultThrowTargetMinDistance, authoringAssembly);
|
||||
AttachConditionWithValue(utilityBranch, typeof(IsPhaseElapsedTimeAboveCondition), "Seconds", DefaultThrowAvailabilityDelay, authoringAssembly);
|
||||
AttachPhaseConditionIfNeeded(utilityBranch, utilityPattern, authoringAssembly);
|
||||
SetBranchRequiresAll(utilityBranch, true);
|
||||
object utilityUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(branchX + actionOffsetX, startY + stepY * 5 + actionOffsetY));
|
||||
object utilitySequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, startY + stepY * 7));
|
||||
object utilitySelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectAlternateTargetByDistanceAction), new Vector2(mainValidateX, startY + stepY * 7));
|
||||
SetNodeFieldValue(utilitySelectNode, "MinRange", DefaultThrowTargetMinDistance, setFieldValueMethod);
|
||||
SetNodeFieldValue(utilitySelectNode, "MaxRange", DefaultTargetSearchRange, setFieldValueMethod);
|
||||
LinkTarget(utilitySelectNode, targetVariable);
|
||||
object utilityUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(mainUseX, startY + stepY * 7));
|
||||
SetNodeFieldValue(utilityUseNode, "Pattern", utilityPattern, setFieldValueMethod);
|
||||
LinkTarget(utilityUseNode, targetVariable);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, utilitySequence, utilitySelectNode, utilityUseNode);
|
||||
|
||||
// #7 Chase — fallback (Branch 아님, Sequence 사용)
|
||||
object chaseSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true), new Vector2(branchX, startY + stepY * 6));
|
||||
object chaseRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(branchX + 160f, startY + stepY * 6 + 80f));
|
||||
object chaseHasTargetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(branchX + 320f, startY + stepY * 6 + 80f));
|
||||
object chaseUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ChaseTargetAction), new Vector2(branchX + 480f, startY + stepY * 6 + 80f));
|
||||
// #9 Chase — fallback (Branch 아님, Sequence 사용)
|
||||
object chaseSequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true), new Vector2(branchX, startY + stepY * 8));
|
||||
object chaseRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(branchX + 160f, startY + stepY * 8 + 80f));
|
||||
SetNodeFieldValue(chaseRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
|
||||
object chaseHasTargetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(branchX + 320f, startY + stepY * 8 + 80f));
|
||||
object chaseUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ChaseTargetAction), new Vector2(branchX + 480f, startY + stepY * 8 + 80f));
|
||||
SetNodeFieldValue(chaseUseNode, "StopDistance", DefaultPrimaryBranchAttackRange, setFieldValueMethod);
|
||||
|
||||
Connect(graphAsset, connectEdgeMethod, GetDefaultOutputPort(rootRefreshNode), GetDefaultInputPort(downBranch));
|
||||
|
||||
List<object> phaseBranches = new List<object>();
|
||||
object phaseEntryNode = null;
|
||||
object previousPhaseBranch = null;
|
||||
|
||||
object phase2Branch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, -1320f));
|
||||
AttachConditionWithValue(phase2Branch, typeof(IsCurrentPhaseCondition), "Phase", 1, authoringAssembly);
|
||||
AttachConditionWithValue(phase2Branch, typeof(IsHealthBelowCondition), "HealthPercent", DefaultPhase2EnterHealthPercent, authoringAssembly);
|
||||
SetBranchRequiresAll(phase2Branch, true);
|
||||
phaseBranches.Add(phase2Branch);
|
||||
phaseEntryNode = phase2Branch;
|
||||
|
||||
object phase2Sequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, -1320f));
|
||||
object phase2TransitionWaitNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(WaitAction), new Vector2(mainValidateX, -1320f));
|
||||
SetNodeFieldValue(phase2TransitionWaitNode, "Duration", DefaultPhaseTransitionLockDuration, setFieldValueMethod);
|
||||
object phase2SetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(mainUseX, -1320f));
|
||||
SetNodeFieldValue(phase2SetNode, "TargetPhase", 2, setFieldValueMethod);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, phase2Sequence, phase2TransitionWaitNode, phase2SetNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, phase2Branch, "True", phase2Sequence);
|
||||
|
||||
object phase3Branch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, -1040f));
|
||||
AttachConditionWithValue(phase3Branch, typeof(IsCurrentPhaseCondition), "Phase", 2, authoringAssembly);
|
||||
AttachConditionWithValue(phase3Branch, typeof(IsHealthBelowCondition), "HealthPercent", DefaultPhase3EnterHealthPercent, authoringAssembly);
|
||||
SetBranchRequiresAll(phase3Branch, true);
|
||||
phaseBranches.Add(phase3Branch);
|
||||
|
||||
object phase3Sequence = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod,
|
||||
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
|
||||
new Vector2(mainSequenceX, -1040f));
|
||||
object phase3TransitionWaitNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(WaitAction), new Vector2(mainValidateX, -1040f));
|
||||
SetNodeFieldValue(phase3TransitionWaitNode, "Duration", DefaultPhaseTransitionLockDuration, setFieldValueMethod);
|
||||
object phase3RoarNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UseSkillAction), new Vector2(mainValidateX + 180f, -1040f));
|
||||
SetNodeFieldValue(phase3RoarNode, "스킬", phase3TransitionSkill, setFieldValueMethod);
|
||||
object phase3SetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(mainUseX, -1040f));
|
||||
SetNodeFieldValue(phase3SetNode, "TargetPhase", 3, setFieldValueMethod);
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, phase3Sequence, phase3TransitionWaitNode, phase3RoarNode, phase3SetNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, phase3Branch, "True", phase3Sequence);
|
||||
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, phase2Branch, "False", phase3Branch);
|
||||
previousPhaseBranch = phase3Branch;
|
||||
|
||||
if (previousPhaseBranch != null)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, previousPhaseBranch, "False", rootRefreshNode);
|
||||
|
||||
// ── FloatingPortNodeModel 생성 + 위치 보정 ──
|
||||
// Branch 노드의 NamedPort(True/False)에 대해 FloatingPortNodeModel을 생성합니다.
|
||||
// CreateNodePortsForNode는 기본 위치(Branch + 200px Y)를 사용하므로, 생성 후 사용자 조정 기준 위치로 이동합니다.
|
||||
var allBranches = new List<object> { downBranch, leapBranch, signatureBranch, outcomeBranch };
|
||||
if (comboBranch != null) allBranches.Add(comboBranch);
|
||||
allBranches.AddRange(new[] { primaryBranch, utilityBranch });
|
||||
var allBranches = new List<object>();
|
||||
allBranches.AddRange(phaseBranches);
|
||||
allBranches.AddRange(new[] { downBranch, leapBranch, signatureBranch, outcomeBranch });
|
||||
allBranches.AddRange(new[] { comboBranch, primaryBranch, secondaryBranch, pressureBranch, utilityBranch });
|
||||
foreach (object branch in allBranches)
|
||||
{
|
||||
createNodePortsMethod?.Invoke(graphAsset, new object[] { branch });
|
||||
@@ -392,32 +526,35 @@ namespace Colosseum.Editor
|
||||
|
||||
// ── 연결 ──
|
||||
|
||||
// Start → Repeater → 첫 번째 Branch
|
||||
// Start → Repeater → phaseEntry(페이즈 전환 조건 -> 전투 의사결정 체인)
|
||||
Connect(graphAsset, connectEdgeMethod, GetDefaultOutputPort(startNode), GetDefaultInputPort(repeatNode));
|
||||
Connect(graphAsset, connectEdgeMethod, GetDefaultOutputPort(repeatNode), GetDefaultInputPort(downBranch));
|
||||
Connect(graphAsset, connectEdgeMethod, GetDefaultOutputPort(repeatNode), GetDefaultInputPort(phaseEntryNode));
|
||||
|
||||
// 각 Branch의 True FloatingPort → Action (combo, signature는 내부에서 Sequence로 연결됨)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, downBranch, "True", downUseNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, leapBranch, "True", leapUseNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, downBranch, "True", downSequence);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, leapBranch, "True", leapSequence);
|
||||
// signatureBranch.True는 signatureSequence에 이미 연결됨
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, primaryBranch, "True", primaryUseNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, utilityBranch, "True", utilityUseNode);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboBranch, "True", comboSequence);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, primaryBranch, "True", primarySequence);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, secondaryBranch, "True", secondarySequence);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, pressureBranch, "True", pressureSequence);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, utilityBranch, "True", utilitySequence);
|
||||
|
||||
// 각 Branch의 False FloatingPort → 다음 우선순위 (계단식 체인)
|
||||
// combo 유무에 따라 연결 경로가 달라짐
|
||||
object afterSignature = comboBranch ?? primaryBranch;
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, downBranch, "False", leapBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, leapBranch, "False", signatureBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, signatureBranch, "False", afterSignature);
|
||||
if (comboBranch != null)
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboBranch, "False", primaryBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, primaryBranch, "False", utilityBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, downBranch, "False", signatureBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, signatureBranch, "False", comboBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, comboBranch, "False", leapBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, leapBranch, "False", primaryBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, primaryBranch, "False", secondaryBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, secondaryBranch, "False", pressureBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, pressureBranch, "False", utilityBranch);
|
||||
ConnectBranch(graphAsset, connectEdgeMethod, utilityBranch, "False", chaseSequence);
|
||||
|
||||
// Chase Sequence 자식 연결
|
||||
ConnectChildren(graphAsset, connectEdgeMethod, chaseSequence, chaseRefreshNode, chaseHasTargetNode, chaseUseNode);
|
||||
|
||||
// Chase 노드 블랙보드 변수 연결
|
||||
// Chase/루트 노드 블랙보드 변수 연결
|
||||
LinkTarget(rootRefreshNode, targetVariable);
|
||||
LinkTarget(chaseRefreshNode, targetVariable);
|
||||
LinkTarget(chaseHasTargetNode, targetVariable);
|
||||
LinkTarget(chaseUseNode, targetVariable);
|
||||
@@ -569,15 +706,6 @@ namespace Colosseum.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ConditionModel의 필드를 블랙보드 변수에 연결합니다.
|
||||
/// </summary>
|
||||
private static void LinkConditionFieldToVariable(object conditionModel, string fieldName, Type fieldType, object variableModel)
|
||||
{
|
||||
MethodInfo setFieldMethod = conditionModel.GetType().GetMethod("SetField", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
setFieldMethod?.Invoke(conditionModel, new object[] { fieldName, variableModel, fieldType });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Condition을 부착하고, 지정된 enum 필드 값을 설정합니다.
|
||||
/// CheckPatternReadyCondition처럼 필드 값으로 역할을 구분하는 Condition에 사용합니다.
|
||||
@@ -613,6 +741,31 @@ namespace Colosseum.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetConditionFieldValue(object conditionModel, string fieldName, object fieldValue)
|
||||
{
|
||||
if (conditionModel == null || fieldValue == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo genericSetField = conditionModel.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
.FirstOrDefault(method => method.Name == "SetField" && method.IsGenericMethod && method.GetParameters().Length == 2);
|
||||
|
||||
if (genericSetField == null)
|
||||
{
|
||||
Debug.LogWarning($"[DrogBTRebuild] SetConditionFieldValue: '{fieldName}' 필드 설정 메서드를 찾지 못했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
MethodInfo closedMethod = genericSetField.MakeGenericMethod(fieldValue.GetType());
|
||||
closedMethod.Invoke(conditionModel, new object[] { fieldName, fieldValue });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"[DrogBTRebuild] SetConditionFieldValue 실패 ({fieldName}): {ex.GetType().Name}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 노드 모델의 지정된 enum 필드 값을 설정합니다.
|
||||
/// UsePatternByRoleAction처럼 필드 값으로 역할을 구분하는 Action에 사용합니다.
|
||||
@@ -701,35 +854,80 @@ namespace Colosseum.Editor
|
||||
return success ? parameters[0] : null;
|
||||
}
|
||||
|
||||
private static object FindBlackboardVariableModel(string variableName)
|
||||
private static IList GetBlackboardVariables(UnityEngine.Object blackboardAsset)
|
||||
{
|
||||
UnityEngine.Object blackboardAsset = AssetDatabase.LoadAllAssetsAtPath(GraphAssetPath)
|
||||
.FirstOrDefault(asset => asset != null && asset.GetType().Name.Contains("BehaviorBlackboardAuthoringAsset", StringComparison.Ordinal));
|
||||
|
||||
if (blackboardAsset == null)
|
||||
return null;
|
||||
|
||||
PropertyInfo variablesProperty = blackboardAsset.GetType().GetProperty("Variables", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
FieldInfo variablesField = blackboardAsset.GetType().GetField("m_Variables", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
IEnumerable variables = variablesProperty?.GetValue(blackboardAsset) as IEnumerable ?? variablesField?.GetValue(blackboardAsset) as IEnumerable;
|
||||
if (variables == null)
|
||||
return null;
|
||||
return variablesProperty?.GetValue(blackboardAsset) as IList ?? variablesField?.GetValue(blackboardAsset) as IList;
|
||||
}
|
||||
|
||||
foreach (object variable in variables)
|
||||
private static string GetVariableName(object variableModel)
|
||||
{
|
||||
return GetFieldOrPropertyValue(variableModel, "Name") as string;
|
||||
}
|
||||
|
||||
private static Type ResolveTypedVariableModelGenericType(IList existingVariables)
|
||||
{
|
||||
for (int i = 0; i < existingVariables.Count; i++)
|
||||
{
|
||||
object variable = existingVariables[i];
|
||||
if (variable == null)
|
||||
continue;
|
||||
|
||||
PropertyInfo nameProperty = variable.GetType().GetProperty("Name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
FieldInfo nameField = variable.GetType().GetField("Name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
string name = nameProperty?.GetValue(variable) as string ?? nameField?.GetValue(variable) as string;
|
||||
if (name == variableName)
|
||||
return variable;
|
||||
Type variableType = variable.GetType();
|
||||
if (variableType.IsGenericType)
|
||||
return variableType.GetGenericTypeDefinition();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object CreateSerializableGuid(Type variableModelType)
|
||||
{
|
||||
FieldInfo idField = variableModelType.GetField("ID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
Type guidType = idField?.FieldType;
|
||||
ConstructorInfo guidConstructor = guidType?.GetConstructor(new[] { typeof(ulong), typeof(ulong) });
|
||||
if (guidConstructor == null)
|
||||
return null;
|
||||
|
||||
byte[] guidBytes = Guid.NewGuid().ToByteArray();
|
||||
ulong value0 = BitConverter.ToUInt64(guidBytes, 0);
|
||||
ulong value1 = BitConverter.ToUInt64(guidBytes, 8);
|
||||
return guidConstructor.Invoke(new object[] { value0, value1 });
|
||||
}
|
||||
|
||||
private static object GetFieldOrPropertyValue(object target, string memberName)
|
||||
{
|
||||
if (target == null)
|
||||
return null;
|
||||
|
||||
PropertyInfo property = target.GetType().GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (property != null)
|
||||
return property.GetValue(target);
|
||||
|
||||
FieldInfo field = target.GetType().GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return field?.GetValue(target);
|
||||
}
|
||||
|
||||
private static void SetFieldOrPropertyValue(object target, string memberName, object value)
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
PropertyInfo property = target.GetType().GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (property != null && property.CanWrite)
|
||||
{
|
||||
property.SetValue(target, value);
|
||||
return;
|
||||
}
|
||||
|
||||
FieldInfo field = target.GetType().GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
field?.SetValue(target, value);
|
||||
}
|
||||
|
||||
private static void LinkTarget(object node, object targetVariable)
|
||||
{
|
||||
LinkFieldToVariable(node, "Target", typeof(GameObject), targetVariable);
|
||||
@@ -982,37 +1180,111 @@ namespace Colosseum.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 컴포넌트의 protected 필드 값을 읽습니다 (참조 타입용).
|
||||
/// 프리팹에서 BossPatternData 에셋을 로드할 때 사용합니다.
|
||||
/// BT 재빌드에 필요한 자산을 지정 경로에서 직접 로드합니다.
|
||||
/// </summary>
|
||||
private static T ReadProtectedField<T>(object obj, string fieldName) where T : class
|
||||
private static T LoadRequiredAsset<T>(string assetPath, string assetLabel) where T : UnityEngine.Object
|
||||
{
|
||||
Type type = obj.GetType();
|
||||
while (type != null)
|
||||
{
|
||||
FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
if (field != null)
|
||||
return field.GetValue(obj) as T;
|
||||
type = type.BaseType;
|
||||
}
|
||||
Debug.LogError($"[DrogBTRebuild] '{fieldName}' 필드를 {obj.GetType().Name}에서 찾지 못했습니다.");
|
||||
return null;
|
||||
T asset = AssetDatabase.LoadAssetAtPath<T>(assetPath);
|
||||
if (asset == null)
|
||||
Debug.LogError($"[DrogBTRebuild] {assetLabel} 로드 실패: {assetPath}");
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 컴포넌트의 protected 필드 값을 읽습니다 (값 타입용).
|
||||
/// 선택 자산을 로드합니다. 없으면 null을 반환합니다.
|
||||
/// </summary>
|
||||
private static T ReadProtectedFieldValue<T>(object obj, string fieldName, T defaultValue) where T : struct
|
||||
private static T LoadOptionalAsset<T>(string assetPath) where T : UnityEngine.Object
|
||||
{
|
||||
Type type = obj.GetType();
|
||||
while (type != null)
|
||||
return AssetDatabase.LoadAssetAtPath<T>(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BT 블랙보드에 필요한 변수가 없으면 기본값으로 생성하고, 있으면 기존 값을 유지합니다.
|
||||
/// </summary>
|
||||
private static object EnsureBlackboardVariable<T>(string variableName, T defaultValue)
|
||||
{
|
||||
UnityEngine.Object blackboardAsset = AssetDatabase.LoadAllAssetsAtPath(GraphAssetPath)
|
||||
.FirstOrDefault(asset => asset != null && asset.GetType().Name.Contains("BehaviorBlackboardAuthoringAsset", StringComparison.Ordinal));
|
||||
|
||||
if (blackboardAsset == null)
|
||||
{
|
||||
FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
if (field != null)
|
||||
return (T)field.GetValue(obj);
|
||||
type = type.BaseType;
|
||||
Debug.LogError($"[DrogBTRebuild] 블랙보드 에셋을 찾지 못했습니다: {variableName}");
|
||||
return null;
|
||||
}
|
||||
return defaultValue;
|
||||
|
||||
IList variables = GetBlackboardVariables(blackboardAsset);
|
||||
if (variables == null)
|
||||
{
|
||||
Debug.LogError($"[DrogBTRebuild] 블랙보드 변수 목록을 읽지 못했습니다: {variableName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < variables.Count; i++)
|
||||
{
|
||||
object variable = variables[i];
|
||||
if (variable == null || GetVariableName(variable) != variableName)
|
||||
continue;
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
Type typedVariableModelGeneric = ResolveTypedVariableModelGenericType(variables);
|
||||
if (typedVariableModelGeneric == null)
|
||||
{
|
||||
Debug.LogError($"[DrogBTRebuild] TypedVariableModel<> 타입을 찾지 못했습니다: {variableName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
Type typedVariableModelType = typedVariableModelGeneric.MakeGenericType(typeof(T));
|
||||
object variableModel = Activator.CreateInstance(typedVariableModelType);
|
||||
if (variableModel == null)
|
||||
{
|
||||
Debug.LogError($"[DrogBTRebuild] 블랙보드 변수 생성 실패: {variableName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
SetFieldOrPropertyValue(variableModel, "ID", CreateSerializableGuid(typedVariableModelType));
|
||||
SetFieldOrPropertyValue(variableModel, "Name", variableName);
|
||||
SetFieldOrPropertyValue(variableModel, "IsExposed", true);
|
||||
SetFieldOrPropertyValue(variableModel, "IsShared", false);
|
||||
SetFieldOrPropertyValue(variableModel, "m_Value", defaultValue);
|
||||
SetFieldOrPropertyValue(variableModel, "ObjectValue", defaultValue);
|
||||
|
||||
variables.Add(variableModel);
|
||||
EditorUtility.SetDirty(blackboardAsset);
|
||||
return variableModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 그래프에서 더 이상 쓰지 않는 블랙보드 변수를 제거합니다.
|
||||
/// </summary>
|
||||
private static void RemoveBlackboardVariables(params string[] variableNames)
|
||||
{
|
||||
if (variableNames == null || variableNames.Length == 0)
|
||||
return;
|
||||
|
||||
UnityEngine.Object blackboardAsset = AssetDatabase.LoadAllAssetsAtPath(GraphAssetPath)
|
||||
.FirstOrDefault(asset => asset != null && asset.GetType().Name.Contains("BehaviorBlackboardAuthoringAsset", StringComparison.Ordinal));
|
||||
|
||||
if (blackboardAsset == null)
|
||||
return;
|
||||
|
||||
IList variables = GetBlackboardVariables(blackboardAsset);
|
||||
if (variables == null)
|
||||
return;
|
||||
|
||||
HashSet<string> variableNameSet = new HashSet<string>(variableNames, StringComparer.Ordinal);
|
||||
for (int i = variables.Count - 1; i >= 0; i--)
|
||||
{
|
||||
object variable = variables[i];
|
||||
if (variable == null || !variableNameSet.Contains(GetVariableName(variable)))
|
||||
continue;
|
||||
|
||||
variables.RemoveAt(i);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(blackboardAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1024,22 +1296,21 @@ namespace Colosseum.Editor
|
||||
object condModel = AttachCondition(branchNode, typeof(CheckPatternReadyCondition), authoringAssembly);
|
||||
if (condModel == null)
|
||||
{
|
||||
Debug.LogError($"[DrogBTRebuild] CheckPatternReadyCondition 부착 실패: {pattern?.PatternName}");
|
||||
Debug.LogError("[DrogBTRebuild] CheckPatternReadyCondition 부착 실패");
|
||||
return;
|
||||
}
|
||||
|
||||
// ConditionModel의 실제 타입에서 SetField<T>를 조회하여 BossPatternData 참조 설정
|
||||
MethodInfo genericSetField = condModel.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
.FirstOrDefault(m => m.Name == "SetField" && m.IsGenericMethod && m.GetParameters().Length == 2);
|
||||
if (genericSetField != null)
|
||||
{
|
||||
MethodInfo closedMethod = genericSetField.MakeGenericMethod(typeof(BossPatternData));
|
||||
closedMethod.Invoke(condModel, new object[] { "Pattern", pattern });
|
||||
}
|
||||
else
|
||||
.FirstOrDefault(method => method.Name == "SetField" && method.IsGenericMethod && method.GetParameters().Length == 2);
|
||||
|
||||
if (genericSetField == null)
|
||||
{
|
||||
Debug.LogError("[DrogBTRebuild] CheckPatternReadyCondition에서 SetField<T>를 찾지 못했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
MethodInfo closedMethod = genericSetField.MakeGenericMethod(typeof(BossPatternData));
|
||||
closedMethod.Invoke(condModel, new object[] { "Pattern", pattern });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1053,5 +1324,6 @@ namespace Colosseum.Editor
|
||||
|
||||
AttachConditionWithValue(branchNode, typeof(IsMinPhaseSatisfiedCondition), "MinPhase", pattern.MinPhase, authoringAssembly);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user