54 lines
1.5 KiB
C#
54 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;
|
|
|
|
|
|
namespace NodeCanvas.Tasks.Actions
|
|
{
|
|
[Name("判断自身处于村庄或者敌方城市")]
|
|
[Category("AI节点")]
|
|
[Serializable]
|
|
public class AIParamGridCollect : BaseActionTask
|
|
{
|
|
protected override string desc => "判断自身处于村庄或者敌方城市";
|
|
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam.UnitData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var unit = data.value.TargetParam.UnitData;
|
|
var map = data.value.TargetParam.MapData;
|
|
var selfPlayerId = data.value.TargetParam.PlayerData.Id;
|
|
var grid = unit.Grid(map);
|
|
if (grid != null && grid.Resource == ResourceType.CityCenter)
|
|
{
|
|
var city = grid.CityOnGrid(map);
|
|
var cityPlayer = city?.Player(map);
|
|
if (city == null || (cityPlayer != null && cityPlayer.Id != selfPlayerId))
|
|
{
|
|
EndAction(true);
|
|
return;
|
|
}
|
|
}
|
|
|
|
EndAction(false);
|
|
}
|
|
}
|
|
} |