69 lines
2.0 KiB
C#
69 lines
2.0 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 AIParamBuildEmbassy : BaseActionTask
|
|
{
|
|
public float Value;
|
|
public int Money;
|
|
|
|
protected override string desc => string.Format($"余额 >= {Money}, 并且对某国好感 >= {Value}, 筛选最高分");
|
|
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
if (data.value.Player.PlayerWealth < Money)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
float maxValue = 0f;
|
|
AIActionBase action = null;
|
|
for (int i = data.value.AIActions.Count - 1; i >= 0; i--)
|
|
{
|
|
var self = data.value.AIActions[i].Param.PlayerData;
|
|
var target = data.value.AIActions[i].Param.TargetPlayerData;
|
|
self.GetCountryDiplomacyInfo(target.Id, out var selfToTarget);
|
|
if (selfToTarget.FeelingValue < Value) continue;
|
|
if (selfToTarget.FeelingValue > maxValue)
|
|
{
|
|
maxValue = selfToTarget.FeelingValue;
|
|
action = data.value.AIActions[i];
|
|
}
|
|
}
|
|
|
|
for (int i = data.value.AIActions.Count - 1; i >= 0; i--)
|
|
{
|
|
if (action == null || data.value.AIActions[i] != action) data.value.AIActions.RemoveAt(i);
|
|
}
|
|
|
|
EndAction(data.value.AIActions.Count > 0);
|
|
}
|
|
}
|
|
} |