65 lines
1.9 KiB
C#
65 lines
1.9 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
|
||
{
|
||
[Category("AIAction")]
|
||
[Serializable]
|
||
public class AICalculateAction : BaseActionTask
|
||
{
|
||
public List<CalculateType> CalculateTypes;
|
||
|
||
|
||
protected override string desc
|
||
{
|
||
get { return string.Format($"评分策略为 {CalculateTypes[0]}"); }
|
||
}
|
||
|
||
protected override void OnExecute()
|
||
{
|
||
base.OnExecute();
|
||
// 直接从Blackboard获取AICalculatorData
|
||
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
||
if (data?.value == null)
|
||
{
|
||
EndAction(false);
|
||
return;
|
||
}
|
||
|
||
Stopwatch sw = new Stopwatch();
|
||
sw.Start();
|
||
data.value.MaxAiAction = AIActionScoreCalculator.CalculateAIActionScore(data.value, CalculateTypes);
|
||
// 加一个解散的目标点定位
|
||
if (data.value.MaxAiAction != null && data.value.MaxAiAction?.ActionLogic?.ActionId?.UnitActionType == UnitActionType.Disband)
|
||
{
|
||
LogSystem.LogError($"UnitActionType Disband NodeId: {NodeId}, {CalculateTypes[0]}");
|
||
}
|
||
if (sw.Elapsed.TotalMilliseconds > 100)
|
||
{
|
||
LogSystem.LogError($"duration out, duration:{sw.Elapsed.TotalMilliseconds} ms, NodeId: {NodeId}, {CalculateTypes[0]}");
|
||
}
|
||
if (data.value.MaxAiAction == null)
|
||
{
|
||
EndAction(false);
|
||
return;
|
||
}
|
||
|
||
EndAction(true);
|
||
}
|
||
}
|
||
} |