51 lines
1.3 KiB
C#
51 lines
1.3 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
|
|
{
|
|
[Name("城市人数")]
|
|
[Category("AI节点")]
|
|
[Serializable]
|
|
public class AIParamCityUnitCountLimit : BaseActionTask
|
|
{
|
|
public bool IsGreater;
|
|
public int Count;
|
|
|
|
protected override string desc
|
|
{
|
|
get
|
|
{
|
|
if (IsGreater) return string.Format($" 城市人数大于 {Count}");
|
|
return string.Format($" 城市人数小于 {Count}");
|
|
}
|
|
}
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam.CityData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var city = data.value.TargetParam.CityData;
|
|
var count = data.value.TargetParam.MapData.GetUnitCount(city.Id);
|
|
if (IsGreater) EndAction(count > Count);
|
|
else EndAction(count < Count);
|
|
}
|
|
}
|
|
} |