TH1/Unity/Assets/Scripts/BTNodeCanvas/AIGeneratorAction.cs

55 lines
1.3 KiB
C#

/*
* @Author: 白哉
* @Description:
* @Date: 2025年06月06日 星期五 19:06:16
* @Modify:
*/
using System;
using System.Collections.Generic;
using Logic.Action;
using Logic.AI;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Actions
{
[Category("AIAction")]
[Serializable]
public class AIGeneratorAction : BaseActionTask
{
public List<CommonActionType> ActionTypes;
protected override string desc
{
get { return string.Format($"构建 {ActionTypes[0]} 行为"); }
}
protected override void OnExecute()
{
base.OnExecute();
// 直接从Blackboard获取AICalculatorData
var data = blackboard.GetVariable<AICalculatorData>("Data");
if (data?.value == null)
{
EndAction(false);
return;
}
data.value.AIActions.Clear();
data.value.MaxAiAction = null;
foreach (var actionType in ActionTypes)AIActionGenerator.GeneratorActionIds(data.value, actionType);
if (data.value.AIActions.Count == 0)
{
EndAction(false);
return;
}
EndAction(true);
}
}
}