65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
/*
|
||
* @Author: 白哉
|
||
* @Description:
|
||
* @Date: 2025年06月06日 星期五 19:06:16
|
||
* @Modify:
|
||
*/
|
||
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics;
|
||
using Logic.Action;
|
||
using Logic.AI;
|
||
using Logic.CrashSight;
|
||
using NodeCanvas.Framework;
|
||
using ParadoxNotion.Design;
|
||
|
||
|
||
namespace NodeCanvas.Tasks.Actions
|
||
{
|
||
[Name("构建行为")]
|
||
[Category("AI节点")]
|
||
[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;
|
||
Stopwatch sw = new Stopwatch();
|
||
sw.Start();
|
||
foreach (var actionType in ActionTypes) AIActionGenerator.GeneratorActionIds(data.value, actionType);
|
||
sw.Stop();
|
||
if (sw.Elapsed.TotalMilliseconds > 50)
|
||
{
|
||
LogSystem.LogInfo($"duration out, duration:{sw.Elapsed.TotalMilliseconds} ms, NodeId: {NodeId} {ActionTypes[0]}");
|
||
}
|
||
if (data.value.AIActions.Count == 0)
|
||
{
|
||
EndAction(false);
|
||
return;
|
||
}
|
||
|
||
EndAction(true);
|
||
}
|
||
}
|
||
} |