Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/EventSystem/AI/Tools/Tool_SetOverwatchMode.cs
ProjectKoi-Kalo\Kalo b906a468b6 已把工具调用从 XML 改成 OpenAI 兼容 JSON,并统一解析/执行流程。改动概览如下:
新增 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
2025-12-31 01:45:38 +08:00

48 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
namespace WulaFallenEmpire.EventSystem.AI.Tools
{
public class Tool_SetOverwatchMode : AITool
{
public override string Name => "set_overwatch_mode";
public override string Description => "Enables or disables the AI Overwatch Combat Protocol. When enabled (enabled=true), the AI will autonomously scan for hostile targets every few seconds and launch appropriate orbital bombardments for a set duration. When disabled (enabled=false), it immediately stops any active overwatch and clears the flight path. Use enabled=false to stop overwatch early if the player requests it.";
public override string UsageSchema => "{\"enabled\":true,\"durationSeconds\":60}";
public override string Execute(string args)
{
var parsed = ParseJsonArgs(args);
bool enabled = true;
if (TryGetBool(parsed, "enabled", out bool e)) enabled = e;
int duration = 60;
if (TryGetInt(parsed, "durationSeconds", out int d)) duration = d;
Map map = Find.CurrentMap;
if (map == null) return "Error: No active map.";
var overwatch = map.GetComponent<MapComponent_AIOverwatch>();
if (overwatch == null)
{
overwatch = new MapComponent_AIOverwatch(map);
map.components.Add(overwatch);
}
if (enabled)
{
overwatch.EnableOverwatch(duration);
return $"Success: AI Overwatch Protocol ENABLED for {duration} seconds. Hostiles will be engaged automatically.";
}
else
{
overwatch.DisableOverwatch();
return "Success: AI Overwatch Protocol DISABLED.";
}
}
}
}