AITool 增加 Schema 构造器与函数定义生成,所有工具补齐 GetParametersSchema():AITool.cs 与 *.cs
57 lines
2.3 KiB
C#
57 lines
2.3 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 Dictionary<string, object> GetParametersSchema()
|
|
{
|
|
var properties = new Dictionary<string, object>
|
|
{
|
|
["enabled"] = SchemaBoolean("Enable or disable overwatch.", nullable: true),
|
|
["durationSeconds"] = SchemaInteger("Duration in seconds when enabling.", nullable: true)
|
|
};
|
|
return SchemaObject(properties, RequiredList("enabled", "durationSeconds"));
|
|
}
|
|
|
|
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.";
|
|
}
|
|
}
|
|
}
|
|
}
|