61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年06月06日 星期五 19:06:16
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System;
|
|
using Logic.AI;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
using RuntimeData;
|
|
|
|
|
|
namespace NodeCanvas.Tasks.Actions
|
|
{
|
|
[Name("小兵在我方城市上")]
|
|
[Category("AI节点")]
|
|
[Serializable]
|
|
public class AIParanIsUnitInSelfCity : BaseActionTask
|
|
{
|
|
public bool Not = false;
|
|
|
|
|
|
protected override string desc
|
|
{
|
|
get
|
|
{
|
|
if (Not) 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 map = data.value.TargetParam.MapData;
|
|
var unit = data.value.TargetParam.UnitData;
|
|
var selfPlayer = unit?.Player(map);
|
|
var grid = unit?.Grid(map);
|
|
var city = grid?.City(map);
|
|
var player = city?.Player(map);
|
|
if (selfPlayer != null && player != null && selfPlayer.Id == player.Id)
|
|
{
|
|
EndAction(!Not);
|
|
return;
|
|
}
|
|
|
|
EndAction(false);
|
|
}
|
|
}
|
|
} |