using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Colosseum.AI;
using Colosseum.AI.BehaviorActions.Actions;
using Colosseum.AI.BehaviorActions.Conditions;
using Colosseum.Abnormalities;
using Colosseum.Enemy;
using Colosseum.Skills;
using UnityEditor;
using UnityEngine;
namespace Colosseum.Editor
{
///
/// 드로그 Behavior Graph authoring 자산을 현재 BT 우선순위 구조로 재생성합니다.
/// Check 노드는 ConditionalGuardAction + Condition 조합으로 구현됩니다.
///
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 DefaultGroundShakePatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_땅 울리기.asset";
private const string DefaultMobilityPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_도약.asset";
private const string DefaultPrimaryPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_콤보-기본기1.asset";
private const string DefaultSecondaryPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_콤보-기본기2.asset";
private const string DefaultTertiaryPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_콤보-기본기3.asset";
private const string DefaultComboPatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_콤보-강타.asset";
private const string DefaultPressurePatternPath = "Assets/_Game/Data/Patterns/Data_Pattern_Drog_콤보-발구르기.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 string DefaultSignatureFailureAbnormalityPath = "Assets/_Game/Data/Abnormalities/Data_Abnormality_Player_집행자의낙인.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 DefaultSignatureRepeatInterval = 90f;
private const float DefaultGroundShakeInterval = 12f;
private const float DefaultPhase2EnterHealthPercent = 75f;
private const float DefaultPhase3EnterHealthPercent = 40f;
private const int DefaultBasicLoopRequirementBeforeBigPattern = 2;
private const float DefaultComboPatternWeight = 26f;
private const float DefaultPressurePatternWeight = 24f;
private const float DefaultPrimaryPatternWeight = 22f;
private const float DefaultSecondaryPatternWeight = 16f;
private const float DefaultTertiaryPatternWeight = 12f;
private const float DefaultSignatureFailureDamage = 40f;
private const float DefaultSignatureFailureKnockbackRadius = 8f;
private const float DefaultSignatureFailureDownRadius = 3f;
private const float DefaultSignatureFailureKnockbackSpeed = 12f;
private const float DefaultSignatureFailureKnockbackDuration = 0.35f;
private const float DefaultSignatureFailureDownDuration = 2f;
[MenuItem("Tools/Colosseum/Rebuild Drog Behavior Authoring Graph")]
private static void Rebuild()
{
UnityEngine.Object graphAsset = AssetDatabase.LoadMainAssetAtPath(GraphAssetPath);
if (graphAsset == null)
{
// 에셋이 없으면 기존 에셋 경로의 타입을 리플렉션으로 찾아 생성합니다.
// BehaviorAuthoringGraph는 Unity.Behavior.Editor 어셈블리에 있습니다.
Type authoringGraphType = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
authoringGraphType = assembly.GetType("Unity.Behavior.Authoring.BehaviorAuthoringGraph");
if (authoringGraphType != null)
break;
}
if (authoringGraphType == null)
{
Debug.LogError("[DrogBTRebuild] BehaviorAuthoringGraph 타입을 모든 어셈블리에서 찾지 못했습니다.");
return;
}
graphAsset = ScriptableObject.CreateInstance(authoringGraphType);
if (graphAsset == null)
{
Debug.LogError("[DrogBTRebuild] BehaviorAuthoringGraph 인스턴스를 생성할 수 없습니다.");
return;
}
AssetDatabase.CreateAsset(graphAsset, GraphAssetPath);
AssetDatabase.SaveAssets();
Debug.Log("[DrogBTRebuild] 새 그래프 자산을 생성했습니다.");
}
try
{
Type authoringGraphType = graphAsset.GetType();
Assembly authoringAssembly = authoringGraphType.Assembly;
Assembly runtimeAssembly = typeof(Unity.Behavior.BehaviorGraph).Assembly;
// 기본 리플렉션 메서드
MethodInfo createNodeMethod = authoringGraphType.BaseType?.GetMethod("CreateNode", BindingFlags.Instance | BindingFlags.Public);
MethodInfo connectEdgeMethod = authoringGraphType.BaseType?.GetMethod("ConnectEdge", BindingFlags.Instance | BindingFlags.Public);
MethodInfo createNodePortsMethod = authoringGraphType.BaseType?.GetMethod("CreateNodePortsForNode", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
MethodInfo buildRuntimeGraphMethod = authoringGraphType.GetMethod("BuildRuntimeGraph", BindingFlags.Instance | BindingFlags.Public);
MethodInfo saveAssetMethod = authoringGraphType.BaseType?.GetMethod("SaveAsset", BindingFlags.Instance | BindingFlags.Public);
MethodInfo setAssetDirtyMethod = authoringGraphType.BaseType?.GetMethod("SetAssetDirty", BindingFlags.Instance | BindingFlags.Public);
MethodInfo getNodeInfoMethod = authoringAssembly.GetType("Unity.Behavior.NodeRegistry", true)
?.GetMethod("GetInfo", BindingFlags.Static | BindingFlags.NonPublic);
if (createNodeMethod == null || connectEdgeMethod == null || buildRuntimeGraphMethod == null || saveAssetMethod == null || setAssetDirtyMethod == null || getNodeInfoMethod == null)
{
Debug.LogError("[DrogBTRebuild] Behavior Authoring 리플렉션 메서드를 찾지 못했습니다.");
return;
}
// ConditionalGuard 리플렉션 타입 (internal)
Type conditionalGuardType = runtimeAssembly.GetType("Unity.Behavior.ConditionalGuardAction");
Type conditionUtilityType = authoringAssembly.GetType("Unity.Behavior.ConditionUtility");
Type conditionModelType = authoringAssembly.GetType("Unity.Behavior.ConditionModel");
Type graphNodeModelType = authoringAssembly.GetType("Unity.Behavior.BehaviorGraphNodeModel");
Type conditionInfoType = authoringAssembly.GetType("Unity.Behavior.ConditionInfo");
if (conditionalGuardType == null) { Debug.LogError("[DrogBTRebuild] ConditionalGuardAction 타입을 찾지 못했습니다."); return; }
if (conditionUtilityType == null) { Debug.LogError("[DrogBTRebuild] ConditionUtility 타입을 찾지 못했습니다."); return; }
if (conditionModelType == null) { Debug.LogError("[DrogBTRebuild] ConditionModel 타입을 찾지 못했습니다."); return; }
if (graphNodeModelType == null) { Debug.LogError("[DrogBTRebuild] BehaviorGraphNodeModel 타입을 찾지 못했습니다."); return; }
if (conditionInfoType == null)
{
Debug.LogError("[DrogBTRebuild] ConditionInfo 타입을 찾지 못했습니다.");
return;
}
Type branchCompositeType = runtimeAssembly.GetType("Unity.Behavior.BranchingConditionComposite");
if (branchCompositeType == null)
{
Debug.LogError("[DrogBTRebuild] BranchingConditionComposite 타입을 찾지 못했습니다.");
return;
}
// SetField(string, VariableModel, Type) — 제네릭 버전과 구분하기 위해 파라미터 수로 필터링
MethodInfo setFieldMethod = conditionModelType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
.FirstOrDefault(m => m.Name == "SetField" && !m.IsGenericMethod && m.GetParameters().Length == 3);
// SetField(string, T) — BehaviorGraphNodeModel 기반 클래스에서 조회 (ConditionModel과 Action 노드 모두 사용)
MethodInfo setFieldValueMethod = graphNodeModelType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
.FirstOrDefault(m => m.Name == "SetField" && m.IsGenericMethod && m.GetParameters().Length == 2);
if (setFieldMethod == null)
{
Debug.LogError("[DrogBTRebuild] ConditionModel.SetField 메서드를 찾지 못했습니다.");
return;
}
if (setFieldValueMethod == null)
{
Debug.LogError("[DrogBTRebuild] SetField 제네릭 메서드를 찾지 못했습니다.");
return;
}
// 기존 에셋의 서브에셋(BehaviorGraph 등)에서 깨진 managed references 클리어
Type behaviorGraphType = typeof(Unity.Behavior.BehaviorGraph);
UnityEngine.Object[] subAssets = AssetDatabase.LoadAllAssetsAtPath(GraphAssetPath);
foreach (var subAsset in subAssets)
{
if (subAsset != null && subAsset.GetType() == behaviorGraphType)
{
UnityEditor.SerializationUtility.ClearAllManagedReferencesWithMissingTypes(subAsset);
EditorUtility.SetDirty(subAsset);
}
}
// AuthoringGraph 자체에서도 깨진 references 클리어
UnityEditor.SerializationUtility.ClearAllManagedReferencesWithMissingTypes(graphAsset);
// 노드 클리어 — 전체 타입 계층에서 필드 찾기
FieldInfo nodesField = FindFieldInHierarchy(authoringGraphType, "m_RootNodes");
if (nodesField == null)
{
Debug.LogError("[DrogBTRebuild] m_RootNodes 필드를 타입 계층 전체에서 찾지 못했습니다.");
return;
}
nodesField.SetValue(graphAsset, Activator.CreateInstance(nodesField.FieldType));
FieldInfo nodesListField = FindFieldInHierarchy(authoringGraphType, "m_Nodes");
if (nodesListField != null)
nodesListField.SetValue(graphAsset, Activator.CreateInstance(nodesListField.FieldType));
FieldInfo nodeModelsInfoField = FindFieldInHierarchy(authoringGraphType, "m_NodeModelsInfo");
if (nodeModelsInfoField != null)
nodeModelsInfoField.SetValue(graphAsset, Activator.CreateInstance(nodeModelsInfoField.FieldType));
FieldInfo runtimeGraphField = FindFieldInHierarchy(authoringGraphType, "m_RuntimeGraph");
if (runtimeGraphField != null)
runtimeGraphField.SetValue(graphAsset, null);
// 클리어 후 에셋을 저장하고 다시 로드하여 잔류 참조가 메모리에 남지 않게 합니다.
EditorUtility.SetDirty(graphAsset);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
// 에셋을 다시 로드 (직렬화된 상태에서 로드하여 클리어 상태 확보)
graphAsset = AssetDatabase.LoadMainAssetAtPath(GraphAssetPath);
if (graphAsset == null)
{
Debug.LogError("[DrogBTRebuild] 에셋 재로드 실패.");
return;
}
authoringGraphType = graphAsset.GetType();
object targetVariable = EnsureBlackboardVariable("Target", null);
if (targetVariable == null)
{
Debug.LogError("[DrogBTRebuild] Target 블랙보드 변수를 찾지 못했습니다.");
return;
}
// 구조 노드
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));
// ── 드로그 패턴과 판단 수치는 노드 로컬 값으로 두고, Target만 블랙보드로 공유합니다. ──
RemoveBlackboardVariables(
"PunishPattern",
"SignaturePattern",
"MobilityPattern",
"ComboPattern",
"PrimaryPattern",
"UtilityPattern",
"PunishSearchRadius",
"MobilityTriggerDistance",
"UtilityTriggerDistance",
"PrimaryAttackRange",
"SelectedMeleePattern",
"Phase2HealthPercent",
"Phase3HealthPercent",
"SightRange",
"AttackRange",
"MoveSpeed");
BossPatternData punishPattern = LoadRequiredAsset(DefaultPunishPatternPath, "밟기 패턴");
BossPatternData signaturePattern = LoadRequiredAsset(DefaultSignaturePatternPath, "집행 패턴");
BossPatternData groundShakePattern = LoadRequiredAsset(DefaultGroundShakePatternPath, "땅 울리기 패턴");
BossPatternData mobilityPattern = LoadRequiredAsset(DefaultMobilityPatternPath, "도약 패턴");
BossPatternData primaryPattern = LoadRequiredAsset(DefaultPrimaryPatternPath, "콤보-기본기1 패턴");
BossPatternData secondaryPattern = LoadRequiredAsset(DefaultSecondaryPatternPath, "콤보-기본기2 패턴");
BossPatternData tertiaryPattern = LoadRequiredAsset(DefaultTertiaryPatternPath, "콤보-기본기3 패턴");
BossPatternData comboPattern = LoadRequiredAsset(DefaultComboPatternPath, "콤보-강타 패턴");
BossPatternData pressurePattern = LoadRequiredAsset(DefaultPressurePatternPath, "콤보-발구르기 패턴");
BossPatternData utilityPattern = LoadRequiredAsset(DefaultUtilityPatternPath, "투척 패턴");
SkillData phase3TransitionSkill = LoadRequiredAsset(DefaultPhase3TransitionSkillPath, "포효 스킬");
AbnormalityData signatureFailureAbnormality = LoadRequiredAsset(DefaultSignatureFailureAbnormalityPath, "집행 실패 디버프");
if (punishPattern == null
|| signaturePattern == null
|| groundShakePattern == null
|| mobilityPattern == null
|| primaryPattern == null
|| secondaryPattern == null
|| tertiaryPattern == null
|| comboPattern == null
|| pressurePattern == null
|| utilityPattern == null
|| phase3TransitionSkill == null)
{
Debug.LogError("[DrogBTRebuild] 드로그 BT 재구성에 필요한 패턴/스킬 에셋을 읽지 못했습니다.");
return;
}
const float branchX = -900f;
const float rootRefreshX = branchX - 500f;
const float sequenceX = branchX + 360f;
const float actionX1 = sequenceX + 360f;
const float actionX2 = actionX1 + 320f;
const float actionX3 = actionX2 + 320f;
const float actionX4 = actionX3 + 320f;
const float actionX5 = actionX4 + 320f;
const float actionX6 = actionX5 + 320f;
const float truePortOffsetX = 203f;
const float truePortOffsetY = 120f;
const float falsePortOffsetX = -211f;
const float falsePortOffsetY = 124f;
const float startY = -1320f;
const float stepY = 360f;
object phase2TransitionBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY));
AttachConditionWithValue(phase2TransitionBranch, typeof(IsCurrentPhaseCondition), "Phase", 1, authoringAssembly);
AttachConditionWithValue(phase2TransitionBranch, typeof(IsHealthBelowCondition), "HealthPercent", DefaultPhase2EnterHealthPercent, authoringAssembly);
SetBranchRequiresAll(phase2TransitionBranch, true);
object phase2TransitionSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY));
object phase2TransitionWaitNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(WaitAction), new Vector2(actionX1, startY));
SetNodeFieldValue(phase2TransitionWaitNode, "Duration", DefaultPhaseTransitionLockDuration, setFieldValueMethod);
object phase2SetPhaseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(actionX2, startY));
SetNodeFieldValue(phase2SetPhaseNode, "TargetPhase", 2, setFieldValueMethod);
SetNodeFieldValue(phase2SetPhaseNode, "ResetTimer", true, setFieldValueMethod);
ConnectChildren(graphAsset, connectEdgeMethod, phase2TransitionSequence, phase2TransitionWaitNode, phase2SetPhaseNode);
object phase3TransitionBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY));
AttachConditionWithValue(phase3TransitionBranch, typeof(IsCurrentPhaseCondition), "Phase", 2, authoringAssembly);
AttachConditionWithValue(phase3TransitionBranch, typeof(IsHealthBelowCondition), "HealthPercent", DefaultPhase3EnterHealthPercent, authoringAssembly);
SetBranchRequiresAll(phase3TransitionBranch, true);
object phase3TransitionSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY));
object phase3RoarNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UseSkillAction), new Vector2(actionX1, startY + stepY));
SetNodeFieldValue(phase3RoarNode, "스킬", phase3TransitionSkill, setFieldValueMethod);
object phase3TransitionWaitNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(WaitAction), new Vector2(actionX2, startY + stepY));
SetNodeFieldValue(phase3TransitionWaitNode, "Duration", DefaultPhaseTransitionLockDuration, setFieldValueMethod);
object phase3SetPhaseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(actionX3, startY + stepY));
SetNodeFieldValue(phase3SetPhaseNode, "TargetPhase", 3, setFieldValueMethod);
SetNodeFieldValue(phase3SetPhaseNode, "ResetTimer", true, setFieldValueMethod);
object phase3RefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(actionX4, startY + stepY));
SetNodeFieldValue(phase3RefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
object phase3ValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(actionX5, startY + stepY));
object phase3SignatureResetLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ResetBasicLoopCountAction), new Vector2(actionX6 - 200f, startY + stepY));
object phase3UseSignatureNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX6, startY + stepY));
SetNodeFieldValue(phase3UseSignatureNode, "Pattern", signaturePattern, setFieldValueMethod);
SetNodeFieldValue(phase3UseSignatureNode, "ContinueOnResolvedFailure", true, setFieldValueMethod);
object phase3SignatureResultBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(actionX6 + 420f, startY + stepY));
AttachConditionWithValue(phase3SignatureResultBranch, typeof(IsPatternExecutionResultCondition), "Result", BossPatternExecutionResult.Failed, authoringAssembly);
SetBranchRequiresAll(phase3SignatureResultBranch, true);
object phase3SignatureStaggerNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(BossStaggerAction), new Vector2(actionX6 + 820f, startY + stepY - 120f));
object phase3SignatureFailureNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SignatureFailureEffectsAction), new Vector2(actionX6 + 820f, startY + stepY + 120f));
ConfigureSignatureFailureNode(phase3SignatureFailureNode, signatureFailureAbnormality, setFieldValueMethod);
object phase3SignatureTimerResetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(actionX6 + 1220f, startY + stepY));
SetNodeFieldValue(phase3SignatureTimerResetNode, "TargetPhase", 3, setFieldValueMethod);
SetNodeFieldValue(phase3SignatureTimerResetNode, "ResetTimer", true, setFieldValueMethod);
ConnectChildren(
graphAsset,
connectEdgeMethod,
phase3TransitionSequence,
phase3RoarNode,
phase3TransitionWaitNode,
phase3SetPhaseNode,
phase3RefreshNode,
phase3ValidateNode,
phase3SignatureResetLoopNode,
phase3UseSignatureNode,
phase3SignatureResultBranch,
phase3SignatureTimerResetNode);
object rootRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(rootRefreshX, startY + stepY * 2f - 120f));
SetNodeFieldValue(rootRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
object punishBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 2f));
AttachPatternReadyCondition(punishBranch, punishPattern, authoringAssembly);
AttachConditionWithValue(punishBranch, typeof(IsDownedTargetInRangeCondition), "SearchRadius", DefaultDownedTargetSearchRadius, authoringAssembly);
SetBranchRequiresAll(punishBranch, true);
object punishSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 2f));
object punishSelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectNearestDownedTargetAction), new Vector2(actionX1, startY + stepY * 2f));
SetNodeFieldValue(punishSelectNode, "SearchRadius", DefaultDownedTargetSearchRadius, setFieldValueMethod);
object punishUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX2, startY + stepY * 2f));
SetNodeFieldValue(punishUseNode, "Pattern", punishPattern, setFieldValueMethod);
object punishResetLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ResetBasicLoopCountAction), new Vector2(actionX3, startY + stepY * 2f));
ConnectChildren(graphAsset, connectEdgeMethod, punishSequence, punishSelectNode, punishUseNode, punishResetLoopNode);
object signatureBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 3f));
AttachConditionWithValue(signatureBranch, typeof(IsCurrentPhaseCondition), "Phase", 3, authoringAssembly);
AttachConditionWithValue(signatureBranch, typeof(IsPhaseElapsedTimeAboveCondition), "Seconds", DefaultSignatureRepeatInterval, authoringAssembly);
AttachPatternReadyCondition(signatureBranch, signaturePattern, authoringAssembly);
AttachConditionWithValue(signatureBranch, typeof(IsBasicLoopCountAtLeastCondition), "Count", DefaultBasicLoopRequirementBeforeBigPattern, authoringAssembly);
SetBranchRequiresAll(signatureBranch, true);
object signatureSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 3f));
object signatureRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(actionX1, startY + stepY * 3f));
SetNodeFieldValue(signatureRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
object signatureValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(actionX2, startY + stepY * 3f));
object signatureUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX3, startY + stepY * 3f));
SetNodeFieldValue(signatureUseNode, "Pattern", signaturePattern, setFieldValueMethod);
SetNodeFieldValue(signatureUseNode, "ContinueOnResolvedFailure", true, setFieldValueMethod);
object signatureResetLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ResetBasicLoopCountAction), new Vector2(actionX3 + 220f, startY + stepY * 3f));
object signatureResultBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(actionX4, startY + stepY * 3f));
AttachConditionWithValue(signatureResultBranch, typeof(IsPatternExecutionResultCondition), "Result", BossPatternExecutionResult.Failed, authoringAssembly);
SetBranchRequiresAll(signatureResultBranch, true);
object signatureStaggerNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(BossStaggerAction), new Vector2(actionX4 + 420f, startY + stepY * 3f - 120f));
object signatureFailureNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SignatureFailureEffectsAction), new Vector2(actionX4 + 420f, startY + stepY * 3f + 120f));
ConfigureSignatureFailureNode(signatureFailureNode, signatureFailureAbnormality, setFieldValueMethod);
object signatureTimerResetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(actionX5, startY + stepY * 3f));
SetNodeFieldValue(signatureTimerResetNode, "TargetPhase", 3, setFieldValueMethod);
SetNodeFieldValue(signatureTimerResetNode, "ResetTimer", true, setFieldValueMethod);
ConnectChildren(
graphAsset,
connectEdgeMethod,
signatureSequence,
signatureRefreshNode,
signatureValidateNode,
signatureUseNode,
signatureResetLoopNode,
signatureResultBranch,
signatureTimerResetNode);
object throwBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 4f));
AttachPatternReadyCondition(throwBranch, utilityPattern, authoringAssembly);
AttachConditionWithValue(throwBranch, typeof(IsRecentReviveTriggerCondition), "MaxAge", DefaultThrowAvailabilityDelay, authoringAssembly);
SetBranchRequiresAll(throwBranch, true);
object throwSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 4f));
object throwSelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectRecentReviveTargetAction), new Vector2(actionX1, startY + stepY * 4f));
SetNodeFieldValue(throwSelectNode, "MaxAge", DefaultThrowAvailabilityDelay, setFieldValueMethod);
SetNodeFieldValue(throwSelectNode, "PreferCaster", true, setFieldValueMethod);
SetNodeFieldValue(throwSelectNode, "FallbackToRevivedTarget", true, setFieldValueMethod);
object throwUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX2, startY + stepY * 4f));
SetNodeFieldValue(throwUseNode, "Pattern", utilityPattern, setFieldValueMethod);
ConnectChildren(graphAsset, connectEdgeMethod, throwSequence, throwSelectNode, throwUseNode);
object leapBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 5f));
AttachPatternReadyCondition(leapBranch, mobilityPattern, authoringAssembly);
AttachConditionWithValue(leapBranch, typeof(IsTargetBeyondDistanceCondition), "MinDistance", DefaultLeapTargetMinDistance, authoringAssembly);
AttachConditionWithValue(leapBranch, typeof(IsBasicLoopCountAtLeastCondition), "Count", DefaultBasicLoopRequirementBeforeBigPattern, authoringAssembly);
SetBranchRequiresAll(leapBranch, true);
object leapSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 5f));
object leapSelectNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SelectTargetByDistanceAction), new Vector2(actionX1, startY + stepY * 5f));
SetNodeFieldValue(leapSelectNode, "MinRange", DefaultLeapTargetMinDistance, setFieldValueMethod);
SetNodeFieldValue(leapSelectNode, "MaxRange", DefaultTargetSearchRange, setFieldValueMethod);
SetNodeFieldValue(leapSelectNode, "SelectionMode", DistanceTargetSelectionMode.Farthest, setFieldValueMethod);
object leapValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(actionX2, startY + stepY * 5f));
object leapUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX3, startY + stepY * 5f));
SetNodeFieldValue(leapUseNode, "Pattern", mobilityPattern, setFieldValueMethod);
object leapResetLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ResetBasicLoopCountAction), new Vector2(actionX4, startY + stepY * 5f));
ConnectChildren(graphAsset, connectEdgeMethod, leapSequence, leapSelectNode, leapValidateNode, leapUseNode, leapResetLoopNode);
object groundShakeBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 6f));
AttachConditionWithValue(groundShakeBranch, typeof(IsCurrentPhaseCondition), "Phase", 2, authoringAssembly);
AttachConditionWithValue(groundShakeBranch, typeof(IsPhaseElapsedTimeAboveCondition), "Seconds", DefaultGroundShakeInterval, authoringAssembly);
AttachPatternReadyCondition(groundShakeBranch, groundShakePattern, authoringAssembly);
AttachConditionWithValue(groundShakeBranch, typeof(IsBasicLoopCountAtLeastCondition), "Count", DefaultBasicLoopRequirementBeforeBigPattern, authoringAssembly);
SetBranchRequiresAll(groundShakeBranch, true);
object groundShakeSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 6f));
object groundShakeRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(actionX1, startY + stepY * 6f));
SetNodeFieldValue(groundShakeRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
object groundShakeValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(actionX2, startY + stepY * 6f));
object groundShakeUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UsePatternByRoleAction), new Vector2(actionX3, startY + stepY * 6f));
SetNodeFieldValue(groundShakeUseNode, "Pattern", groundShakePattern, setFieldValueMethod);
object groundShakeResetLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ResetBasicLoopCountAction), new Vector2(actionX4 - 180f, startY + stepY * 6f));
object groundShakeTimerResetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(SetBossPhaseAction), new Vector2(actionX4, startY + stepY * 6f));
SetNodeFieldValue(groundShakeTimerResetNode, "TargetPhase", 2, setFieldValueMethod);
SetNodeFieldValue(groundShakeTimerResetNode, "ResetTimer", true, setFieldValueMethod);
ConnectChildren(graphAsset, connectEdgeMethod, groundShakeSequence, groundShakeRefreshNode, groundShakeValidateNode, groundShakeUseNode, groundShakeResetLoopNode, groundShakeTimerResetNode);
object meleeBranch = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, branchCompositeType, new Vector2(branchX, startY + stepY * 7f));
object meleeRangeCondModel = AttachCondition(meleeBranch, typeof(IsTargetInAttackRangeCondition), authoringAssembly);
if (meleeRangeCondModel != null)
setFieldMethod.Invoke(meleeRangeCondModel, new object[] { "Target", targetVariable, typeof(GameObject) });
if (meleeRangeCondModel != null)
SetConditionFieldValue(meleeRangeCondModel, "AttackRange", DefaultPrimaryBranchAttackRange);
object meleeReadyCondModel = AttachCondition(meleeBranch, typeof(HasAnyReadyPatternCondition), authoringAssembly);
SetWeightedPatternFields(meleeReadyCondModel, setFieldMethod, comboPattern, DefaultComboPatternWeight, pressurePattern, DefaultPressurePatternWeight, primaryPattern, DefaultPrimaryPatternWeight, secondaryPattern, DefaultSecondaryPatternWeight, tertiaryPattern, DefaultTertiaryPatternWeight);
SetBranchRequiresAll(meleeBranch, true);
object meleeSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(sequenceX, startY + stepY * 7f));
object meleeValidateNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(actionX1, startY + stepY * 7f));
object meleeUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(UseWeightedReadyPatternAction), new Vector2(actionX2, startY + stepY * 7f));
SetWeightedPatternFields(meleeUseNode, setFieldValueMethod, comboPattern, DefaultComboPatternWeight, pressurePattern, DefaultPressurePatternWeight, primaryPattern, DefaultPrimaryPatternWeight, secondaryPattern, DefaultSecondaryPatternWeight, tertiaryPattern, DefaultTertiaryPatternWeight);
object meleeIncrementLoopNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(IncrementBasicLoopCountAction), new Vector2(actionX3, startY + stepY * 7f));
SetNodeFieldValue(meleeIncrementLoopNode, "Count", 1, setFieldValueMethod);
ConnectChildren(graphAsset, connectEdgeMethod, meleeSequence, meleeValidateNode, meleeUseNode, meleeIncrementLoopNode);
object chaseSequence = CreateNode(
graphAsset,
createNodeMethod,
getNodeInfoMethod,
runtimeAssembly.GetType("Unity.Behavior.SequenceComposite", true),
new Vector2(branchX, startY + stepY * 11.5f));
object chaseRefreshNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(RefreshPrimaryTargetAction), new Vector2(branchX + 160f, startY + stepY * 11.5f + 80f));
SetNodeFieldValue(chaseRefreshNode, "SearchRange", DefaultTargetSearchRange, setFieldValueMethod);
object chaseHasTargetNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ValidateTargetAction), new Vector2(branchX + 480f, startY + stepY * 11.5f + 80f));
object chaseUseNode = CreateNode(graphAsset, createNodeMethod, getNodeInfoMethod, typeof(ChaseTargetAction), new Vector2(branchX + 800f, startY + stepY * 11.5f + 80f));
SetNodeFieldValue(chaseUseNode, "StopDistance", DefaultPrimaryBranchAttackRange, setFieldValueMethod);
LinkTarget(rootRefreshNode, targetVariable);
LinkTarget(phase3RefreshNode, targetVariable);
LinkTarget(phase3ValidateNode, targetVariable);
LinkTarget(phase3UseSignatureNode, targetVariable);
LinkTarget(punishSelectNode, targetVariable);
LinkTarget(punishUseNode, targetVariable);
LinkTarget(signatureRefreshNode, targetVariable);
LinkTarget(signatureValidateNode, targetVariable);
LinkTarget(signatureUseNode, targetVariable);
LinkTarget(throwSelectNode, targetVariable);
LinkTarget(throwUseNode, targetVariable);
LinkTarget(leapSelectNode, targetVariable);
LinkTarget(leapValidateNode, targetVariable);
LinkTarget(leapUseNode, targetVariable);
LinkTarget(groundShakeRefreshNode, targetVariable);
LinkTarget(groundShakeValidateNode, targetVariable);
LinkTarget(groundShakeUseNode, targetVariable);
LinkTarget(meleeValidateNode, targetVariable);
LinkTarget(meleeUseNode, targetVariable);
LinkTarget(chaseRefreshNode, targetVariable);
LinkTarget(chaseHasTargetNode, targetVariable);
LinkTarget(chaseUseNode, targetVariable);
Connect(graphAsset, connectEdgeMethod, GetDefaultOutputPort(rootRefreshNode), GetDefaultInputPort(punishBranch));
var allBranches = new List