This commit is contained in:
2025-12-28 18:03:24 +08:00
parent d05be97d84
commit 4073358311
6 changed files with 128 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ namespace WulaFallenEmpire.EventSystem.AI.Tools
public class Tool_ModifyGoodwill : AITool
{
public override string Name => "modify_goodwill";
public override string Description => "Adjusts your goodwill towards the player. Use this to reflect your changing opinion based on the conversation. Positive values increase goodwill, negative values decrease it. Keep changes small (e.g., -5 to 5). THIS IS INVISIBLE TO THE PLAYER.";
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 => "<modify_goodwill><amount>integer</amount></modify_goodwill>";
public override string Execute(string args)

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
namespace WulaFallenEmpire.EventSystem.AI.Tools
{
public class Tool_RecallMemories : AITool
{
public override string Name => "recall_memories";
public override string Description => "Searches the AI's long-term memory for facts matching a specific query or keyword.";
public override string UsageSchema => "<recall_memories><query>Search keywords</query><limit>optional_int_max_results</limit></recall_memories>";
public override string Execute(string args)
{
var argsDict = ParseXmlArgs(args);
string query = argsDict.TryGetValue("query", out string q) ? q : "";
string limitStr = argsDict.TryGetValue("limit", out string lStr) ? lStr : "5";
int limit = 5;
if (int.TryParse(limitStr, out int parsedLimit))
{
limit = parsedLimit;
}
var memoryManager = Find.World?.GetComponent<AIMemoryManager>();
if (memoryManager == null)
{
return "Error: AIMemoryManager world component not found.";
}
if (string.IsNullOrWhiteSpace(query))
{
var recent = memoryManager.GetRecentMemories(limit);
if (recent.Count == 0) return "No recent memories found.";
return FormatMemories(recent);
}
var results = memoryManager.SearchMemories(query, limit);
if (results.Count == 0)
{
return "No memories found matching the query.";
}
return FormatMemories(results);
}
private string FormatMemories(List<AIMemoryEntry> memories)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Found Memories:");
foreach (var m in memories)
{
sb.AppendLine($"- [{m.Category}] {m.Fact} (ID: {m.Id})");
}
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
namespace WulaFallenEmpire.EventSystem.AI.Tools
{
public class Tool_RememberFact : AITool
{
public override string Name => "remember_fact";
public override string Description => "Stores a specific fact or piece of information into the AI's long-term memory for future retrieval.";
public override string UsageSchema => "<remember_fact><fact>Text content to remember</fact><category>optional_category</category></remember_fact>";
public override string Execute(string args)
{
var argsDict = ParseXmlArgs(args);
if (!argsDict.TryGetValue("fact", out string fact) || string.IsNullOrWhiteSpace(fact))
{
return "Error: <fact> content is required.";
}
string category = argsDict.TryGetValue("category", out string cat) ? cat : "misc";
var memoryManager = Find.World?.GetComponent<AIMemoryManager>();
if (memoryManager == null)
{
return "Error: AIMemoryManager world component not found.";
}
var entry = memoryManager.AddMemory(fact, category);
if (entry != null)
{
return $"Success: Memory stored. ID: {entry.Id}";
}
else
{
return "Error: Failed to store memory.";
}
}
}
}