- BT 재평가 중에도 패턴 실행 상태를 보존하도록 보스 패턴 액션과 런타임 상태를 조정했다. - 스킬 컨트롤러에서 동일 프레임 종료 판정을 막아 패턴 내 다음 스킬이 즉시 잘리는 문제를 수정했다. - 드로그 BT, 패턴/스킬 데이터, 애니메이션 클립과 컨트롤러를 현재 검증된 재생 구성으로 정리했다. - 자연 발동 기준으로 콤보-기본기2 재생 시간을 재검증해 클립 길이와 실제 재생 간격이 맞는 것을 확인했다.
85 lines
3.4 KiB
C#
85 lines
3.4 KiB
C#
using System;
|
|
|
|
using Unity.Behavior;
|
|
using Unity.Properties;
|
|
using UnityEngine;
|
|
|
|
using Colosseum.Enemy;
|
|
|
|
namespace Colosseum.AI.BehaviorActions.Actions
|
|
{
|
|
/// <summary>
|
|
/// 준비된 후보 패턴 중 하나를 가중치 기반으로 선택하고 즉시 실행합니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
[NodeDescription(
|
|
name: "Use Weighted Ready Pattern",
|
|
story: "준비된 후보 패턴 중 하나를 가중치 기반으로 선택해 실행",
|
|
category: "Action",
|
|
id: "6d4fc6fd-0ccd-4d9a-8b86-c602062f78a7")]
|
|
public partial class UseWeightedReadyPatternAction : BossPatternActionBase
|
|
{
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern1;
|
|
[SerializeReference] public BlackboardVariable<float> Weight1 = new BlackboardVariable<float>(1f);
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern2;
|
|
[SerializeReference] public BlackboardVariable<float> Weight2 = new BlackboardVariable<float>(1f);
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern3;
|
|
[SerializeReference] public BlackboardVariable<float> Weight3 = new BlackboardVariable<float>(1f);
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern4;
|
|
[SerializeReference] public BlackboardVariable<float> Weight4 = new BlackboardVariable<float>(1f);
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern5;
|
|
[SerializeReference] public BlackboardVariable<float> Weight5 = new BlackboardVariable<float>(1f);
|
|
|
|
private BossPatternData selectedPattern;
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
if (HasActivePatternExecutionState)
|
|
return base.OnStart();
|
|
|
|
if (!TrySelectPattern(out selectedPattern))
|
|
return Status.Failure;
|
|
|
|
BossBehaviorRuntimeState context = GameObject.GetComponent<BossBehaviorRuntimeState>();
|
|
context?.LogDebug(nameof(UseWeightedReadyPatternAction), $"가중치 패턴 선택 후 실행: {selectedPattern.PatternName}");
|
|
return base.OnStart();
|
|
}
|
|
|
|
protected override void OnEnd()
|
|
{
|
|
if (!HasActivePatternExecutionState)
|
|
selectedPattern = null;
|
|
|
|
base.OnEnd();
|
|
}
|
|
|
|
protected override bool TryResolvePattern(out BossPatternData pattern, out GameObject target)
|
|
{
|
|
target = Target != null ? Target.Value : null;
|
|
pattern = selectedPattern;
|
|
|
|
if (pattern == null && !TrySelectPattern(out pattern))
|
|
return false;
|
|
|
|
if (target == null)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
private bool TrySelectPattern(out BossPatternData pattern)
|
|
{
|
|
WeightedPatternCandidate[] candidates =
|
|
{
|
|
new WeightedPatternCandidate(Pattern1?.Value, Weight1?.Value ?? 0f),
|
|
new WeightedPatternCandidate(Pattern2?.Value, Weight2?.Value ?? 0f),
|
|
new WeightedPatternCandidate(Pattern3?.Value, Weight3?.Value ?? 0f),
|
|
new WeightedPatternCandidate(Pattern4?.Value, Weight4?.Value ?? 0f),
|
|
new WeightedPatternCandidate(Pattern5?.Value, Weight5?.Value ?? 0f),
|
|
};
|
|
|
|
return WeightedPatternSelector.TrySelectReadyPattern(GameObject, candidates, out pattern);
|
|
}
|
|
}
|
|
}
|