62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年10月21日 星期二 17:10:56
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System;
|
|
using Logic.AI;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
|
|
|
|
namespace NodeCanvas.Tasks.Actions
|
|
{
|
|
[Name("筛选目标兵血量缺口")]
|
|
[Category("AI节点")]
|
|
[Serializable]
|
|
public class AIParamIsTargetUnitHealthGap : BaseActionTask
|
|
{
|
|
public bool GreaterThan = true;
|
|
public float Value = 0;
|
|
|
|
|
|
protected override string desc
|
|
{
|
|
get
|
|
{
|
|
if (GreaterThan) return string.Format($"目标血量缺口大于等于 {Value}");
|
|
return string.Format($"目标血量缺口小于等于 {Value}");
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam?.TargetUnitData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
for (int i = data.value.AIActions.Count - 1; i >= 0; i--)
|
|
{
|
|
var targetUnit = data.value.AIActions[i].Param.TargetUnitData;
|
|
if (targetUnit != null)
|
|
{
|
|
var offset = targetUnit.GetMaxHealth() - targetUnit.Health;
|
|
if (GreaterThan && offset >= Value) continue;
|
|
if (!GreaterThan && offset <= Value) continue;
|
|
}
|
|
data.value.AIActions.RemoveAt(i);
|
|
}
|
|
|
|
EndAction(data.value.AIActions.Count > 0);
|
|
}
|
|
}
|
|
} |