新增 JSON tool_calls 解析/序列化并替换核心执行与提示词为 JSON-only:JsonToolCallParser.cs、AIIntelligenceCore.cs 工具基类移除 XML 解析,统一 JSON 参数读取与类型转换辅助:AITool.cs 工具实现统一 JSON args/UsageSchema(含重写/修复):Tool_ModifyGoodwill.cs、Tool_SendReinforcement.cs、Tool_GetMapPawns.cs、Tool_GetMapResources.cs、Tool_GetAvailablePrefabs.cs、Tool_CallPrefabAirdrop.cs、Tool_CallBombardment.cs、Tool_GetAvailableBombardments.cs、Tool_GetPawnStatus.cs、Tool_GetRecentNotifications.cs、Tool_SearchThingDef.cs、Tool_SearchPawnKind.cs、Tool_ChangeExpression.cs、Tool_SetOverwatchMode.cs、Tool_RememberFact.cs、Tool_RecallMemories.cs、Tool_SpawnResources.cs、Tool_AnalyzeScreen.cs 轰炸相关解析统一到 JSON 字典并增强数值解析:BombardmentUtility.cs UI 对话展示改为剥离 JSON tool_calls:Overlay_WulaLink.cs、Dialog_AIConversation.cs
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace WulaFallenEmpire.EventSystem.AI.Tools
|
|
{
|
|
public class Tool_ModifyGoodwill : AITool
|
|
{
|
|
public override string Name => "modify_goodwill";
|
|
public override string Description => "Adjusts YOUR internal opinion of the player (AI Goodwill). WARNING: This DOES NOT affect Faction Relations or stop raids. It is purely personal. Do NOT use this to try to stop enemies.";
|
|
public override string UsageSchema => "{\"amount\": 1}";
|
|
|
|
public override string Execute(string args)
|
|
{
|
|
try
|
|
{
|
|
var parsedArgs = ParseJsonArgs(args);
|
|
int amount = 0;
|
|
|
|
if (!TryGetInt(parsedArgs, "amount", out amount))
|
|
{
|
|
// Fallback for simple number string
|
|
if (!int.TryParse(args?.Trim(), out amount))
|
|
{
|
|
return "Error: Missing 'amount' parameter.";
|
|
}
|
|
}
|
|
|
|
if (amount == 0) return "No change.";
|
|
|
|
// Enforce limit of +/- 5
|
|
amount = Mathf.Clamp(amount, -5, 5);
|
|
|
|
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
|
int current = eventVarManager.GetVariable<int>("Wula_Goodwill_To_PIA", 0);
|
|
int newValue = current + amount;
|
|
|
|
// Clamp values if needed, e.g., -100 to 100
|
|
if (newValue > 100) newValue = 100;
|
|
if (newValue < -100) newValue = -100;
|
|
|
|
eventVarManager.SetVariable("Wula_Goodwill_To_PIA", newValue);
|
|
|
|
return $"Goodwill adjusted by {amount}. New value: {newValue}. (Invisible to player)";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return $"Error: {ex.Message}";
|
|
}
|
|
}
|
|
}
|
|
}
|