65 lines
1.6 KiB
C#
65 lines
1.6 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年06月06日 星期五 19:06:16
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System;
|
|
using Logic.AI;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
|
|
|
|
namespace NodeCanvas.Tasks.Actions
|
|
{
|
|
[Category("AIAction")]
|
|
[Serializable]
|
|
public class AIParamTargetCityHaveUnit : BaseActionTask
|
|
{
|
|
public bool CheckHaveUnit = true;
|
|
|
|
|
|
protected override string desc
|
|
{
|
|
get
|
|
{
|
|
if (CheckHaveUnit) return string.Format($"目标城市上有单位");
|
|
return string.Format($"目标城市上没有单位");
|
|
}
|
|
}
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam.UnitData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var param = data.value.TargetParam;
|
|
var legion = param.UnitData.LegionId;
|
|
var targetCity = data.value.LegionTargetCity[legion];
|
|
if (targetCity == 0)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
if (param.MapData.GetGridDataByCityId(targetCity, out var gridData))
|
|
{
|
|
if (param.MapData.GetUnitDataByGid(gridData.Id, out var unitData))
|
|
{
|
|
EndAction(CheckHaveUnit);
|
|
return;
|
|
}
|
|
}
|
|
|
|
EndAction(!CheckHaveUnit);
|
|
}
|
|
}
|
|
} |