70 lines
2.0 KiB
C#
70 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
|
|
{
|
|
[Category("AIAction")]
|
|
[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 == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
if (data.value.Player.PlayerWealth < Money)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
float maxValue = 0f;
|
|
CountryDiplomacyInfo maxInfo = null;
|
|
foreach (var info in data.value.Player.DiplomacyData.Info)
|
|
{
|
|
if (info.FeelingValue < Value) continue;
|
|
if (info.FeelingValue > maxValue)
|
|
{
|
|
maxValue = info.FeelingValue;
|
|
maxInfo = info;
|
|
}
|
|
}
|
|
|
|
if (maxInfo != null && data.value.Map.PlayerMap.GetPlayerDataByPlayerID(maxInfo.PlayerId, out var target))
|
|
{
|
|
target.DiplomacyData.GetCountryDiplomacyInfo(data.value.Player.Id, out var targetToSelf);
|
|
targetToSelf.IsEmbassy = true;
|
|
if (!target.MeetPlayers.Contains(data.value.Player.Id))
|
|
target.MeetPlayers.Add(data.value.Player.Id);
|
|
EndAction(true);
|
|
return;
|
|
}
|
|
|
|
EndAction(false);
|
|
}
|
|
}
|
|
} |