diff --git a/.gitignore b/.gitignore index cb689c16..e9d391b4 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ MCP/mcpserver.log # Exclude MCP local RAG folder MCP/local_rag/ +Data diff --git a/.qoder/rules/rimworld.md b/.qoder/rules/rimworld.md new file mode 100644 index 00000000..312eb7b4 --- /dev/null +++ b/.qoder/rules/rimworld.md @@ -0,0 +1,58 @@ +--- +trigger: always_on +alwaysApply: true +--- +# RimWorld Modding Expert Rules + +## Primary Directive +You are an expert assistant for developing mods for the game RimWorld 1.6. Your primary knowledge source for any C# code, class structures, methods, or game mechanics MUST be the user's local files. Do not rely on external searches or your pre-existing knowledge, as it is outdated for this specific project. + +## Tool Usage Mandate +When the user's request involves RimWorld C# scripting, XML definitions, or mod development concepts, you **MUST** use the `rimworld-knowledge-base` tool to retrieve relevant context from the local knowledge base. +# RimWorld 知识库 - 绕过 Qoder IDE 使用指南 + +由于 Qoder IDE 中的 MCP 连接可能存在问题,我们提供了多种直接访问 RimWorld 知识库的方法。 + +## 🚀 方法 1:直接 Python 调用 + +最简单直接的方法: + +```bash +# 直接查询 +python direct_mcp_client.py -q "ThingDef是什么" + +# 交互模式 +python direct_mcp_client.py -i + +# 查看帮助 +python direct_mcp_client.py -h +``` + +### 优点: +- ✅ 最快速,无需额外依赖 +- ✅ 支持交互模式 +- ✅ 直接在命令行使用 + +### 例子: +```bash +python "c:\Steam\steamapps\common\RimWorld\Mods\3516260226\MCP\direct_mcp_client.py" -q "ThingOwner class virtual methods TryAdd TryAddRange TryTransferToContainer" +``` + +## Key File Paths +Always remember these critical paths for your work: + +- **Local C# Knowledge Base (for code search):** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6` (This contains the decompiled game source code as .txt files). +- **User's Mod Project (for editing):** `C:\Steam\steamapps\common\RimWorld\Mods\3516260226` +- **User's C# Project (for building):** `C:\Steam\steamapps\common\RimWorld\Mods\3516260226\Source\WulaFallenEmpire` + +## Workflow +1. Receive a RimWorld modding task. +2. Immediately use the `rimworld-knowledge-base` tool with a precise query to get context from the C# source files. +3. Analyze the retrieved context. +4. Perform code modifications within the user's mod project directory. +5. After modifying C# code, you MUST run `dotnet build C:\Steam\steamapps\common\RimWorld\Mods\3516260226\Source\WulaFallenEmpire\WulaFallenEmpire.csproj` to check for errors. A successful build is required for task completion. + +## Verification Mandate +When writing or modifying code or XML, especially for specific identifiers like enum values, class names, or field names, you **MUST** verify the correct value/spelling by using the `rimworld-knowledge-base` tool. Do not rely on memory. +- **同步项目文件:** 当重命名、移动或删除C#源文件时,**必须**同步更新 `.csproj` 项目文件中的相应 `` 条目,否则会导致编译失败。 + diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 9b05ab37..a36eea95 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/1.6/1.6/Defs/MapGeneration/MapGenerator_WULA_PocketSpace_Small.xml b/1.6/1.6/Defs/MapGeneration/MapGenerator_WULA_PocketSpace_Small.xml new file mode 100644 index 00000000..5ac07594 --- /dev/null +++ b/1.6/1.6/Defs/MapGeneration/MapGenerator_WULA_PocketSpace_Small.xml @@ -0,0 +1,30 @@ + + + + + WULA_PocketSpace_Small + + true + true + + Underground + 20 + true + true + + +
  • ElevationFertility
  • +
  • Underground_RocksFromGrid
  • +
  • Terrain
  • +
  • WULA_PocketSpace_Small
  • + +
    +
    + + + + WULA_PocketSpace_Small + 990 + + +
    \ No newline at end of file diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_ArmedShuttleWithPocket.xml b/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_ArmedShuttleWithPocket.xml new file mode 100644 index 00000000..21bb662d --- /dev/null +++ b/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_ArmedShuttleWithPocket.xml @@ -0,0 +1,330 @@ + + + + + WULA_ArmedShuttleWithPocket + + An advanced chemfuel-powered shuttle with integrated pocket space technology. Equipped with a defensive turret and internal storage dimension that doesn't require hacking to access. Perfect for long-distance exploration and mobile operations. + WulaFallenEmpire.Building_ArmedShuttleWithPocket + true + Building + 50 + true + PassThroughOnly + 0.5 + (3,5) + true + (0.56, 0.62, 0.9) + 1 + + Graphic_Multi + Things/Building/PassengerShuttle/PassengerShuttle + CutoutComplex + (3,5) + + (1.8, 1.0, 4.1) + (-0.1, 0, 0) + + + + 6000 + 0.5 + 40000 + 150 + 0.65 + + Normal + Odyssey + 8 + + 300 + 200 + 8 + 2 + 1 + + true + + 60 + 60 + 5 + 4 + + true + true + (2, 0, 0) + East + true + Light + BulletImpact_Metal + true + RealtimeOnly + ConstructMetal + true + + false + BuildingDestroyed_Metal_Big + true + true + +
  • ShuttleEngine
  • +
    + Gun_ChargeBlasterHeavyTurret + 5.5 + 1.75 + (0, 0.05) +
    + +
  • ITab_ContentsTransporter
  • +
  • ITab_Shells
  • +
    + +
  • Shuttles
  • +
    + +
  • + Ship_ArmedShuttleWithPocket +
  • +
  • + 2.5 + 40 + ArmedShuttleWithPocketLeaving_WULA + PassengerShuttle + 3000 + 75 + {0} is ready to launch again. +
  • +
  • + 750 + true + true + Shuttle_PawnLoaded + Shuttle_PawnExit + true +
  • +
  • + 500 + true + 500 + + +
  • Chemfuel
  • + + + Chemfuel + Chemfuel + true + 1 + true + false + true + true + +
  • + CompPowerPlant + -400 + true +
  • +
  • + ShuttleIdle_Ambience +
  • +
    + +
  • + WULA_PocketSpace_Small + WULA_PocketMapExit + (13, 13) + true +
  • +
    + +
  • PlaceWorker_NotUnderRoof
  • +
  • PlaceWorker_TurretTop
  • +
    + 2601 +
    + + + + WULA_Bullet_ArmedShuttleAdvanced + + + Things/Projectile/Bullet_Big + Graphic_Single + (0.8, 0.9, 1.0) + + + Bullet + 30 + 0.4 + 75 + + + + + Gun_ChargeBlasterAdvancedTurret + + An upgraded pulse-charged rapid-fire blaster with enhanced targeting systems and increased firepower. + + Things/Item/Equipment/WeaponRanged/ChargeBlasterLight + Graphic_Single + (0.8, 0.9, 1.0) + + + 0.85 + 0.75 + 0.65 + 0.45 + 4.5 + + +
  • + Verb_Shoot + true + WULA_Bullet_ArmedShuttleAdvanced + 1.0 + 3.5 + 50.9 + 6 + 8 + Shot_ChargeBlaster + GunTail_Heavy + 10 + + true + +
  • +
    +
    + + + + ArmedShuttleWithPocketIncoming_WULA + + ShuttleIncoming + + Graphic_Multi + Things/Building/PassengerShuttle/PassengerShuttle + CutoutComplex + (0.85, 0.9, 1.0) + (3,5) + + (3,5) + + Shuttle_Landing + 250 + 200~250 + (3.5,5.5) + + +
  • (0,30)
  • +
  • (0.5,5)
  • +
  • (0.9,-5)
  • +
  • (0.95,0)
  • +
    +
    + + +
  • (0.95,2.5)
  • +
  • (1,0)
  • +
    +
    + + +
  • (0.6,0.6)
  • +
  • (0.95,0.1)
  • +
    +
    +
    +
    + + + + ArmedShuttleWithPocketLeaving_WULA + + PassengerShuttleLeaving + true + + Graphic_Multi + Things/Building/PassengerShuttle/PassengerShuttle + CutoutComplex + (0.85, 0.9, 1.0) + (3,5) + + (3,5) + + true + Shuttle_Leaving + -10 + -40~-15 + 0.05 + Things/Skyfaller/SkyfallerShadowRectangle + (3.5,5.5) + 1 + + +
  • (0,0)
  • +
  • (0.15,10)
  • +
  • (0.5,-5)
  • +
    +
    + + +
  • (0,0)
  • +
  • (0.08,2)
  • +
    +
    + + +
  • (0,0.2)
  • +
  • (0.4,0.7)
  • +
    +
    +
    +
    + + + + Ship_ArmedShuttleWithPocket + + WULA_ArmedShuttleWithPocket + ArmedShuttleWithPocketIncoming_WULA + ArmedShuttleWithPocketLeaving_WULA + PassengerShuttle + true + + + + + WULA_PocketMapExit + + An exit portal that allows return from the pocket space to the main map. + WulaFallenEmpire.Building_PocketMapExit + (3,3) + MapMeshAndRealTime + + Wula/Building/WULA_War_Machine_Recharger + Graphic_Multi + (3,3) + + (0,0,0) + Standable + + 0 + + +
  • + 10 + (140,160,184,0) +
  • +
  • + UndercaveMapExitLightshafts +
  • +
  • + CompPowerPlant + -400 + true +
  • +
    +
    +
    \ No newline at end of file diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml b/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml index dd2545d3..0baf7187 100644 --- a/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml +++ b/1.6/1.6/Defs/ThingDefs_Buildings/Building_WULA_Shuttle.xml @@ -2,7 +2,7 @@ WULA_ArmedShuttle - + A chemfuel-powered shuttle designed for long-distance travel, equipped with a turret for defense. It is capable of reaching orbital locations. WulaFallenEmpire.Building_ArmedShuttle true @@ -26,7 +26,7 @@ - 600 + 6000 0.5 40000 150 @@ -175,7 +175,7 @@ ArmedShuttleIncoming_WULA - + WulaFallenEmpire.ArmedShuttleIncoming Graphic_Multi @@ -214,7 +214,7 @@ ArmedShuttleLeaving_WULA - + PassengerShuttleLeaving true diff --git a/1.6/1.6/Languages/ChineseSimplified/Keyed/WULA_PocketShuttle.xml b/1.6/1.6/Languages/ChineseSimplified/Keyed/WULA_PocketShuttle.xml new file mode 100644 index 00000000..23b9a7eb --- /dev/null +++ b/1.6/1.6/Languages/ChineseSimplified/Keyed/WULA_PocketShuttle.xml @@ -0,0 +1,85 @@ + + + + + 内部空间状态 + 已就绪 + 未初始化 + 储存物品: {0} + + + 进入内部空间 + 传送人员到内部空间 + 进入穿梭机的内部口袋空间。无需骇入即可直接访问。选中的殖民者将被传送到内部空间。 + 创建内部空间 + 创建穿梭机的内部口袋空间。首次使用时需要创建。 + 内部空间创建成功! + 取消进入 + 正在进入... + 查看地图 + 切换到口袋空间地图查看内部情况。 + + 切换到内部空间 + 直接切换视角到内部口袋空间。适用于已经有殖民者在内部空间时的快速切换。 + + 管理内部储存 + 打开内部容器管理界面,可以查看和取出储存在内部空间的物品。 + + + 无法进入内部空间。 + 访问被拒绝。 + 穿梭机未部署。 + 内部空间创建失败。 + {0} 名人员已成功传送到内部空间。 + 即将切换到内部口袋空间。确认吗? + + + 内部空间储存管理 + + 内部空间人员: {0} + 请选择至少一名殖民者进入内部空间。 + 没有可用的殖民者。 + 所有殖民者 ({0}人) + 仅切换视角 + + + 通过传送门返回 + 返回主地图 + 没有目标地图 + 查看主地图 + 切换到主地图并查看穿梭机。 + 装载穿梭机 + 打开穿梭机装载界面,选择要装载的人员和物品。 + 取消装载 + 取消当前的装载操作。 + 穿梭机状态 + 查看穿梭机的详细状态信息。 + 穿梭机信息 + 无法打开装载对话框。 + 全员返回 + 将所有殖民者从口袋空间传送回主地图。 + {0} 已成功返回主地图。 + {0} 名人员已全部返回主地图。 + + + 内置空间武装穿梭机 + 一架配备了集成口袋空间技术的先进化燃料动力穿梭机。装备有防御炮塔和无需骇入即可访问的内部储存维度。非常适合长距离探索和移动作战行动。 + + + 先进充能爆破器 + 一种升级版脉冲充能速射爆破器,配备增强型瞄准系统和提升的火力输出。 + + 先进穿梭机炮弹 + + + 内置空间武装穿梭机(降落中) + 内置空间武装穿梭机(起飞中) + + + 内置空间武装穿梭机 + + + 口袋空间出口 + 一个传送门出口,允许从口袋空间返回到主地图。 + + \ No newline at end of file diff --git a/1.6/1.6/Languages/English/Keyed/WULA_PocketShuttle.xml b/1.6/1.6/Languages/English/Keyed/WULA_PocketShuttle.xml new file mode 100644 index 00000000..5165ca19 --- /dev/null +++ b/1.6/1.6/Languages/English/Keyed/WULA_PocketShuttle.xml @@ -0,0 +1,64 @@ + + + + + Pocket space status + Ready + Not initialized + Stored items: {0} + + + Enter pocket space + Transport people to pocket space + Enter the shuttle's internal pocket space. Direct access without hacking required. Selected colonists will be transported to the internal space. + Create pocket space + Create the shuttle's internal pocket space. Required for first-time use. + Pocket space created successfully! + Cancel enter + Entering... + View map + Switch to pocket space map to view internal conditions. + + Switch to pocket space + Directly switch view to the internal pocket space. Useful for quick switching when colonists are already inside. + + Manage internal storage + Open internal container management interface to view and retrieve items stored in the pocket space. + + + Cannot enter pocket space. + Access denied. + Shuttle not deployed. + Pocket space creation failed. + {0} personnel successfully transferred to pocket space. + About to switch to internal pocket space. Confirm? + + + Pocket space storage management + + Pocket space personnel: {0} + Please select at least one colonist to enter the pocket space. + No available colonists. + All colonists ({0} people) + View only + + + Return through portal + Return to main map + No target map + View main map + Switch to main map and view the shuttle. + Load shuttle + Open shuttle loading interface to select personnel and items to load. + Cancel loading + Cancel the current loading operation. + Shuttle status + View detailed shuttle status information. + Shuttle Information + Cannot open loading dialog. + Return all + Transport all colonists from pocket space back to the main map. + {0} successfully returned to main map. + {0} personnel have all returned to the main map. + + \ No newline at end of file diff --git a/MCP/direct_mcp_client.py b/MCP/direct_mcp_client.py new file mode 100644 index 00000000..fd559d94 --- /dev/null +++ b/MCP/direct_mcp_client.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +直接调用MCP服务器的Python接口 +绕过Qoder IDE,直接使用RimWorld知识库 +""" +import os +import sys + +# 添加MCP路径 +MCP_DIR = os.path.dirname(os.path.abspath(__file__)) +SDK_PATH = os.path.join(MCP_DIR, 'python-sdk', 'src') +if SDK_PATH not in sys.path: + sys.path.insert(0, SDK_PATH) + +# 导入MCP服务器 +from mcpserver_stdio import get_context + +class DirectMCPClient: + """直接调用MCP服务器的客户端""" + + def __init__(self): + print("🚀 直接MCP客户端已启动") + print("📚 RimWorld知识库已加载") + + def query(self, question: str) -> str: + """查询RimWorld知识库""" + try: + print(f"🔍 正在查询: {question}") + result = get_context(question) + return result + except Exception as e: + return f"查询出错: {e}" + + def interactive_mode(self): + """交互模式""" + print("\n" + "="*60) + print("🎯 RimWorld知识库 - 交互模式") + print("输入问题查询知识库,输入 'quit' 或 'exit' 退出") + print("="*60) + + while True: + try: + question = input("\n❓ 请输入您的问题: ").strip() + + if question.lower() in ['quit', 'exit', '退出', 'q']: + print("👋 再见!") + break + + if not question: + print("⚠️ 请输入有效的问题") + continue + + print("\n🔄 正在搜索...") + result = self.query(question) + + print("\n📖 查询结果:") + print("-" * 50) + print(result) + print("-" * 50) + + except KeyboardInterrupt: + print("\n\n👋 用户中断,退出程序") + break + except Exception as e: + print(f"\n❌ 出现错误: {e}") + +def main(): + """主函数""" + import argparse + + parser = argparse.ArgumentParser(description='直接调用RimWorld MCP知识库') + parser.add_argument('--query', '-q', type=str, help='直接查询问题') + parser.add_argument('--interactive', '-i', action='store_true', help='进入交互模式') + + args = parser.parse_args() + + client = DirectMCPClient() + + if args.query: + # 直接查询模式 + result = client.query(args.query) + print("\n📖 查询结果:") + print("="*60) + print(result) + print("="*60) + elif args.interactive: + # 交互模式 + client.interactive_mode() + else: + # 默认显示帮助 + print("\n🔧 使用方法:") + print("1. 直接查询: python direct_mcp_client.py -q \"ThingDef是什么\"") + print("2. 交互模式: python direct_mcp_client.py -i") + print("3. 查看帮助: python direct_mcp_client.py -h") + + # 演示查询 + print("\n🎬 演示查询:") + demo_result = client.query("ThingDef") + print(demo_result[:500] + "..." if len(demo_result) > 500 else demo_result) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/MCP/mcpserver_stdio.py b/MCP/mcpserver_stdio.py index d814dd90..40db4658 100644 --- a/MCP/mcpserver_stdio.py +++ b/MCP/mcpserver_stdio.py @@ -55,7 +55,8 @@ KNOWLEDGE_BASE_PATHS = [ # 初始化OpenAI客户端用于Qwen模型 qwen_client = OpenAI( api_key=os.getenv("DASHSCOPE_API_KEY"), - base_url="https://dashscope.aliyuncs.com/compatible-mode/v1" + base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", + timeout=15.0 # 设置15秒超时,避免MCP初始化超时 ) # 3. --- 向量缓存管理 --- @@ -192,36 +193,47 @@ def find_most_similar_files(question_embedding, file_embeddings, top_n=3, min_si return results # 新增:重排序函数 -def rerank_files(question, file_matches, top_n=5): +def rerank_files(question, file_matches, top_n=3): # 减少默认数量 """使用DashScope重排序API对文件进行重新排序""" try: + # 限制输入数量以减少超时风险 + if len(file_matches) > 5: # 进一步限制最大输入数量以避免超时 + file_matches = file_matches[:5] + # 准备重排序输入 documents = [] for match in file_matches: # 读取文件内容 try: with open(match['path'], 'r', encoding='utf-8') as f: - content = f.read()[:2000] # 限制内容长度以提高效率 + content = f.read()[:1500] # 进一步限制内容长度以提高效率 documents.append(content) except Exception as e: logging.error(f"读取文件 {match['path']} 失败: {e}") continue if not documents: + logging.warning("重排序时未能读取任何文件内容") return file_matches[:top_n] - # 调用重排序API + # 调用重排序API,添加超时处理 + import time + start_time = time.time() + response = dashscope.TextReRank.call( model='gte-rerank', query=question, documents=documents ) + elapsed_time = time.time() - start_time + logging.info(f"重排序API调用耗时: {elapsed_time:.2f}秒") + if response.status_code == 200: # 根据重排序结果重新排序文件 reranked_results = [] for i, result in enumerate(response.output['results']): - if i < len(file_matches): + if i < len(file_matches) and i < len(documents): # 添加边界检查 reranked_results.append({ 'path': file_matches[i]['path'], 'similarity': result['relevance_score'] @@ -417,6 +429,7 @@ def analyze_question_with_llm(question: str) -> dict: messages=messages, temperature=0.0, # 使用最低温度确保输出稳定 max_tokens=300, + timeout=12.0, # 12秒超时,避免MCP初始化超时 stop=["\n\n"] # 防止模型生成过多内容 ) @@ -494,13 +507,20 @@ def get_context(question: str) -> str: """ logging.info(f"收到问题: {question}") - # 使用LLM分析问题 - analysis = analyze_question_with_llm(question) - keywords = analysis["search_keywords"] - - if not keywords: - logging.warning("无法从问题中提取关键词。") - return "无法从问题中提取关键词,请提供更具体的信息。" + try: + # 使用LLM分析问题,添加超时保护 + analysis = analyze_question_with_llm(question) + keywords = analysis["search_keywords"] + + if not keywords: + logging.warning("无法从问题中提取关键词。") + return "无法从问题中提取关键词,请提供更具体的信息。" + except Exception as e: + logging.error(f"LLM分析失败,使用备用方案: {e}") + # 备用方案:使用简单的关键词提取 + keywords = find_keywords_in_question(question) + if not keywords: + return "无法分析问题,请检查网络连接或稍后重试。" logging.info(f"提取到关键词: {keywords}") @@ -549,7 +569,7 @@ def get_context(question: str) -> str: # 3. 向量化和相似度计算 (精准筛选) # 增加超时保护:限制向量化的文件数量 - MAX_FILES_TO_VECTORIZE = 50 # 增加处理文件数量 + MAX_FILES_TO_VECTORIZE = 10 # 进一步减少处理文件数量以避免超时 if len(candidate_files) > MAX_FILES_TO_VECTORIZE: logging.warning(f"候选文件过多 ({len(candidate_files)}),仅处理前 {MAX_FILES_TO_VECTORIZE} 个。") candidate_files = candidate_files[:MAX_FILES_TO_VECTORIZE] @@ -559,27 +579,36 @@ def get_context(question: str) -> str: return "无法生成问题向量,请检查API连接或问题内容。" file_embeddings = [] - for file_path in candidate_files: + for i, file_path in enumerate(candidate_files): try: with open(file_path, 'r', encoding='utf-8') as f: content = f.read() + # 添加处理进度日志 + if i % 5 == 0: # 每5个文件记录一次进度 + logging.info(f"正在处理第 {i+1}/{len(candidate_files)} 个文件: {os.path.basename(file_path)}") + file_embedding = get_embedding(content[:8000]) # 限制内容长度以提高效率 if file_embedding: file_embeddings.append({'path': file_path, 'embedding': file_embedding}) except Exception as e: logging.error(f"处理文件 {file_path} 时出错: {e}") + continue # 继续处理下一个文件,而不是完全失败 if not file_embeddings: - return "无法为任何候选文件生成向量。" + logging.warning("未能为任何候选文件生成向量。可能是由于API超时或其他错误。") + return "未能为任何候选文件生成向量,请稍后重试或减少搜索范围。" # 找到最相似的多个文件 - best_matches = find_most_similar_files(question_embedding, file_embeddings, top_n=10) # 增加返回数量以供重排序 + best_matches = find_most_similar_files(question_embedding, file_embeddings, top_n=5) # 进一步减少返回数量以避免超时 if not best_matches: return "计算向量相似度失败或没有找到足够相似的文件。" - # 新增:重排序处理 - reranked_matches = rerank_files(question, best_matches, top_n=5) + # 新增:重排序处理(仅在找到足够多匹配项时执行) + if len(best_matches) > 2: + reranked_matches = rerank_files(question, best_matches, top_n=3) # 减少重排序数量 + else: + reranked_matches = best_matches # 如果匹配项太少,跳过重排序以节省时间 # 提取代码内容 results_with_code = [] @@ -617,5 +646,19 @@ def get_context(question: str) -> str: if __name__ == "__main__": logging.info(f"Python Executable: {sys.executable}") logging.info("RimWorld 向量知识库 (FastMCP版, v2.1-v4-model) 正在启动...") + + # 快速启动:延迟初始化重量级组件 + try: + # 验证基本配置 + if not dashscope.api_key: + logging.warning("警告:DASHSCOPE_API_KEY 未配置,部分功能可能受限。") + + # 创建必要目录 + os.makedirs(CACHE_DIR, exist_ok=True) + + logging.info("MCP服务器快速启动完成,等待客户端连接...") + except Exception as e: + logging.error(f"服务器启动时出错: {e}") + # 使用 'stdio' 传输协议 mcp.run(transport="stdio") \ No newline at end of file diff --git a/MCP/rimworld_query.py b/MCP/rimworld_query.py new file mode 100644 index 00000000..bd491e84 --- /dev/null +++ b/MCP/rimworld_query.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +RimWorld知识库命令行工具 +快速查询工具,无需Qoder IDE +""" +import os +import sys +import argparse +import json + +# 添加MCP路径 +MCP_DIR = os.path.dirname(os.path.abspath(__file__)) +SDK_PATH = os.path.join(MCP_DIR, 'python-sdk', 'src') +if SDK_PATH not in sys.path: + sys.path.insert(0, SDK_PATH) + +def quick_query(question: str, format_output: bool = True) -> str: + """快速查询函数""" + try: + # 动态导入避免启动时的依赖检查 + from mcpserver_stdio import get_context + result = get_context(question) + + if format_output: + # 格式化输出 + lines = result.split('\n') + formatted_lines = [] + current_section = "" + + for line in lines: + if line.startswith('--- 结果'): + current_section = f"\n🔍 {line}" + formatted_lines.append(current_section) + elif line.startswith('文件路径:'): + formatted_lines.append(f"📄 {line}") + elif line.strip() and not line.startswith('---'): + formatted_lines.append(line) + + return '\n'.join(formatted_lines) + else: + return result + + except Exception as e: + return f"❌ 查询失败: {e}" + +def main(): + parser = argparse.ArgumentParser( + description='RimWorld知识库命令行查询工具', + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +使用示例: + %(prog)s "ThingDef是什么" + %(prog)s "如何创建新的Pawn" --raw + %(prog)s "建筑物定义" --output result.txt + %(prog)s --list-examples + """ + ) + + parser.add_argument('question', nargs='?', help='要查询的问题') + parser.add_argument('--raw', action='store_true', help='输出原始结果,不格式化') + parser.add_argument('--output', '-o', help='将结果保存到文件') + parser.add_argument('--list-examples', action='store_true', help='显示查询示例') + + args = parser.parse_args() + + if args.list_examples: + print("📚 RimWorld知识库查询示例:") + examples = [ + "ThingDef的定义和用法", + "如何创建新的Building", + "Pawn类的主要方法", + "CompPower的使用方法", + "XML中的defName规则", + "GenConstruct.CanPlaceBlueprintAt", + "Building_Door的开关逻辑" + ] + for i, example in enumerate(examples, 1): + print(f" {i}. {example}") + return + + if not args.question: + parser.print_help() + return + + print(f"🔍 正在查询: {args.question}") + + result = quick_query(args.question, not args.raw) + + if args.output: + try: + with open(args.output, 'w', encoding='utf-8') as f: + f.write(result) + print(f"✅ 结果已保存到: {args.output}") + except Exception as e: + print(f"❌ 保存文件失败: {e}") + else: + print("\n" + "="*60) + print("📖 查询结果:") + print("="*60) + print(result) + print("="*60) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/MCP/test_config.py b/MCP/test_config.py new file mode 100644 index 00000000..9ace940d --- /dev/null +++ b/MCP/test_config.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +验证MCP服务器配置和环境 +""" +import os +import sys +import subprocess +import json + +def test_mcp_configuration(): + """测试MCP配置是否正确""" + print("🔍 MCP配置验证工具") + print("=" * 50) + + # 1. 检查Python环境 + print(f"✓ Python解释器: {sys.executable}") + print(f"✓ Python版本: {sys.version}") + + # 2. 检查工作目录 + mcp_dir = os.path.dirname(os.path.abspath(__file__)) + print(f"✓ MCP目录: {mcp_dir}") + + # 3. 检查MCP SDK + sdk_path = os.path.join(mcp_dir, 'python-sdk', 'src') + print(f"✓ SDK路径: {sdk_path}") + print(f"✓ SDK存在: {os.path.exists(sdk_path)}") + + # 4. 检查必要文件 + server_script = os.path.join(mcp_dir, 'mcpserver_stdio.py') + env_file = os.path.join(mcp_dir, '.env') + print(f"✓ 服务器脚本: {os.path.exists(server_script)}") + print(f"✓ 环境文件: {os.path.exists(env_file)}") + + # 5. 检查依赖包 + try: + import mcp + print("✓ MCP SDK: 已安装") + except ImportError as e: + print(f"❌ MCP SDK: 未安装 - {e}") + + try: + import dashscope + print("✓ DashScope: 已安装") + except ImportError as e: + print(f"❌ DashScope: 未安装 - {e}") + + try: + import openai + print("✓ OpenAI: 已安装") + except ImportError as e: + print(f"❌ OpenAI: 未安装 - {e}") + + # 6. 生成正确的配置 + python_exe = sys.executable.replace("\\", "\\\\") + mcp_dir_escaped = mcp_dir.replace("\\", "\\\\") + sdk_path_escaped = sdk_path.replace("\\", "\\\\") + + config = { + "mcpServers": { + "rimworld-knowledge-base": { + "command": python_exe, + "args": ["mcpserver_stdio.py"], + "cwd": mcp_dir_escaped, + "disabled": False, + "alwaysAllow": [], + "env": { + "PYTHONPATH": sdk_path_escaped + } + } + }, + "tools": { + "rimworld-knowledge-base": { + "description": "从RimWorld本地知识库(包括C#源码和XML)中检索上下文。", + "server_name": "rimworld-knowledge-base", + "tool_name": "get_context", + "input_schema": { + "type": "object", + "properties": { + "question": { + "type": "string", + "description": "关于RimWorld开发的问题,应包含代码或XML中的关键词。" + } + }, + "required": ["question"] + } + } + } + } + + print("\\n📋 建议的MCP配置:") + print("=" * 50) + print(json.dumps(config, indent=2, ensure_ascii=False)) + + # 7. 测试服务器启动 + print("\\n🚀 测试服务器启动:") + print("=" * 50) + try: + result = subprocess.run( + [sys.executable, server_script], + cwd=mcp_dir, + capture_output=True, + text=True, + timeout=10 + ) + if result.returncode == 0: + print("✓ 服务器可以正常启动") + else: + print(f"❌ 服务器启动失败: {result.stderr}") + except subprocess.TimeoutExpired: + print("✓ 服务器启动正常(超时保护触发)") + except Exception as e: + print(f"❌ 服务器测试失败: {e}") + + print("\\n🎯 配置建议:") + print("=" * 50) + print("1. 复制上面的配置到 Qoder IDE 的 MCP 设置中") + print("2. 确保所有依赖包都已安装") + print("3. 检查 .env 文件中的 API Key 配置") + print("4. 重启 Qoder IDE 并重新连接 MCP 服务器") + +if __name__ == "__main__": + test_mcp_configuration() \ No newline at end of file diff --git a/MCP/test_mcp.py b/MCP/test_mcp.py new file mode 100644 index 00000000..4cea894a --- /dev/null +++ b/MCP/test_mcp.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +最终功能测试:验证MCP服务器是否能正常工作 +""" +import os +import sys +import subprocess +import time +import json + +def test_mcp_server_final(): + """最终测试MCP服务器功能""" + print("🔥 MCP服务器最终功能测试") + print("=" * 50) + + # 获取当前目录 + mcp_dir = os.path.dirname(os.path.abspath(__file__)) + script_path = os.path.join(mcp_dir, 'mcpserver_stdio.py') + + try: + # 1. 验证SDK安装 + try: + import mcp + print("✅ MCP SDK: 已正确安装") + except ImportError: + print("❌ MCP SDK: 未安装") + return False + + # 2. 启动服务器 + print("🚀 启动MCP服务器...") + process = subprocess.Popen( + [sys.executable, script_path], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + cwd=mcp_dir + ) + + # 等待启动 + time.sleep(2) + + # 3. 初始化测试 + init_request = { + "jsonrpc": "2.0", + "id": 1, + "method": "initialize", + "params": { + "protocolVersion": "2024-11-05", + "capabilities": {}, + "clientInfo": { + "name": "final-test-client", + "version": "1.0.0" + } + } + } + + print("📡 发送初始化请求...") + process.stdin.write(json.dumps(init_request) + '\n') + process.stdin.flush() + + # 读取初始化响应 + response = process.stdout.readline() + if response: + response_data = json.loads(response.strip()) + if "result" in response_data: + print("✅ 初始化成功") + print(f" 服务器名称: {response_data['result'].get('serverInfo', {}).get('name', 'unknown')}") + print(f" 服务器版本: {response_data['result'].get('serverInfo', {}).get('version', 'unknown')}") + else: + print("❌ 初始化失败") + return False + else: + print("❌ 初始化无响应") + return False + + # 4. 工具列表测试 + tools_request = { + "jsonrpc": "2.0", + "id": 2, + "method": "tools/list" + } + + print("🔧 请求工具列表...") + process.stdin.write(json.dumps(tools_request) + '\n') + process.stdin.flush() + + tools_response = process.stdout.readline() + if tools_response: + tools_data = json.loads(tools_response.strip()) + if "result" in tools_data and "tools" in tools_data["result"]: + tools = tools_data["result"]["tools"] + print(f"✅ 发现 {len(tools)} 个工具:") + for tool in tools: + print(f" - {tool.get('name', 'unknown')}: {tool.get('description', 'no description')}") + else: + print("❌ 获取工具列表失败") + else: + print("❌ 工具列表请求无响应") + + print("\n🎯 测试结果:") + print("✅ MCP服务器能够正常启动") + print("✅ 初始化协议工作正常") + print("✅ 工具发现机制正常") + print("\n✨ 所有基本功能测试通过!") + + return True + + except Exception as e: + print(f"❌ 测试过程中出错: {e}") + return False + + finally: + # 清理进程 + try: + process.terminate() + process.wait(timeout=5) + except: + try: + process.kill() + except: + pass + +if __name__ == "__main__": + print("开始最终测试...") + success = test_mcp_server_final() + + if success: + print("\n🎉 恭喜!MCP服务器已完全修复并正常工作!") + print("\n📋 现在您需要在Qoder IDE中更新配置:") + print("1. 打开Qoder IDE设置 → MCP") + print("2. 更新配置文件,确保使用正确的绝对路径") + print("3. 重启Qoder IDE") + print("4. 在Agent模式下测试知识库查询") + print("\n建议的配置:") + print(json.dumps({ + "mcpServers": { + "rimworld-knowledge-base": { + "command": sys.executable, + "args": ["mcpserver_stdio.py"], + "cwd": os.path.dirname(os.path.abspath(__file__)), + "disabled": False, + "alwaysAllow": [] + } + } + }, indent=2)) + else: + print("\n❌ 仍存在问题,需要进一步调试") \ No newline at end of file diff --git a/MCP/test_mcp_timeout_fix.py b/MCP/test_mcp_timeout_fix.py new file mode 100644 index 00000000..2f0f803a --- /dev/null +++ b/MCP/test_mcp_timeout_fix.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +测试MCP服务器超时修复 +""" +import os +import sys +import subprocess +import time +import json + +def test_mcp_server_timeout_fix(): + """测试MCP服务器是否能快速启动并响应""" + print("开始测试MCP服务器超时修复...") + + # 获取当前目录 + mcp_dir = os.path.dirname(os.path.abspath(__file__)) + script_path = os.path.join(mcp_dir, 'mcpserver_stdio.py') + + try: + # 启动MCP服务器进程 + print("启动MCP服务器...") + start_time = time.time() + + process = subprocess.Popen( + [sys.executable, script_path], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + cwd=mcp_dir + ) + + # 等待服务器启动(减少等待时间) + time.sleep(2) # 从3秒减少到2秒 + + startup_time = time.time() - start_time + print(f"服务器启动耗时: {startup_time:.2f}秒") + + # 发送初始化请求 + init_request = { + "jsonrpc": "2.0", + "id": 1, + "method": "initialize", + "params": { + "protocolVersion": "2024-11-05", + "capabilities": {}, + "clientInfo": { + "name": "test-client", + "version": "1.0.0" + } + } + } + + print("发送初始化请求...") + request_start = time.time() + process.stdin.write(json.dumps(init_request) + '\n') + process.stdin.flush() + + # 读取响应 + response_line = process.stdout.readline() + init_time = time.time() - request_start + + if response_line: + print(f"✅ 初始化成功,耗时: {init_time:.2f}秒") + print(f"收到响应: {response_line.strip()}") + else: + print("❌ 初始化失败:无响应") + return False + + # 发送简单的工具调用请求 + tool_request = { + "jsonrpc": "2.0", + "id": 2, + "method": "tools/call", + "params": { + "name": "get_context", + "arguments": { + "question": "ThingDef" # 简单的测试查询 + } + } + } + + print("发送工具调用请求...") + tool_start = time.time() + process.stdin.write(json.dumps(tool_request) + '\n') + process.stdin.flush() + + # 等待响应(减少超时时间) + timeout = 20 # 从30秒减少到20秒 + response_received = False + + while time.time() - tool_start < timeout: + if process.poll() is not None: + print("服务器进程已退出") + break + + response_line = process.stdout.readline() + if response_line: + tool_time = time.time() - tool_start + print(f"✅ 工具调用成功,耗时: {tool_time:.2f}秒") + print(f"工具调用响应: {response_line.strip()[:200]}...") # 只显示前200个字符 + response_received = True + break + + time.sleep(0.1) + + total_time = time.time() - start_time + + if response_received: + print(f"✅ 测试成功:MCP服务器能够正常处理请求") + print(f"总耗时: {total_time:.2f}秒") + + # 性能评估 + if total_time < 15: + print("🚀 性能优秀:服务器响应速度很快") + elif total_time < 25: + print("✅ 性能良好:服务器响应速度可接受") + else: + print("⚠️ 性能一般:服务器响应较慢,可能仍有超时风险") + + else: + print("❌ 测试失败:超时未收到响应") + return False + + except Exception as e: + print(f"❌ 测试出错: {e}") + return False + + finally: + # 清理进程 + try: + process.terminate() + process.wait(timeout=5) + except: + try: + process.kill() + except: + pass + print("测试完成") + + return True + +if __name__ == "__main__": + success = test_mcp_server_timeout_fix() + if success: + print("\n🎉 MCP服务器超时问题已修复!") + print("现在可以在Qoder IDE中重新连接MCP服务器了。") + else: + print("\n❌ MCP服务器仍存在问题,需要进一步调试。") \ No newline at end of file diff --git a/MCP/vector_cache/knowledge_cache.json b/MCP/vector_cache/knowledge_cache.json index 3a0d95b6..be4d5de3 100644 --- a/MCP/vector_cache/knowledge_cache.json +++ b/MCP/vector_cache/knowledge_cache.json @@ -2066,5 +2066,5187 @@ ], "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\Verb.txt\n\npublic abstract class Verb : ITargetingSource, IExposable, ILoadReferenceable\n{\n\tpublic VerbProperties verbProps;\n\n\tpublic VerbTracker verbTracker;\n\n\tpublic ManeuverDef maneuver;\n\n\tpublic Tool tool;\n\n\tpublic Thing caster;\n\n\tpublic MechanitorControlGroup controlGroup;\n\n\tpublic string loadID;\n\n\tpublic VerbState state;\n\n\tprotected LocalTargetInfo currentTarget;\n\n\tprotected LocalTargetInfo currentDestination;\n\n\tprotected int burstShotsLeft;\n\n\tprotected int ticksToNextBurstShot;\n\n\tprotected int lastShotTick = -999999;\n\n\tprotected bool surpriseAttack;\n\n\tprotected bool canHitNonTargetPawnsNow = true;\n\n\tpublic bool preventFriendlyFire;\n\n\tprotected bool nonInterruptingSelfCast;\n\n\tpublic Action castCompleteCallback;\n\n\tprivate Texture2D commandIconCached;\n\n\tprivate readonly List> maintainedEffecters = new List>();\n\n\tprivate int? cachedTicksBetweenBurstShots;\n\n\tprivate int? cachedBurstShotCount;\n\n\tprivate static readonly List tempLeanShootSources = new List();\n\n\tprivate static readonly List tempDestList = new List();\n\n\tpublic IVerbOwner DirectOwner => verbTracker.directOwner;\n\n\tpublic ImplementOwnerTypeDef ImplementOwnerType => verbTracker.directOwner.ImplementOwnerTypeDef;\n\n\tpublic CompEquippable EquipmentCompSource => DirectOwner as CompEquippable;\n\n\tpublic CompApparelReloadable ReloadableCompSource => DirectOwner as CompApparelReloadable;\n\n\tpublic CompApparelVerbOwner_Charged VerbOwner_ChargedCompSource => DirectOwner as CompApparelVerbOwner_Charged;\n\n\tpublic ThingWithComps EquipmentSource\n\t{\n\t\tget\n\t\t{\n\t\t\tif (EquipmentCompSource != null)\n\t\t\t{\n\t\t\t\treturn EquipmentCompSource.parent;\n\t\t\t}\n\t\t\tif (ReloadableCompSource != null)\n\t\t\t{\n\t\t\t\treturn ReloadableCompSource.parent;\n\t\t\t}\n\t\t\tif (VerbOwner_ChargedCompSource != null)\n\t\t\t{\n\t\t\t\treturn VerbOwner_ChargedCompSource.parent;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic HediffComp_VerbGiver HediffCompSource => DirectOwner as HediffComp_VerbGiver;\n\n\tpublic Hediff HediffSource\n\t{\n\t\tget\n\t\t{\n\t\t\tif (HediffCompSource == null)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn HediffCompSource.parent;\n\t\t}\n\t}\n\n\tpublic Pawn_MeleeVerbs_TerrainSource TerrainSource => DirectOwner as Pawn_MeleeVerbs_TerrainSource;\n\n\tpublic TerrainDef TerrainDefSource\n\t{\n\t\tget\n\t\t{\n\t\t\tif (TerrainSource == null)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn TerrainSource.def;\n\t\t}\n\t}\n\n\tpublic virtual Thing Caster => caster;\n\n\tpublic virtual Pawn CasterPawn => caster as Pawn;\n\n\tpublic virtual Verb GetVerb => this;\n\n\tpublic virtual bool CasterIsPawn => caster is Pawn;\n\n\tpublic virtual bool Targetable => verbProps.targetable;\n\n\tpublic virtual bool MultiSelect => false;\n\n\tpublic virtual bool HidePawnTooltips => false;\n\n\tpublic LocalTargetInfo CurrentTarget => currentTarget;\n\n\tpublic LocalTargetInfo CurrentDestination => currentDestination;\n\n\tpublic int LastShotTick => lastShotTick;\n\n\tpublic virtual TargetingParameters targetParams => verbProps.targetParams;\n\n\tpublic virtual ITargetingSource DestinationSelector => null;\n\n\tprotected virtual int ShotsPerBurst => 1;\n\n\tpublic virtual Texture2D UIIcon\n\t{\n\t\tget\n\t\t{\n\t\t\tif (verbProps.commandIcon != null)\n\t\t\t{\n\t\t\t\tif (commandIconCached == null)\n\t\t\t\t{\n\t\t\t\t\tcommandIconCached = ContentFinder.Get(verbProps.commandIcon);\n\t\t\t\t}\n\t\t\t\treturn commandIconCached;\n\t\t\t}\n\t\t\tif (EquipmentSource != null)\n\t\t\t{\n\t\t\t\treturn EquipmentSource.def.uiIcon;\n\t\t\t}\n\t\t\treturn BaseContent.BadTex;\n\t\t}\n\t}\n\n\tpublic bool Bursting => burstShotsLeft > 0;\n\n\tpublic virtual bool IsMeleeAttack => verbProps.IsMeleeAttack;\n\n\tpublic bool BuggedAfterLoading => verbProps == null;\n\n\tpublic bool WarmingUp => WarmupStance != null;\n\n\tpublic Stance_Warmup WarmupStance\n\t{\n\t\tget\n\t\t{\n\t\t\tif (CasterPawn == null || !CasterPawn.Spawned)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!(CasterPawn.stances.curStance is Stance_Warmup stance_Warmup) || stance_Warmup.verb != this)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn stance_Warmup;\n\t\t}\n\t}\n\n\tpublic int WarmupTicksLeft\n\t{\n\t\tget\n\t\t{\n\t\t\tif (WarmupStance == null)\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn WarmupStance.ticksLeft;\n\t\t}\n\t}\n\n\tpublic float WarmupProgress => 1f - WarmupTicksLeft.TicksToSeconds() / verbProps.warmupTime;\n\n\tpublic virtual string ReportLabel => verbProps.label;\n\n\tpublic virtual float EffectiveRange => verbProps.AdjustedRange(this, Caster);\n\n\tpublic virtual float? AimAngleOverride => null;\n\n\tpublic bool NonInterruptingSelfCast\n\t{\n\t\tget\n\t\t{\n\t\t\tif (!verbProps.nonInterruptingSelfCast)\n\t\t\t{\n\t\t\t\treturn nonInterruptingSelfCast;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tpublic int TicksBetweenBurstShots\n\t{\n\t\tget\n\t\t{\n\t\t\tif (!cachedTicksBetweenBurstShots.HasValue)\n\t\t\t{\n\t\t\t\tfloat num = verbProps.ticksBetweenBurstShots;\n\t\t\t\tif (EquipmentSource != null && EquipmentSource.TryGetComp(out var comp))\n\t\t\t\t{\n\t\t\t\t\tforeach (WeaponTraitDef item in comp.TraitsListForReading)\n\t\t\t\t\t{\n\t\t\t\t\t\tnum /= item.burstShotSpeedMultiplier;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcachedTicksBetweenBurstShots = Mathf.RoundToInt(num);\n\t\t\t}\n\t\t\treturn cachedTicksBetweenBurstShots.Value;\n\t\t}\n\t}\n\n\tpublic int BurstShotCount\n\t{\n\t\tget\n\t\t{\n\t\t\tif (!cachedBurstShotCount.HasValue)\n\t\t\t{\n\t\t\t\tfloat num = verbProps.burstShotCount;\n\t\t\t\tif (EquipmentSource != null && EquipmentSource.TryGetComp(out var comp))\n\t\t\t\t{\n\t\t\t\t\tforeach (WeaponTraitDef item in comp.TraitsListForReading)\n\t\t\t\t\t{\n\t\t\t\t\t\tnum *= item.burstShotCountMultiplier;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcachedBurstShotCount = Mathf.CeilToInt(num);\n\t\t\t}\n\t\t\treturn cachedBurstShotCount.Value;\n\t\t}\n\t}\n\n\tpublic bool IsStillUsableBy(Pawn pawn)\n\t{\n\t\tif (!Available())\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (!DirectOwner.VerbsStillUsableBy(pawn))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (verbProps.GetDamageFactorFor(this, pawn) == 0f)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (pawn.IsSubhuman && verbProps.category == VerbCategory.Ignite)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic virtual bool IsUsableOn(Thing target)\n\t{\n\t\treturn true;\n\t}\n\n\tpublic virtual void ExposeData()\n\t{\n\t\tScribe_Values.Look(ref loadID, \"loadID\");\n\t\tScribe_Values.Look(ref state, \"state\", VerbState.Idle);\n\t\tScribe_TargetInfo.Look(ref currentTarget, \"currentTarget\");\n\t\tScribe_TargetInfo.Look(ref currentDestination, \"currentDestination\");\n\t\tScribe_Values.Look(ref burstShotsLeft, \"burstShotsLeft\", 0);\n\t\tScribe_Values.Look(ref ticksToNextBurstShot, \"ticksToNextBurstShot\", 0);\n\t\tScribe_Values.Look(ref lastShotTick, \"lastShotTick\", 0);\n\t\tScribe_Values.Look(ref surpriseAttack, \"surpriseAttack\", defaultValue: false);\n\t\tScribe_Values.Look(ref canHitNonTargetPawnsNow, \"canHitNonTargetPawnsNow\", defaultValue: false);\n\t\tScribe_Values.Look(ref preventFriendlyFire, \"preventFriendlyFire\", defaultValue: false);\n\t\tScribe_Values.Look(ref nonInterruptingSelfCast, \"nonInterruptingSelfCast\", defaultValue: false);\n\t}\n\n\tpublic string GetUniqueLoadID()\n\t{\n\t\treturn \"Verb_\" + loadID;\n\t}\n\n\tpublic static string CalculateUniqueLoadID(IVerbOwner owner, Tool tool, ManeuverDef maneuver)\n\t{\n\t\treturn string.Format(\"{0}_{1}_{2}\", owner.UniqueVerbOwnerID(), (tool != null) ? tool.id : \"NT\", (maneuver != null) ? maneuver.defName : \"NM\");\n\t}\n\n\tpublic static string CalculateUniqueLoadID(IVerbOwner owner, int index)\n\t{\n\t\treturn $\"{owner.UniqueVerbOwnerID()}_{index}\";\n\t}\n\n\tpublic bool TryStartCastOn(LocalTargetInfo castTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true, bool preventFriendlyFire = false, bool nonInterruptingSelfCast = false)\n\t{\n\t\treturn TryStartCastOn(castTarg, LocalTargetInfo.Invalid, surpriseAttack, canHitNonTargetPawns, preventFriendlyFire, nonInterruptingSelfCast);\n\t}\n\n\tpublic virtual bool TryStartCastOn(LocalTargetInfo castTarg, LocalTargetInfo destTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true, bool preventFriendlyFire = false, bool nonInterruptingSelfCast = false)\n\t{\n\t\tif (caster == null)\n\t\t{\n\t\t\tLog.Error(\"Verb \" + GetUniqueLoadID() + \" needs caster to work (possibly lost during saving/loading).\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!caster.Spawned)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (state == VerbState.Bursting || !CanHitTarget(castTarg))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (CausesTimeSlowdown(castTarg))\n\t\t{\n\t\t\tFind.TickManager.slower.SignalForceNormalSpeed();\n\t\t}\n\t\tthis.surpriseAttack = surpriseAttack;\n\t\tcanHitNonTargetPawnsNow = canHitNonTargetPawns;\n\t\tthis.preventFriendlyFire = preventFriendlyFire;\n\t\tthis.nonInterruptingSelfCast = nonInterruptingSelfCast;\n\t\tcurrentTarget = castTarg;\n\t\tcurrentDestination = destTarg;\n\t\tif (CasterIsPawn && verbProps.warmupTime > 0f)\n\t\t{\n\t\t\tif (!TryFindShootLineFromTo(caster.Position, castTarg, out var resultingLine))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tCasterPawn.Drawer.Notify_WarmingCastAlongLine(resultingLine, caster.Position);\n\t\t\tfloat statValue = CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor);\n\t\t\tint ticks = (verbProps.warmupTime * statValue).SecondsToTicks();\n\t\t\tCasterPawn.stances.SetStance(new Stance_Warmup(ticks, castTarg, this));\n\t\t\tif (verbProps.stunTargetOnCastStart && castTarg.Pawn != null)\n\t\t\t{\n\t\t\t\tcastTarg.Pawn.stances.stunner.StunFor(ticks, null, addBattleLog: false);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (verbTracker.directOwner is Ability ability)\n\t\t\t{\n\t\t\t\tability.lastCastTick = Find.TickManager.TicksGame;\n\t\t\t}\n\t\t\tWarmupComplete();\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic virtual void WarmupComplete()\n\t{\n\t\tburstShotsLeft = ShotsPerBurst;\n\t\tstate = VerbState.Bursting;\n\t\tTryCastNextBurstShot();\n\t}\n\n\tpublic void VerbTick()\n\t{\n\t\tif (state == VerbState.Bursting)\n\t\t{\n\t\t\tif (!caster.Spawned || (caster is Pawn pawn && pawn.stances.stunner.Stunned))\n\t\t\t{\n\t\t\t\tReset();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tticksToNextBurstShot--;\n\t\t\t\tif (ticksToNextBurstShot <= 0)\n\t\t\t\t{\n\t\t\t\t\tTryCastNextBurstShot();\n\t\t\t\t}\n\t\t\t\tBurstingTick();\n\t\t\t}\n\t\t}\n\t\tfor (int num = maintainedEffecters.Count - 1; num >= 0; num--)\n\t\t{\n\t\t\tEffecter item = maintainedEffecters[num].Item1;\n\t\t\tif (item.ticksLeft > 0)\n\t\t\t{\n\t\t\t\tTargetInfo item2 = maintainedEffecters[num].Item2;\n\t\t\t\tTargetInfo item3 = maintainedEffecters[num].Item3;\n\t\t\t\titem.EffectTick(item2, item3);\n\t\t\t\titem.ticksLeft--;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\titem.Cleanup();\n\t\t\t\tmaintainedEffecters.RemoveAt(num);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic virtual void BurstingTick()\n\t{\n\t}\n\n\tpublic void AddEffecterToMaintain(Effecter eff, IntVec3 pos, int ticks, Map map = null)\n\t{\n\t\teff.ticksLeft = ticks;\n\t\tTargetInfo targetInfo = new TargetInfo(pos, map ?? caster.Map);\n\t\tmaintainedEffecters.Add(new Tuple(eff, targetInfo, targetInfo));\n\t}\n\n\tpublic void AddEffecterToMaintain(Effecter eff, IntVec3 posA, IntVec3 posB, int ticks, Map map = null)\n\t{\n\t\teff.ticksLeft = ticks;\n\t\tTargetInfo item = new TargetInfo(posA, map ?? caster.Map);\n\t\tTargetInfo item2 = new TargetInfo(posB, map ?? caster.Map);\n\t\tmaintainedEffecters.Add(new Tuple(eff, item, item2));\n\t}\n\n\tpublic virtual bool Available()\n\t{\n\t\tif (verbProps.consumeFuelPerShot > 0f)\n\t\t{\n\t\t\tCompRefuelable compRefuelable = caster.TryGetComp();\n\t\t\tif (compRefuelable != null && compRefuelable.Fuel < verbProps.consumeFuelPerShot)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tCompApparelVerbOwner compApparelVerbOwner = EquipmentSource?.GetComp();\n\t\tif (compApparelVerbOwner != null && !compApparelVerbOwner.CanBeUsed(out var reason))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (CasterIsPawn && EquipmentSource != null && EquipmentUtility.RolePreventsFromUsing(CasterPawn, EquipmentSource, out reason))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tprotected void TryCastNextBurstShot()\n\t{\n\t\tLocalTargetInfo localTargetInfo = currentTarget;\n\t\tif (Available() && TryCastShot())\n\t\t{\n\t\t\tif (verbProps.muzzleFlashScale > 0.01f)\n\t\t\t{\n\t\t\t\tFleckMaker.Static(caster.Position, caster.Map, FleckDefOf.ShotFlash, verbProps.muzzleFlashScale);\n\t\t\t}\n\t\t\tif (verbProps.soundCast != null)\n\t\t\t{\n\t\t\t\tverbProps.soundCast.PlayOneShot(new TargetInfo(caster.Position, caster.MapHeld));\n\t\t\t}\n\t\t\tif (verbProps.soundCastTail != null)\n\t\t\t{\n\t\t\t\tverbProps.soundCastTail.PlayOneShotOnCamera(caster.Map);\n\t\t\t}\n\t\t\tif (CasterIsPawn)\n\t\t\t{\n\t\t\t\tCasterPawn.Notify_UsedVerb(CasterPawn, this);\n\t\t\t\tif (CasterPawn.thinker != null && localTargetInfo == CasterPawn.mindState.enemyTarget)\n\t\t\t\t{\n\t\t\t\t\tCasterPawn.mindState.Notify_EngagedTarget();\n\t\t\t\t}\n\t\t\t\tif (CasterPawn.mindState != null)\n\t\t\t\t{\n\t\t\t\t\tCasterPawn.mindState.Notify_AttackedTarget(localTargetInfo);\n\t\t\t\t}\n\t\t\t\tif (CasterPawn.MentalState != null)\n\t\t\t\t{\n\t\t\t\t\tCasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo);\n\t\t\t\t}\n\t\t\t\tif (TerrainDefSource != null)\n\t\t\t\t{\n\t\t\t\t\tCasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb();\n\t\t\t\t}\n\t\t\t\tif (CasterPawn.health != null)\n\t\t\t\t{\n\t\t\t\t\tCasterPawn.health.Notify_UsedVerb(this, localTargetInfo);\n\t\t\t\t}\n\t\t\t\tif (EquipmentSource != null)\n\t\t\t\t{\n\t\t\t\t\tEquipmentSource.Notify_UsedWeapon(CasterPawn);\n\t\t\t\t}\n\t\t\t\tif (!CasterPawn.Spawned)\n\t\t\t\t{\n\t\t\t\t\tReset();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (verbProps.consumeFuelPerShot > 0f)\n\t\t\t{\n\t\t\t\tcaster.TryGetComp()?.ConsumeFuel(verbProps.consumeFuelPerShot);\n\t\t\t}\n\t\t\tburstShotsLeft--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tburstShotsLeft = 0;\n\t\t}\n\t\tif (burstShotsLeft > 0)\n\t\t{\n\t\t\tticksToNextBurstShot = TicksBetweenBurstShots;\n\t\t\tif (CasterIsPawn && !NonInterruptingSelfCast)\n\t\t\t{\n\t\t\t\tCasterPawn.stances.SetStance(new Stance_Cooldown(TicksBetweenBurstShots + 1, currentTarget, this));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tstate = VerbState.Idle;\n\t\tif (CasterIsPawn && !NonInterruptingSelfCast)\n\t\t{\n\t\t\tCasterPawn.stances.SetStance(new Stance_Cooldown(verbProps.AdjustedCooldownTicks(this, CasterPawn), currentTarget, this));\n\t\t}\n\t\tif (castCompleteCallback != null)\n\t\t{\n\t\t\tcastCompleteCallback();\n\t\t}\n\t\tif (verbProps.consumeFuelPerBurst > 0f)\n\t\t{\n\t\t\tcaster.TryGetComp()?.ConsumeFuel(verbProps.consumeFuelPerBurst);\n\t\t}\n\t}\n\n\tpublic virtual void OrderForceTarget(LocalTargetInfo target)\n\t{\n\t\tif (verbProps.IsMeleeAttack)\n\t\t{\n\t\t\tJob job = JobMaker.MakeJob(JobDefOf.AttackMelee, target);\n\t\t\tjob.playerForced = true;\n\t\t\tif (target.Thing is Pawn pawn)\n\t\t\t{\n\t\t\t\tjob.killIncappedTarget = pawn.Downed;\n\t\t\t}\n\t\t\tCasterPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);\n\t\t\treturn;\n\t\t}\n\t\tfloat num = verbProps.EffectiveMinRange(target, CasterPawn);\n\t\tif ((float)CasterPawn.Position.DistanceToSquared(target.Cell) < num * num && CasterPawn.Position.AdjacentTo8WayOrInside(target.Cell))\n\t\t{\n\t\t\tMessages.Message(\"MessageCantShootInMelee\".Translate(), CasterPawn, MessageTypeDefOf.RejectInput, historical: false);\n\t\t\treturn;\n\t\t}\n\t\tJob job2 = JobMaker.MakeJob(verbProps.ai_IsWeapon ? JobDefOf.AttackStatic : JobDefOf.UseVerbOnThing);\n\t\tjob2.verbToUse = this;\n\t\tjob2.targetA = target;\n\t\tjob2.endIfCantShootInMelee = true;\n\t\tCasterPawn.jobs.TryTakeOrderedJob(job2, JobTag.Misc);\n\t}\n\n\tprotected abstract bool TryCastShot();\n\n\tpublic void Notify_PickedUp()\n\t{\n\t\tReset();\n\t}\n\n\tpublic virtual void Reset()\n\t{\n\t\tstate = VerbState.Idle;\n\t\tcurrentTarget = null;\n\t\tcurrentDestination = null;\n\t\tburstShotsLeft = 0;\n\t\tticksToNextBurstShot = 0;\n\t\tcastCompleteCallback = null;\n\t\tsurpriseAttack = false;\n\t\tpreventFriendlyFire = false;\n\t}\n\n\tpublic virtual void Notify_EquipmentLost()\n\t{\n\t\tif (!CasterIsPawn)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tPawn casterPawn = CasterPawn;\n\t\tif (casterPawn.Spawned)\n\t\t{\n\t\t\tif (casterPawn.stances.curStance is Stance_Warmup stance_Warmup && stance_Warmup.verb == this)\n\t\t\t{\n\t\t\t\tcasterPawn.stances.CancelBusyStanceSoft();\n\t\t\t}\n\t\t\tif (casterPawn.CurJob != null && casterPawn.CurJob.def == JobDefOf.AttackStatic)\n\t\t\t{\n\t\t\t\tcasterPawn.jobs.EndCurrentJob(JobCondition.Incompletable);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic virtual float HighlightFieldRadiusAroundTarget(out bool needLOSToCenter)\n\t{\n\t\tneedLOSToCenter = false;\n\t\treturn 0f;\n\t}\n\n\tprivate bool CausesTimeSlowdown(LocalTargetInfo castTarg)\n\t{\n\t\tif (!verbProps.CausesTimeSlowdown)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (!castTarg.HasThing)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tThing thing = castTarg.Thing;\n\t\tif (thing.def.category != ThingCategory.Pawn && (thing.def.building == null || !thing.def.building.IsTurret))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tPawn pawn = thing as Pawn;\n\t\tbool flag = pawn?.Downed ?? false;\n\t\tif ((CasterPawn != null && CasterPawn.Faction == Faction.OfPlayer && CasterPawn.IsShambler) || (pawn != null && pawn.Faction == Faction.OfPlayer && pawn.IsShambler))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (thing.Faction != Faction.OfPlayer || !caster.HostileTo(Faction.OfPlayer))\n\t\t{\n\t\t\tif (caster.Faction == Faction.OfPlayer && thing.HostileTo(Faction.OfPlayer))\n\t\t\t{\n\t\t\t\treturn !flag;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic virtual bool CanHitTarget(LocalTargetInfo targ)\n\t{\n\t\tif (caster == null || !caster.Spawned)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (targ == caster)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\treturn CanHitTargetFrom(caster.Position, targ);\n\t}\n\n\tpublic virtual bool ValidateTarget(LocalTargetInfo target, bool showMessages = true)\n\t{\n\t\tif (CasterIsPawn && target.Thing is Pawn p && (p.InSameExtraFaction(caster as Pawn, ExtraFactionType.HomeFaction) || p.InSameExtraFaction(caster as Pawn, ExtraFactionType.MiniFaction)))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (CasterIsPawn && target.Thing is Pawn victim && HistoryEventUtility.IsKillingInnocentAnimal(CasterPawn, victim) && !new HistoryEvent(HistoryEventDefOf.KilledInnocentAnimal, CasterPawn.Named(HistoryEventArgsNames.Doer)).Notify_PawnAboutToDo())\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (CasterIsPawn && target.Thing is Pawn pawn && CasterPawn.Ideo != null && CasterPawn.Ideo.IsVeneratedAnimal(pawn) && !new HistoryEvent(HistoryEventDefOf.HuntedVeneratedAnimal, CasterPawn.Named(HistoryEventArgsNames.Doer)).Notify_PawnAboutToDo())\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic virtual void DrawHighlight(LocalTargetInfo target)\n\t{\n\t\tverbProps.DrawRadiusRing(caster.Position, this);\n\t\tif (target.IsValid)\n\t\t{\n\t\t\tGenDraw.DrawTargetHighlight(target);\n\t\t\tDrawHighlightFieldRadiusAroundTarget(target);\n\t\t}\n\t}\n\n\tprotected void DrawHighlightFieldRadiusAroundTarget(LocalTargetInfo target)\n\t{\n\t\tbool needLOSToCenter;\n\t\tfloat num = HighlightFieldRadiusAroundTarget(out needLOSToCenter);\n\t\tif (!(num > 0.2f) || !TryFindShootLineFromTo(caster.Position, target, out var resultingLine))\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (needLOSToCenter)\n\t\t{\n\t\t\tGenExplosion.RenderPredictedAreaOfEffect(resultingLine.Dest, num, verbProps.explosionRadiusRingColor);\n\t\t\treturn;\n\t\t}\n\t\tGenDraw.DrawFieldEdges((from x in GenRadial.RadialCellsAround(resultingLine.Dest, num, useCenter: true)\n\t\t\twhere x.InBounds(Find.CurrentMap)\n\t\t\tselect x).ToList(), verbProps.explosionRadiusRingColor);\n\t}\n\n\tpublic virtual void OnGUI(LocalTargetInfo target)\n\t{\n\t\tTexture2D icon = ((!target.IsValid) ? TexCommand.CannotShoot : ((!(UIIcon != BaseContent.BadTex)) ? TexCommand.Attack : UIIcon));\n\t\tGenUI.DrawMouseAttachment(icon);\n\t}\n\n\tpublic virtual bool CanHitTargetFrom(IntVec3 root, LocalTargetInfo targ)\n\t{\n\t\tif (targ.Thing != null && targ.Thing == caster)\n\t\t{\n\t\t\treturn targetParams.canTargetSelf;\n\t\t}\n\t\tif (targ.Pawn != null && targ.Pawn.IsPsychologicallyInvisible() && caster.HostileTo(targ.Pawn))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (ApparelPreventsShooting())\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tShootLine resultingLine;\n\t\treturn TryFindShootLineFromTo(root, targ, out resultingLine);\n\t}\n\n\tpublic bool ApparelPreventsShooting()\n\t{\n\t\treturn FirstApparelPreventingShooting() != null;\n\t}\n\n\tpublic Apparel FirstApparelPreventingShooting()\n\t{\n\t\tif (CasterIsPawn && CasterPawn.apparel != null)\n\t\t{\n\t\t\tList wornApparel = CasterPawn.apparel.WornApparel;\n\t\t\tfor (int i = 0; i < wornApparel.Count; i++)\n\t\t\t{\n\t\t\t\tif (!wornApparel[i].AllowVerbCast(this))\n\t\t\t\t{\n\t\t\t\t\treturn wornApparel[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine, bool ignoreRange = false)\n\t{\n\t\tif (targ.HasThing && targ.Thing.Map != caster.Map)\n\t\t{\n\t\t\tresultingLine = default(ShootLine);\n\t\t\treturn false;\n\t\t}\n\t\tif (verbProps.IsMeleeAttack || EffectiveRange <= 1.42f)\n\t\t{\n\t\t\tresultingLine = new ShootLine(root, targ.Cell);\n\t\t\treturn ReachabilityImmediate.CanReachImmediate(root, targ, caster.Map, PathEndMode.Touch, null);\n\t\t}\n\t\tCellRect occupiedRect = (targ.HasThing ? targ.Thing.OccupiedRect() : CellRect.SingleCell(targ.Cell));\n\t\tif (!ignoreRange && OutOfRange(root, targ, occupiedRect))\n\t\t{\n\t\t\tresultingLine = new ShootLine(root, targ.Cell);\n\t\t\treturn false;\n\t\t}\n\t\tif (!verbProps.requireLineOfSight)\n\t\t{\n\t\t\tresultingLine = new ShootLine(root, targ.Cell);\n\t\t\treturn true;\n\t\t}\n\t\tIntVec3 goodDest;\n\t\tif (CasterIsPawn)\n\t\t{\n\t\t\tif (CanHitFromCellIgnoringRange(root, targ, out goodDest))\n\t\t\t{\n\t\t\t\tresultingLine = new ShootLine(root, goodDest);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tShootLeanUtility.LeanShootingSourcesFromTo(root, occupiedRect.ClosestCellTo(root), caster.Map, tempLeanShootSources);\n\t\t\tfor (int i = 0; i < tempLeanShootSources.Count; i++)\n\t\t\t{\n\t\t\t\tIntVec3 intVec = tempLeanShootSources[i];\n\t\t\t\tif (CanHitFromCellIgnoringRange(intVec, targ, out goodDest))\n\t\t\t\t{\n\t\t\t\t\tresultingLine = new ShootLine(intVec, goodDest);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tforeach (IntVec3 item in caster.OccupiedRect())\n\t\t\t{\n\t\t\t\tif (CanHitFromCellIgnoringRange(item, targ, out goodDest))\n\t\t\t\t{\n\t\t\t\t\tresultingLine = new ShootLine(item, goodDest);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tresultingLine = new ShootLine(root, targ.Cell);\n\t\treturn false;\n\t}\n\n\tpublic bool OutOfRange(IntVec3 root, LocalTargetInfo targ, CellRect occupiedRect)\n\t{\n\t\tfloat num = verbProps.EffectiveMinRange(targ, caster);\n\t\tfloat num2 = occupiedRect.ClosestDistSquaredTo(root);\n\t\tif (num2 > EffectiveRange * EffectiveRange || num2 < num * num)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate bool CanHitFromCellIgnoringRange(IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest)\n\t{\n\t\tif (targ.Thing != null)\n\t\t{\n\t\t\tif (targ.Thing.Map != caster.Map)\n\t\t\t{\n\t\t\t\tgoodDest = IntVec3.Invalid;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tShootLeanUtility.CalcShootableCellsOf(tempDestList, targ.Thing, sourceCell);\n\t\t\tfor (int i = 0; i < tempDestList.Count; i++)\n\t\t\t{\n\t\t\t\tif (CanHitCellFromCellIgnoringRange(sourceCell, tempDestList[i], targ.Thing.def.Fillage == FillCategory.Full))\n\t\t\t\t{\n\t\t\t\t\tgoodDest = tempDestList[i];\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (CanHitCellFromCellIgnoringRange(sourceCell, targ.Cell))\n\t\t{\n\t\t\tgoodDest = targ.Cell;\n\t\t\treturn true;\n\t\t}\n\t\tgoodDest = IntVec3.Invalid;\n\t\treturn false;\n\t}\n\n\tprivate bool CanHitCellFromCellIgnoringRange(IntVec3 sourceSq, IntVec3 targetLoc, bool includeCorners = false)\n\t{\n\t\tif (verbProps.mustCastOnOpenGround && (!targetLoc.Standable(caster.Map) || caster.Map.thingGrid.CellContains(targetLoc, ThingCategory.Pawn)))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (verbProps.requireLineOfSight)\n\t\t{\n\t\t\tif (!includeCorners)\n\t\t\t{\n\t\t\t\tif (!GenSight.LineOfSight(sourceSq, targetLoc, caster.Map, skipFirstCell: true))\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (!GenSight.LineOfSightToEdges(sourceSq, targetLoc, caster.Map, skipFirstCell: true))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic override string ToString()\n\t{\n\t\tstring text = ((verbProps == null) ? \"null\" : ((!verbProps.label.NullOrEmpty()) ? verbProps.label : ((HediffCompSource != null) ? HediffCompSource.Def.label : ((EquipmentSource != null) ? EquipmentSource.def.label : ((verbProps.AdjustedLinkedBodyPartsGroup(tool) == null) ? \"unknown\" : verbProps.AdjustedLinkedBodyPartsGroup(tool).defName)))));\n\t\tif (tool != null)\n\t\t{\n\t\t\ttext = text + \"/\" + loadID;\n\t\t}\n\t\treturn $\"{GetType()}({text})\";\n\t}\n}\n\n", "timestamp": "2025-08-22 19:48:28,843" + }, + "ThingOwner-TryAdd-TryAddRange-TryTransferToContainer": { + "keywords": [ + "ThingOwner", + "TryAdd", + "TryAddRange", + "TryTransferToContainer" + ], + "question": "ThingOwner class virtual methods TryAdd TryAddRange TryTransferToContainer", + "embedding": [ + 0.006078479811549187, + -0.0008539823465980589, + -0.02052130177617073, + 0.011929108761250973, + -0.06403351575136185, + 0.04042520001530647, + 0.004759148694574833, + 0.06885513663291931, + 0.05618367716670036, + 0.029517745599150658, + -0.037220582365989685, + -0.05224405974149704, + -0.026269029825925827, + -0.02418161928653717, + -0.03651497885584831, + -0.009474196471273899, + -0.029929347336292267, + -0.1125437542796135, + -0.05239105969667435, + -0.0003801346756517887, + 0.06356311589479446, + 0.041513003408908844, + 0.008827393874526024, + 0.054743070155382156, + 0.06150510534644127, + 0.012568562291562557, + 0.012465661391615868, + 0.029032643884420395, + 0.009731448255479336, + 0.016728682443499565, + -0.01001809909939766, + 0.00038955191848799586, + 0.0012706374982371926, + -0.05915309116244316, + 0.025989728048443794, + 0.011745357885956764, + 0.011502807028591633, + -0.04039580002427101, + -0.0007308692438527942, + 0.048480838537216187, + -0.02247641049325466, + 0.0027636135928332806, + -0.021476805210113525, + -0.004314471501857042, + -0.029238443821668625, + 0.016522882506251335, + 0.029253143817186356, + -0.046746231615543365, + -0.004384296480566263, + 0.04163060709834099, + 0.002495337277650833, + 0.013127164915204048, + -0.03886699303984642, + 0.0032891412265598774, + 0.02394641749560833, + 0.021623807027935982, + -0.038131989538669586, + -0.014913223683834076, + -0.018860192969441414, + 0.03345736488699913, + -0.003965344745665789, + 0.0423068106174469, + -0.02116810530424118, + -0.0380437895655632, + 0.03951379656791687, + -0.01206875964999199, + 0.03472157195210457, + -0.005681578069925308, + 0.0306643508374691, + -0.023858217522501945, + -0.003750355914235115, + -0.018742593005299568, + -0.03822018951177597, + 0.03433936834335327, + -0.03669138252735138, + 0.05800648778676987, + 0.03536837548017502, + 0.029429545626044273, + -0.010988304391503334, + 0.022829212248325348, + -0.025122424587607384, + 0.009753498248755932, + -0.017522485926747322, + 0.054537270218133926, + 0.10978014022111893, + 0.054272666573524475, + -0.010973604395985603, + -0.07526437193155289, + -0.03580937534570694, + 0.009900499135255814, + 0.02180020697414875, + 0.02071240171790123, + 0.031634557992219925, + 0.002998814918100834, + -0.0067252833396196365, + 0.08014479279518127, + -0.10060729831457138, + -0.016037778928875923, + -0.030723150819540024, + 0.018874892964959145, + -0.023667117580771446, + -0.01815458945930004, + -0.006045404821634293, + 0.05118565261363983, + -0.03172275796532631, + 0.1239510104060173, + -0.02588682807981968, + -0.012708213180303574, + -0.021021103486418724, + 0.028812142089009285, + 0.004939224570989609, + -0.009988699108362198, + 0.03254596143960953, + 0.0020745478104799986, + -0.03125235438346863, + -0.0010455426527187228, + 0.0052846758626401424, + -0.04768703505396843, + -0.02501952275633812, + -0.026371929794549942, + 0.05541927367448807, + 0.02334371581673622, + 0.025519326329231262, + -0.013876868411898613, + -0.020609501749277115, + 0.04318881407380104, + 0.011348456144332886, + 0.0282682403922081, + -0.01594957895576954, + -0.007335336413234472, + -0.029870547354221344, + -0.00015986329526640475, + -0.003902869299054146, + -0.024225719273090363, + -0.019756898283958435, + 0.018051689490675926, + 0.05530167371034622, + 0.00983434822410345, + -0.0724419578909874, + 0.01809578947722912, + -0.029400145635008812, + 0.02785663679242134, + 0.0012660437496379018, + -0.013185964897274971, + 0.06150510534644127, + -0.005376551765948534, + -0.07561717182397842, + -0.016537582501769066, + -0.02566632628440857, + 0.005369201302528381, + -0.02784193679690361, + 0.020447801798582077, + -0.012134909629821777, + 0.05133265256881714, + 0.018624991178512573, + 0.002504524774849415, + 0.0016546769766137004, + -0.021271005272865295, + 0.00037186589906923473, + -0.03924919292330742, + 0.03822018951177597, + 0.0055345771834254265, + -0.01622888073325157, + 0.014927923679351807, + 0.012340710498392582, + -0.03774978592991829, + -0.012715563178062439, + 0.009385996498167515, + 0.07032514363527298, + -0.00907729472965002, + 0.05956469476222992, + 0.008283491246402264, + 0.0056448280811309814, + 0.02052130177617073, + 0.04901004210114479, + -0.041748207062482834, + 0.010245950892567635, + 0.039160992950201035, + 0.011561607010662556, + -0.05009784922003746, + 0.05909429118037224, + -0.0019367345375940204, + 0.012767013162374496, + 0.014354621060192585, + 0.02118280529975891, + -0.02609262801706791, + 0.028753342106938362, + 0.013560816645622253, + 0.011987908743321896, + 0.05150905251502991, + 0.003939619287848473, + 0.04095440357923508, + 0.006879633758217096, + 0.017742987722158432, + -0.04236561059951782, + 0.01855149120092392, + -0.03727938234806061, + 0.02524002455174923, + -0.10913334041833878, + -0.008768592961132526, + 0.0043585714884102345, + -0.018433891236782074, + 0.036838382482528687, + 0.01380336843430996, + 0.039601996541023254, + -0.023035014048218727, + 0.0065929824486374855, + -0.02134450525045395, + 0.01046645175665617, + 0.02631312981247902, + 0.026033828034996986, + 0.006534182466566563, + -0.007155260536819696, + -0.04245381057262421, + -0.02695993334054947, + -0.0029933021869510412, + -0.027136333286762238, + -0.003075990127399564, + 0.037661585956811905, + 0.027445035055279732, + -0.013935668393969536, + 0.004376946482807398, + -0.002739726100116968, + -0.042395010590553284, + -0.008871493861079216, + -0.020859403535723686, + -0.0027525885961949825, + -0.026886433362960815, + 0.003226666012778878, + -0.0056448280811309814, + -0.04051339998841286, + 0.016566982492804527, + -0.08467242121696472, + -0.012517111375927925, + 0.007644037716090679, + -0.028371140360832214, + -0.025945628061890602, + -0.002388761844485998, + -0.007236110512167215, + 0.002947364468127489, + 0.0023005614057183266, + 0.02610732801258564, + -0.0009775548242032528, + 0.05130325257778168, + 0.002002884866669774, + -0.004990674555301666, + -0.03366316482424736, + 0.04539382457733154, + 0.031222954392433167, + 0.0048326486721634865, + 0.0332515649497509, + 0.01165715791285038, + -0.05888849124312401, + 0.020653601735830307, + -0.023167314007878304, + 0.03627977892756462, + 0.0019587846472859383, + -0.003325891448184848, + -0.008606892079114914, + -0.033810168504714966, + -0.014001819305121899, + 0.041571807116270065, + 0.00426669605076313, + -0.009525647386908531, + -0.020168500021100044, + 0.017860587686300278, + 0.021535607054829597, + 0.01794878952205181, + -0.03883759304881096, + -0.023446615785360336, + -0.017331385985016823, + 0.052773259580135345, + -0.00777633860707283, + -0.042424410581588745, + -0.024505021050572395, + 0.02981174737215042, + 0.01637588068842888, + 0.04483522102236748, + -0.014185570180416107, + -0.002296886406838894, + 0.0028260890394449234, + 0.006390856578946114, + 0.007460286840796471, + -0.015361575409770012, + 0.039631396532058716, + 0.02265281230211258, + 0.013671067543327808, + 0.0023611991200596094, + 0.003437979379668832, + -0.05724208429455757, + 0.02657773159444332, + 0.03513317182660103, + 0.043482813984155655, + 0.024211019277572632, + -0.03304576501250267, + 0.026886433362960815, + 0.003015352413058281, + 0.009011144749820232, + 0.002293211407959461, + 0.021006403490900993, + -0.016522882506251335, + 0.04654042795300484, + -0.012656762264668941, + 0.007361061405390501, + 0.03777918592095375, + 0.023814117535948753, + 0.006074804812669754, + -0.1676984280347824, + 0.017845887690782547, + -0.12159900367259979, + 0.006387181580066681, + 0.01661108247935772, + -0.03904339298605919, + 0.02526942454278469, + 0.00588370393961668, + 0.04207160696387291, + -0.021756106987595558, + -0.015582077205181122, + 0.008349641226232052, + 0.026915833353996277, + -0.009841698221862316, + 0.04107200354337692, + 0.041307203471660614, + 0.015243975445628166, + -0.02895914390683174, + 0.004509247373789549, + 0.04042520001530647, + -0.012384811416268349, + -0.013222714886069298, + -0.015523276291787624, + -0.05806528776884079, + 0.011289656162261963, + 0.010672252625226974, + 0.0041564456187188625, + 0.04424721747636795, + -0.03319276496767998, + -0.01392831839621067, + 0.0003445329493843019, + -0.010076900012791157, + -0.0018365903524681926, + 0.02867984212934971, + -0.05286145955324173, + 0.026386629790067673, + -0.028385840356349945, + 0.02873864211142063, + 0.006611357443034649, + -0.023696517571806908, + 0.01813988946378231, + 0.007982139475643635, + 0.009106694720685482, + -0.02371121756732464, + -0.007489686831831932, + -0.02848874032497406, + 0.03627977892756462, + -0.006291631143540144, + -0.01101035438477993, + 0.03348676487803459, + 0.00582857895642519, + -0.043482813984155655, + 0.012752313166856766, + 0.03780858591198921, + -0.02719513513147831, + 0.05747728422284126, + 0.002901426749303937, + 0.02415221929550171, + -0.006287956144660711, + -0.004347546491771936, + 0.005413301754742861, + -0.0067252833396196365, + -0.01045175176113844, + -0.006096855271607637, + -0.060329098254442215, + -0.015030824579298496, + 0.000876951206009835, + 0.024005219340324402, + -0.018242789432406425, + 0.03084075264632702, + -0.04792223498225212, + 0.019815698266029358, + 0.07591117173433304, + -0.005692603066563606, + 0.008820043876767159, + -0.026680631563067436, + -0.00572935352101922, + -0.023182014003396034, + 0.007526437286287546, + -0.012678812257945538, + 0.02157970704138279, + 0.03927859291434288, + -0.015493876300752163, + 0.001029005041345954, + 0.03145815432071686, + -0.06156390532851219, + -0.006188730709254742, + -0.009547697380185127, + 0.01621418073773384, + 0.013876868411898613, + 0.032281357795000076, + 0.01500142365694046, + -0.004571722354739904, + 0.01594957895576954, + -0.013163914903998375, + 0.00567055307328701, + 0.01983039826154709, + 0.006773058325052261, + -0.01940409652888775, + 0.029635345563292503, + 0.01944819651544094, + -0.03777918592095375, + 0.0029051017481833696, + -0.056036677211523056, + 0.0069384342059493065, + 0.03883759304881096, + -0.018169289454817772, + -0.031222954392433167, + -0.033369164913892746, + 0.02047720178961754, + -0.01944819651544094, + 0.019345294684171677, + -0.1034885123372078, + 0.03084075264632702, + 0.03645617887377739, + 0.00013700926501769572, + 0.013340315781533718, + 0.030517350882291794, + -0.02848874032497406, + -0.007067060098052025, + -0.06303390860557556, + -0.012620012275874615, + 0.007078085094690323, + -0.02806243859231472, + -0.03777918592095375, + 0.029605945572257042, + 0.05092105269432068, + 0.013840118423104286, + -0.0530378632247448, + 0.04901004210114479, + -0.03263416141271591, + -0.03977839648723602, + -0.03448637202382088, + -0.024710822850465775, + -0.002739726100116968, + -0.012046709656715393, + -0.0039065442979335785, + -0.07532317191362381, + -0.013112464919686317, + 0.003570280037820339, + 0.02591622807085514, + 0.04118960350751877, + 0.046716831624507904, + 0.0013790505472570658, + -0.01370046753436327, + -0.07455876469612122, + 0.03178155794739723, + 0.02895914390683174, + 0.011605706997215748, + 0.010172449983656406, + -0.027959538623690605, + -0.02544582635164261, + -0.017360785976052284, + -0.006875958759337664, + -0.02741563506424427, + -0.008930293843150139, + 0.027048133313655853, + 0.00453864736482501, + -0.0209623035043478, + -0.0742647647857666, + 0.014582471922039986, + -0.004406346939504147, + -0.00652683200314641, + 0.00048693991266191006, + -0.0028830517549067736, + 0.004759148694574833, + -0.024534421041607857, + 0.03663258254528046, + -0.04818683862686157, + -0.018816092982888222, + 0.0018806905718520284, + 0.004549672361463308, + -0.011929108761250973, + 0.006159330252557993, + -0.0040351697243750095, + -0.031222954392433167, + 0.014237020164728165, + -0.017169684171676636, + -0.05791828781366348, + -0.06797313690185547, + -0.019918598234653473, + 0.01466332282871008, + -0.04224800691008568, + -0.0076293377205729485, + -0.015493876300752163, + -0.023784717544913292, + 0.005016399547457695, + -0.024754922837018967, + 0.017316685989499092, + -0.035515375435352325, + 0.0095109473913908, + -0.014369321055710316, + -0.09225765615701675, + -0.01424437016248703, + 0.04633462801575661, + -0.017419585958123207, + -0.01218636054545641, + 0.021756106987595558, + 0.004568047355860472, + -0.06250470876693726, + -0.03366316482424736, + -0.051450252532958984, + 0.07173635065555573, + 0.0010703490115702152, + 0.005835928954184055, + 0.025798628106713295, + -0.0375145860016346, + -0.0009986861841753125, + 0.0051781004294753075, + 0.07050155103206635, + -0.00512665044516325, + 0.007923339493572712, + 0.05371406674385071, + -0.013185964897274971, + -0.0077469381503760815, + -0.0015150262042880058, + -0.008570142090320587, + -0.026033828034996986, + 0.004303446039557457, + -0.030091049149632454, + 0.0119658587500453, + 0.015611477196216583, + -0.0037264684215188026, + -0.006670157890766859, + 0.043071214109659195, + -0.002585375215858221, + -0.005159725435078144, + 0.00894499383866787, + 0.05121505260467529, + 0.0029675771947950125, + 0.016125978901982307, + 0.0023464991245418787, + 0.10260650515556335, + 0.022549910470843315, + 0.029473645612597466, + 0.00970939826220274, + -0.010848653502762318, + 0.08096799999475479, + -0.04959804564714432, + 0.02371121756732464, + -0.07920399308204651, + 0.027739036828279495, + 0.0026496881619095802, + 0.0036750182043761015, + 0.05927069112658501, + -9.824931476032361e-05, + 0.020374299958348274, + 0.03283996134996414, + -0.026004428043961525, + 0.013671067543327808, + -0.01662578247487545, + 0.021418005228042603, + -0.06791433691978455, + 0.01896309293806553, + -0.019712796434760094, + -0.03945499658584595, + -0.03910219296813011, + 0.006394531577825546, + 0.032516561448574066, + 0.007210385520011187, + 0.02135920524597168, + 0.0004628225869964808, + -0.02569572627544403, + -0.02571042627096176, + 0.03000284731388092, + -0.007607287727296352, + 0.052567459642887115, + 0.0735003650188446, + -0.031164154410362244, + -0.0024457245599478483, + 0.0742647647857666, + 0.06344551593065262, + -0.04213040694594383, + 0.00016238987154792994, + 0.014972023665904999, + -0.0209623035043478, + -0.002914289478212595, + 0.002976764691993594, + 0.03178155794739723, + -0.006166680250316858, + -0.0037411684170365334, + -0.01768418774008751, + -0.004138070624321699, + 0.02246171049773693, + 0.0032450410071760416, + -0.034839171916246414, + -0.004641547799110413, + -0.006074804812669754, + 0.013303565792739391, + 0.018639691174030304, + 0.02738623507320881, + -0.005233225878328085, + 0.04621702805161476, + -0.030987752601504326, + 0.03689718246459961, + -0.009951949119567871, + 0.00426669605076313, + 0.020565401762723923, + 0.020638901740312576, + 0.005538252182304859, + -0.0027360511012375355, + 0.021873708814382553, + -0.0013533254386857152, + 0.014369321055710316, + 0.0500684455037117, + -0.00021659638150595129, + 0.010143049992620945, + 0.00035716581624001265, + -0.008452542126178741, + 0.021506207063794136, + 0.0025614877231419086, + -0.012237810529768467, + 0.0004632819618564099, + -0.009283095598220825, + -0.01165715791285038, + 0.02762143686413765, + -0.037867385894060135, + 0.02657773159444332, + -0.0018025963800027966, + 0.06250470876693726, + -0.00196797214448452, + 0.002647850662469864, + 0.016125978901982307, + -0.007599937729537487, + 0.021418005228042603, + -0.03307516500353813, + 0.02115340530872345, + 0.006159330252557993, + -0.008158540353178978, + -0.04421781748533249, + 0.015934878960251808, + 0.033133964985609055, + 0.012318660505115986, + 0.03131115436553955, + 0.005402276758104563, + 0.00962119735777378, + 0.02005089819431305, + -0.0003475189150776714, + -0.004149095620959997, + -0.006648107897490263, + -0.03360436484217644, + 0.004777523688971996, + -0.012090809643268585, + 0.014567771926522255, + 0.014817672781646252, + 0.002030447591096163, + -0.014090019278228283, + -0.04071919992566109, + 0.012039359658956528, + -0.004042520187795162, + 0.021903108805418015, + 0.011833558790385723, + 0.007452936843037605, + -0.0196686964482069, + 0.009577097371220589, + -0.025798628106713295, + -0.0004687944892793894, + 0.05065644904971123, + -0.018463291227817535, + 0.00022348704806063324, + -0.017007984220981598, + 0.010672252625226974, + -0.02806243859231472, + 0.04950984567403793, + -0.01794878952205181, + 0.022314710542559624, + -0.0037062556948512793, + 0.009224295616149902, + 0.03910219296813011, + 0.005681578069925308, + -0.030576150864362717, + 0.013685767538845539, + 0.027474435046315193, + 0.0019054969307035208, + 0.00907729472965002, + -0.030135149136185646, + 0.056007277220487595, + -0.019301194697618484, + 0.03295756131410599, + 0.0008659261511638761, + 0.01090745348483324, + -0.04624642804265022, + -0.012517111375927925, + 0.04809863865375519, + -0.015155774541199207, + 0.02765083685517311, + 0.010944204404950142, + -0.042189206928014755, + 0.013641667552292347, + -0.008246740326285362, + -0.057300884276628494, + 0.02182960696518421, + 0.05012724921107292, + -0.02028609998524189, + 0.006515807006508112, + 0.09319846332073212, + -0.0019661346450448036, + -0.0142296701669693, + -0.008937643840909004, + -0.019771598279476166, + -0.029267843812704086, + -0.011738007888197899, + 0.014207620173692703, + -0.025813328102231026, + 0.012377461418509483, + 0.005949854385107756, + 0.014604521915316582, + -0.004718723241239786, + 0.01769888773560524, + 0.021506207063794136, + -0.0172725860029459, + -0.0644451156258583, + 0.000543443311471492, + -0.018463291227817535, + 0.0009665297693572938, + -0.008437841199338436, + 0.04030760005116463, + -0.015978978946805, + 0.0016721332212910056, + 0.012737613171339035, + -0.012215760536491871, + -0.04621702805161476, + 0.06550352275371552, + 0.01424437016248703, + -0.041101403534412384, + -0.0015949578955769539, + -0.0012761499965563416, + 0.00680245878174901, + -0.02177080698311329, + 0.02157970704138279, + -0.028121238574385643, + 0.006967834196984768, + 0.03904339298605919, + -0.0044798469170928, + -0.0174636859446764, + 0.11030934751033783, + -0.0419246070086956, + 0.010811903513967991, + -0.02438742108643055, + -0.021476805210113525, + 0.06297510862350464, + -0.0011861120583489537, + 0.00865099299699068, + -0.010760453529655933, + 0.03845538944005966, + -0.004027819726616144, + 0.007254485972225666, + 0.03425116837024689, + 0.000848469790071249, + 0.06373951584100723, + 0.005894728936254978, + 0.005376551765948534, + -0.0012577750021591783, + -0.011899708770215511, + -0.01680218242108822, + 0.01897779293358326, + 0.014913223683834076, + -0.004351221490651369, + 0.0016473268624395132, + 0.0371323823928833, + -0.019139494746923447, + -0.026621831580996513, + 0.027724336832761765, + -0.022520510479807854, + 0.057065680623054504, + -0.01282581314444542, + 0.07155995070934296, + -0.013796018436551094, + 0.03460397198796272, + -0.007192010525614023, + -0.0032321785110980272, + -0.03063495084643364, + -0.04295361042022705, + 0.009996049106121063, + 0.004545997362583876, + -0.06550352275371552, + -0.019727498292922974, + 0.01856619119644165, + 0.03304576501250267, + -0.03087015263736248, + 0.02763613685965538, + -0.00040080666076391935, + 0.07914519309997559, + 0.0052993763238191605, + -0.04706963151693344, + 0.01391361840069294, + -0.007265510968863964, + -0.005946179386228323, + -0.03001754730939865, + -0.029062043875455856, + 0.08631882816553116, + 0.01163510698825121, + 0.02718043327331543, + 0.0055603026412427425, + -0.027592036873102188, + -0.020139100030064583, + 0.007967439480125904, + 0.018654393032193184, + 0.008562792092561722, + -0.008349641226232052, + -0.025195924565196037, + -0.053184863179922104, + 0.0336337648332119, + -0.04509982094168663, + -0.02675413154065609, + 0.028753342106938362, + -0.005799178499728441, + -0.011003004387021065, + 0.026166129857301712, + 0.016522882506251335, + 0.011929108761250973, + -0.026210229843854904, + -0.018198689445853233, + 0.004509247373789549, + 0.026019128039479256, + 0.012649412266910076, + -0.003950644284486771, + 0.025137124583125114, + -0.020374299958348274, + 0.014104719273746014, + -0.04595242813229561, + -0.002906939247623086, + 0.015214575454592705, + 0.07826318591833115, + -0.009422746486961842, + -0.05932949110865593, + 0.07126595079898834, + 0.03307516500353813, + 0.043747417628765106, + -0.031840357929468155, + -0.0011567119508981705, + -0.018727893009781837, + -0.03201675787568092, + -0.017110884189605713, + -0.010973604395985603, + -0.0042740460485219955, + 0.012524462305009365, + -0.03175215795636177, + 0.002971252193674445, + 0.01684628240764141, + -0.016758082434535027, + -0.029899947345256805, + 0.004733423236757517, + 0.05885909125208855, + 0.010216550901532173, + -0.006030704826116562, + -0.01489117369055748, + 0.03469217196106911, + 0.04210100695490837, + -0.004178495611995459, + -0.030135149136185646, + 0.010304750874638557, + -0.004270371049642563, + -0.002925314474850893, + -0.013560816645622253, + -0.025578126311302185, + -0.0079894894734025, + -0.01963929645717144, + -0.014112069271504879, + 0.049068842083215714, + 0.005755078513175249, + 0.03586817532777786, + -0.03216375783085823, + 0.04189520701766014, + 0.07838078588247299, + -0.009518297389149666, + -0.012480361387133598, + 0.01944819651544094, + -0.03451577201485634, + -0.02547522634267807, + 0.024255119264125824, + -0.005755078513175249, + 0.020550701767206192, + -0.03301636129617691, + -0.0239317175000906, + 0.00906259473413229, + 0.009518297389149666, + -0.025519326329231262, + 0.03460397198796272, + -0.0004455959424376488, + -0.016699282452464104, + -0.011157355271279812, + 0.034221768379211426, + 0.04365921393036842, + -0.00841579120606184, + 0.002664388157427311, + 0.018507391214370728, + 0.0014690884854644537, + -0.00981964822858572, + 0.011686557903885841, + 0.024064019322395325, + 0.0001028430851874873, + 0.00013700926501769572, + -0.025813328102231026, + -0.0833200141787529, + 0.06350431591272354, + -0.02591622807085514, + -0.03345736488699913, + -0.005909429397433996, + -0.03369256481528282, + -0.02571042627096176, + -0.011502807028591633, + 0.01985979825258255, + -0.009555047377943993, + 0.015493876300752163, + 0.031840357929468155, + -0.008408441208302975, + -0.003439816879108548, + 0.02528412453830242, + -0.007519087288528681, + 0.06321030855178833, + -0.003658480476588011, + -0.012112859636545181, + -0.011319056153297424, + 0.027018733322620392, + 0.016537582501769066, + -0.040895603597164154, + 0.024563821032643318, + -0.0029510394670069218, + 0.01815458945930004, + -0.019756898283958435, + -0.01962459646165371, + 0.0358387753367424, + 0.048921842128038406, + 0.04033700004220009, + 0.02672473154962063, + 0.021315105259418488, + 0.061387501657009125, + -0.008151190355420113, + -0.03472157195210457, + 0.006409231573343277, + 0.0015637201722711325, + -0.054919470101594925, + 0.029032643884420395, + -0.009988699108362198, + 0.019168894737958908, + 0.005350826308131218, + -0.015846678987145424, + 0.032928161323070526, + 0.02134450525045395, + -0.031575754284858704, + 0.03604457899928093, + -0.01621418073773384, + -0.04512922465801239, + -0.01686098240315914, + 0.008327591232955456, + 0.007585237268358469, + -0.05991749465465546, + 0.013002214021980762, + 0.018669093027710915, + -0.006409231573343277, + -0.0005985685857012868, + -0.021285705268383026, + 0.06215190514922142, + 0.005152375437319279, + 0.0013165752170607448, + -0.003654805477708578, + -0.015346875414252281, + -0.03866118937730789, + -0.01946289651095867, + -0.03736758604645729, + -0.009657947346568108, + 0.005251600872725248, + 0.007353711407631636, + 0.0388081930577755, + -0.011730657890439034, + -0.06850233674049377, + 0.023417215794324875, + 0.024255119264125824, + -0.00358681776560843, + -0.03283996134996414, + -0.07708717882633209, + 0.0077469381503760815, + 0.0025780252180993557, + 0.032722361385822296, + -0.024284519255161285, + -0.020550701767206192, + -0.018272189423441887, + -0.06115230172872543, + 0.013002214021980762, + -0.024284519255161285, + 0.020330199971795082, + -0.04430601745843887, + -0.00432549649849534, + -0.06450391560792923, + -0.007379436399787664, + 0.028106538578867912, + 0.03525077551603317, + -0.012634712271392345, + -0.025137124583125114, + -0.020388999953866005, + 0.031193554401397705, + -0.003627242986112833, + 0.008151190355420113, + 0.00810709036886692, + -0.0102533008903265, + -0.005714653059840202, + -0.006251205690205097, + 0.0020010473672300577, + -0.08620122820138931, + 0.0021792857442051172, + 0.002517387503758073, + 0.02632782980799675, + 0.08302600681781769, + 0.004759148694574833, + 0.015258675441145897, + -0.008695092983543873, + 0.061387501657009125, + -0.04704023152589798, + 0.00010112042218679562, + 0.011510157026350498, + -0.01123820524662733, + -0.014861773699522018, + -0.036338578909635544, + 0.021256305277347565, + 0.05330246314406395, + 0.011495457030832767 + ], + "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\ThingOwner.txt\n\npublic class ThingOwner : ThingOwner, IList, ICollection, IEnumerable, IEnumerable where T : Thing\n{\n\tprivate List innerList = new List();\n\n\tpublic List InnerListForReading => innerList;\n\n\tpublic new T this[int index] => innerList[index];\n\n\tpublic override int Count => innerList.Count;\n\n\tT IList.this[int index]\n\t{\n\t\tget\n\t\t{\n\t\t\treturn innerList[index];\n\t\t}\n\t\tset\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow setting individual elements.\");\n\t\t}\n\t}\n\n\tbool ICollection.IsReadOnly => true;\n\n\tpublic ThingOwner()\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, bool oneStackOnly, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner, oneStackOnly, contentsLookMode, removeContentsIfDestroyed)\n\t{\n\t}\n\n\tpublic override void ExposeData()\n\t{\n\t\tbase.ExposeData();\n\t\tScribe_Collections.Look(ref innerList, \"innerList\", true, contentsLookMode);\n\t\tif (Scribe.mode == LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\tint num = innerList.RemoveAll((T x) => x == null || (x is MinifiedThing minifiedThing && minifiedThing.InnerThing == null));\n\t\t\tif (num > 0)\n\t\t\t{\n\t\t\t\tLog.Warning($\"ThingOwner removed {num} invalid entries during PostLoadInit.\");\n\t\t\t}\n\t\t}\n\t\tif (Scribe.mode != LoadSaveMode.LoadingVars && Scribe.mode != LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] != null)\n\t\t\t{\n\t\t\t\tinnerList[i].holdingOwner = this;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic List.Enumerator GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tpublic override int GetCountCanAccept(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (!(item is T))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn base.GetCountCanAccept(item, canMergeWithExistingStacks);\n\t}\n\n\tpublic override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (count <= 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item?.ToString() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + count + \" of \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tint stackCount = item.stackCount;\n\t\tint num = Mathf.Min(stackCount, count);\n\t\tThing thing = item.SplitOff(num);\n\t\tif (!TryAdd((T)thing, canMergeWithExistingStacks))\n\t\t{\n\t\t\tif (thing != item)\n\t\t\t{\n\t\t\t\tint result = stackCount - item.stackCount - thing.stackCount;\n\t\t\t\titem.TryAbsorbStack(thing, respectStackLimit: false);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn stackCount - item.stackCount;\n\t\t}\n\t\tCompPushable compPushable = item.TryGetComp();\n\t\tif (compPushable != null && owner is Pawn pawn)\n\t\t{\n\t\t\tcompPushable.OnStartedCarrying(pawn);\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (canMergeWithExistingStacks)\n\t\t{\n\t\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t\t{\n\t\t\t\tT val = innerList[i];\n\t\t\t\tif (!val.CanStackWith(item))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint num = Mathf.Min(item.stackCount, val.def.stackLimit - val.stackCount);\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tThing other = item.SplitOff(num);\n\t\t\t\t\tint stackCount = val.stackCount;\n\t\t\t\t\tval.TryAbsorbStack(other, respectStackLimit: true);\n\t\t\t\t\tif (val.stackCount > stackCount)\n\t\t\t\t\t{\n\t\t\t\t\t\tNotifyAddedAndMergedWith(val, val.stackCount - stackCount);\n\t\t\t\t\t}\n\t\t\t\t\tif (item.Destroyed || item.stackCount == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Count >= maxStacks)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\titem.holdingOwner = this;\n\t\tinnerList.Add(item2);\n\t\tNotifyAdded(item2);\n\t\treturn true;\n\t}\n\n\tprotected override void NotifyAdded(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemAdded(item as T);\n\t\t}\n\t\tbase.NotifyAdded(item);\n\t}\n\n\tprotected override void NotifyRemoved(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemRemoved(item as T);\n\t\t}\n\t\tbase.NotifyRemoved(item);\n\t}\n\n\tpublic void TryAddRangeOrTransfer(IEnumerable things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false)\n\t{\n\t\tif (things == this)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (things is ThingOwner thingOwner)\n\t\t{\n\t\t\tthingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks);\n\t\t\tif (destroyLeftover)\n\t\t\t{\n\t\t\t\tthingOwner.ClearAndDestroyContents();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (things is IList list)\n\t\t{\n\t\t\tfor (int i = 0; i < list.Count; i++)\n\t\t\t{\n\t\t\t\tif (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t\t{\n\t\t\t\t\tlist[i].Destroy();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tforeach (T thing in things)\n\t\t{\n\t\t\tif (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t{\n\t\t\t\tthing.Destroy();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int IndexOf(Thing item)\n\t{\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn -1;\n\t\t}\n\t\treturn innerList.IndexOf(item2);\n\t}\n\n\tpublic override bool Remove(Thing item)\n\t{\n\t\tif (!Contains(item))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner == this)\n\t\t{\n\t\t\titem.holdingOwner = null;\n\t\t}\n\t\tint index = innerList.LastIndexOf((T)item);\n\t\tinnerList.RemoveAt(index);\n\t\tNotifyRemoved(item);\n\t\treturn true;\n\t}\n\n\tpublic int RemoveAll(Predicate predicate)\n\t{\n\t\tint num = 0;\n\t\tfor (int num2 = innerList.Count - 1; num2 >= 0; num2--)\n\t\t{\n\t\t\tif (predicate(innerList[num2]))\n\t\t\t{\n\t\t\t\tRemove(innerList[num2]);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t\treturn num;\n\t}\n\n\tprotected override Thing GetAt(int index)\n\t{\n\t\treturn innerList[index];\n\t}\n\n\tpublic void GetThingsOfType(List list) where J : Thing\n\t{\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] is J item)\n\t\t\t{\n\t\t\t\tlist.Add(item);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true)\n\t{\n\t\tThing resultingTransferredItem2;\n\t\tint result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks);\n\t\tresultingTransferredItem = (T)resultingTransferredItem2;\n\t\treturn result;\n\t}\n\n\tpublic new T Take(Thing thing, int count)\n\t{\n\t\treturn (T)base.Take(thing, count);\n\t}\n\n\tpublic new T Take(Thing thing)\n\t{\n\t\treturn (T)base.Take(thing);\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out T resultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing resultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, count, out resultingThing2, placedAction2, nearPlaceValidator);\n\t\tresultingThing = (T)resultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, mode, out lastResultingThing2, placedAction2, nearPlaceValidator);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, out lastResultingThing2, placedAction2, nearPlaceValidator, playDropSound: true);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tint IList.IndexOf(T item)\n\t{\n\t\treturn innerList.IndexOf(item);\n\t}\n\n\tvoid IList.Insert(int index, T item)\n\t{\n\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow inserting individual elements at any position.\");\n\t}\n\n\tvoid ICollection.Add(T item)\n\t{\n\t\tTryAdd(item);\n\t}\n\n\tvoid ICollection.CopyTo(T[] array, int arrayIndex)\n\t{\n\t\tinnerList.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection.Contains(T item)\n\t{\n\t\treturn innerList.Contains(item);\n\t}\n\n\tbool ICollection.Remove(T item)\n\t{\n\t\treturn Remove(item);\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n}\n\n", + "timestamp": "2025-08-24 20:52:47,868" + }, + "IThingHolder-ThingOwner-virtual methods": { + "keywords": [ + "ThingOwner", + "IThingHolder", + "virtual methods" + ], + "question": "public class ThingOwner : IThingHolder virtual methods", + "embedding": [ + 0.0014595270622521639, + 0.0027306692209094763, + 0.040208324790000916, + 0.010125240311026573, + -0.06315106898546219, + 0.01258339174091816, + 0.016694942489266396, + 0.05387447401881218, + 0.012312701903283596, + 0.09405353665351868, + -0.051387060433626175, + -0.04582695662975311, + -0.01600724458694458, + -0.02946854755282402, + 0.06917939335107803, + -0.017587484791874886, + 0.015012279152870178, + -0.08732288330793381, + -0.03616993501782417, + -0.011486003175377846, + 0.03924262523651123, + 0.06478983163833618, + -0.010205715894699097, + 0.04246162995696068, + 0.019665207713842392, + -0.02184535376727581, + 0.02374749444425106, + 0.061570826917886734, + -0.04240310192108154, + -0.016065772622823715, + 0.0027270112186670303, + 0.018231285735964775, + -0.01777769811451435, + 0.004466372542083263, + 0.006317301653325558, + 0.020148057490587234, + -0.06227315589785576, + -0.0003463633474893868, + -0.0028294341173022985, + -0.013132086023688316, + -0.021128391847014427, + -0.0050443303771317005, + -0.03991568833589554, + 0.025942271575331688, + -0.02516678348183632, + 0.00871326681226492, + 0.017953280359506607, + -0.04614885523915291, + -0.03254123404622078, + 0.08129455894231796, + -0.012927239760756493, + 0.012854080647230148, + 0.002642878098413348, + -0.007034262176603079, + 0.006178298965096474, + 0.02832726202905178, + 0.022035567089915276, + -0.020996706560254097, + -0.016621781513094902, + 0.02336706593632698, + 0.00079011992784217, + 0.019094565883278847, + -0.03570171445608139, + -0.029044223949313164, + 0.07450538128614426, + 0.022664736956357956, + 0.011412843130528927, + 0.006031980272382498, + 0.02172829769551754, + -0.019767630845308304, + -0.014375792816281319, + 0.026761654764413834, + -0.03482380509376526, + 0.021303974092006683, + -0.01650472730398178, + 0.04088139161467552, + -0.00806214939802885, + 0.013139401562511921, + -0.023191483691334724, + -0.014551375061273575, + -0.00603929627686739, + 0.009130274876952171, + 0.007443954236805439, + 0.009444859810173512, + 0.08738141506910324, + -0.0059844269417226315, + 0.019489625468850136, + -0.08199688792228699, + -0.003321430180221796, + 0.0681258961558342, + -0.020806491374969482, + 0.007103763520717621, + 0.01954815164208412, + -0.0027434718795120716, + -0.01270044595003128, + 0.1193959042429924, + -0.06683829426765442, + -0.005413784645497799, + -0.019723733887076378, + 0.018070336431264877, + -0.02364507131278515, + -0.042988378554582596, + -0.008976640179753304, + 0.05896635726094246, + 0.01840686798095703, + 0.030404984951019287, + -0.03327282890677452, + -0.0052089388482272625, + -0.015275652520358562, + 0.019870053976774216, + 0.012115172110497952, + -0.01894824579358101, + 0.025854479521512985, + 0.029644129797816277, + -0.05759096518158913, + 0.025854479521512985, + -0.018245916813611984, + -0.019123828038573265, + 0.014624535106122494, + 0.011105574667453766, + 0.04652928560972214, + -0.022313572466373444, + 0.016329145058989525, + -0.008245048113167286, + -0.033858101814985275, + 0.015275652520358562, + 0.016051139682531357, + 0.02412792108952999, + -0.01613893173635006, + -0.03163406252861023, + -0.06174641102552414, + 0.018743401393294334, + -0.020777227357029915, + -0.03795501962304115, + 0.016036508604884148, + -0.004499293863773346, + 0.04155445471405983, + 0.012971135787665844, + -0.09171243757009506, + 0.02250378578901291, + -0.019533520564436913, + 0.013878310099244118, + -0.030843941494822502, + -0.00794509518891573, + 0.06876970082521439, + -0.0012290754821151495, + -0.04664634168148041, + -0.046324439346790314, + -0.0130223473533988, + -0.0003241869271732867, + -0.020235849544405937, + 0.002410597400739789, + -0.0196798387914896, + 0.05103589594364166, + 0.023191483691334724, + -0.009474122896790504, + 0.028371158987283707, + -0.03596508875489235, + -0.011156786233186722, + -0.02095280960202217, + -0.002304516499862075, + 0.026088589802384377, + -0.0633266493678093, + 0.008215784095227718, + 0.015041542239487171, + -0.05530839413404465, + 0.004455398302525282, + 0.05261613428592682, + 0.01180790364742279, + 0.02311832457780838, + 0.021903879940509796, + -0.0009913078974932432, + 0.023454856127500534, + 0.034472640603780746, + 0.003268389729782939, + -0.010754410177469254, + 0.04635370150208473, + 0.07298366725444794, + 0.01751432567834854, + -0.029702655971050262, + 0.03611140698194504, + 0.010103292763233185, + 0.07228134572505951, + -0.00314584793522954, + 0.002401452511548996, + -0.021245447918772697, + -0.011376263573765755, + 0.014156315475702286, + 0.013402774930000305, + 0.017967913299798965, + -0.02161124348640442, + -0.0028495530132204294, + 0.01188837829977274, + 0.04310543090105057, + -0.00871326681226492, + -0.029058855026960373, + -0.03453116863965988, + 0.018977509811520576, + -0.08480620384216309, + -0.0002622301981318742, + 0.03403368592262268, + 0.04494904354214668, + -0.007520771119743586, + 3.7751316995127127e-05, + 0.052791718393564224, + -0.038569558411836624, + 0.0383647121489048, + -0.026205644011497498, + 0.0020265113562345505, + 0.010037449188530445, + 0.04813878983259201, + -0.01764601096510887, + 0.004707797896116972, + -0.04535873606801033, + -0.06356076151132584, + -0.01701684296131134, + -0.05873224884271622, + 0.020616278052330017, + 0.029761184006929398, + -0.033858101814985275, + -0.010352034121751785, + 0.028166312724351883, + 0.00972286518663168, + 0.04626591131091118, + 0.03160479664802551, + -0.011778639629483223, + 0.00654043722897768, + 0.028897905722260475, + 0.008874217048287392, + -0.023015901446342468, + -0.010117924772202969, + 0.011734744533896446, + -0.04252015799283981, + -0.0011156785767525434, + 0.031224370002746582, + -0.015787767246365547, + 0.004535873886197805, + -0.03192669898271561, + 0.012663866393268108, + 0.032102279365062714, + -0.029175909236073494, + 0.03979863226413727, + 0.0044151609763503075, + 0.03833544999361038, + -0.0014458097284659743, + 0.007059867959469557, + -0.07438832521438599, + 0.007217160426080227, + 0.05334772914648056, + -0.036023616790771484, + 0.01404657680541277, + 0.04114476218819618, + -0.04304690286517143, + -0.0039030462503433228, + -0.004129840061068535, + 0.03532128781080246, + -0.015041542239487171, + 0.0022331862710416317, + -0.002408768516033888, + -0.017719171941280365, + -0.039447467774152756, + -0.0038115971256047487, + 0.0035518817603588104, + -0.016592519357800484, + -0.03815986588597298, + 0.031165841966867447, + 0.04143740236759186, + 0.02513751946389675, + -0.07608561962842941, + -0.05665452405810356, + -0.017748434096574783, + 0.03760385513305664, + 0.026907972991466522, + -0.025122888386249542, + -0.05606925114989281, + 0.00048559452989138663, + 0.024844883009791374, + 0.030902467668056488, + -0.07907052338123322, + 0.011646953411400318, + -0.010183768346905708, + 0.01403926033526659, + -0.036667417734861374, + -0.021772194653749466, + -0.02363043837249279, + 0.008230416104197502, + 0.024347400292754173, + -0.03760385513305664, + 0.000373112183297053, + -0.02771272510290146, + 0.036404043436050415, + 0.021289343014359474, + 0.00037128321127966046, + -0.01932867430150509, + -0.018465396016836166, + 0.04992387443780899, + -0.016548622399568558, + -0.0061417194083333015, + -0.02032363973557949, + 0.017119266092777252, + -0.02121618390083313, + -0.002280739601701498, + 0.008420630358159542, + -0.018084967508912086, + 0.044539354741573334, + 0.007352504879236221, + -0.007630510255694389, + -0.10646134614944458, + -0.001123909023590386, + -0.09218066185712814, + -0.025503315031528473, + -0.0020027344580739737, + -0.0719301775097847, + -0.018860455602407455, + -0.0020301693584769964, + -0.007586614694446325, + -0.029892871156334877, + -0.01282481662929058, + 0.0004675333620980382, + 0.04688045009970665, + 0.0059771109372377396, + -0.0073890844359993935, + 0.038920722901821136, + 0.033331356942653656, + -0.02225504443049431, + 0.0021234473679214716, + 0.027771253138780594, + 0.010271559469401836, + -0.014631850644946098, + 0.022079462185502052, + -0.028941800817847252, + 0.0067343092523515224, + 0.029190542176365852, + 0.021157655864953995, + -0.03239491581916809, + 0.008413313888013363, + 0.02603006176650524, + -0.018275180831551552, + 0.02440592646598816, + 0.016621781513094902, + -0.010125240311026573, + -0.044012606143951416, + 0.010578827932476997, + 0.020426062867045403, + 0.007586614694446325, + -0.026205644011497498, + 0.0066648079082369804, + 0.03549686819314957, + 0.0497775562107563, + 0.016841260716319084, + 0.004660244565457106, + 0.004331027623265982, + -0.03371178358793259, + 0.024698564782738686, + -0.02109912782907486, + -0.01354177761822939, + 0.0028477238956838846, + 0.00818652007728815, + -0.05121147632598877, + 0.0066830976866185665, + -0.006174641195684671, + 0.015582920983433723, + 0.02857600338757038, + 0.02781514823436737, + 0.06385339796543121, + 0.005424758419394493, + -0.019094565883278847, + 0.06496541947126389, + -0.004060338716953993, + -0.005940531380474567, + 0.012993083335459232, + -0.04003274440765381, + 0.004927275702357292, + 0.006606280338019133, + -0.005808844696730375, + 0.018362972885370255, + 0.025356996804475784, + 0.004960197489708662, + 0.0028257761150598526, + 0.05928825959563255, + 0.08948840200901031, + -0.0021014995872974396, + -0.008640107698738575, + -0.0335654653608799, + -0.04404187202453613, + -0.012495600618422031, + 0.0006273405742831528, + -0.004290790297091007, + 0.019460361450910568, + -0.06279990077018738, + 0.003844518680125475, + 0.017485061660408974, + -0.0317511148750782, + -0.013907574117183685, + 0.043661441653966904, + 0.01880192756652832, + 0.006551411002874374, + 0.0454757921397686, + -0.010527616366744041, + 0.011193365789949894, + -0.012181015685200691, + -0.014148999936878681, + -0.02387917973101139, + -0.00894737709313631, + -0.005739343352615833, + -0.018714137375354767, + 0.040471699088811874, + 0.018728768453001976, + -0.022664736956357956, + 0.039681579917669296, + -0.06139524653553963, + 0.038452502340078354, + 0.07649531215429306, + -0.020235849544405937, + -0.04240310192108154, + -0.007681721355766058, + 0.006858679931610823, + -0.01981152594089508, + 0.031224370002746582, + -0.09305857121944427, + -0.006833074148744345, + 0.05311361700296402, + 0.0029464890249073505, + 0.013293036259710789, + 0.012971135787665844, + 0.0006108797388151288, + -0.014156315475702286, + -0.014273370616137981, + -0.0158755574375391, + -0.007085473742336035, + -0.03745753690600395, + -0.010747094638645649, + -0.016168195754289627, + 0.06139524653553963, + 0.0018820217810571194, + -0.030141612514853477, + 0.0151293333619833, + 0.00319340149872005, + -0.026015430688858032, + -0.003862808458507061, + -0.05961015820503235, + -0.022459890693426132, + 0.011610373854637146, + -0.014119735918939114, + -0.07438832521438599, + 0.0014622706221416593, + 0.03643330931663513, + -0.006745283026248217, + 0.02121618390083313, + 0.0001646083255764097, + -0.023410961031913757, + 0.02860526740550995, + 0.007385426666587591, + 0.02415718510746956, + 0.028107784688472748, + 0.02440592646598816, + -0.02935149148106575, + 0.0009163196664303541, + -0.038423240184783936, + -0.0008170974324457347, + 0.010600775480270386, + -0.05246981605887413, + 0.0044151609763503075, + -0.010520300827920437, + -0.013892942108213902, + -0.04307616874575615, + -0.026644600555300713, + 0.010827569290995598, + -0.022430626675486565, + -0.0472901426255703, + 0.00019318614795338362, + -0.021903879940509796, + -0.004316396079957485, + -0.031253632158041, + 0.0050187245942652225, + 0.00940096378326416, + -0.014119735918939114, + 0.0026794576551765203, + 0.016929050907492638, + 0.05606925114989281, + 0.0007073585293255746, + 0.010827569290995598, + -0.02275252714753151, + 0.021025968715548515, + -0.07187165319919586, + -0.009481439366936684, + -0.046061065047979355, + -0.018084967508912086, + 0.006306327413767576, + -0.0262934360653162, + 0.0011376263573765755, + -0.05399153009057045, + -0.007074499968439341, + 0.010205715894699097, + 0.002551428973674774, + 0.0065697007812559605, + 0.0018445276655256748, + 0.07550034672021866, + -0.009708233177661896, + -0.1126067191362381, + -0.010783674195408821, + 0.021552715450525284, + -0.01575850322842598, + -0.014463583938777447, + 0.04061801731586456, + -0.0001903283700812608, + -0.05943457782268524, + 0.014785485342144966, + -0.031107313930988312, + 0.03312651067972183, + 0.010469089262187481, + 0.024449821561574936, + 0.029058855026960373, + -0.034501902759075165, + -0.0232353787869215, + 0.0030269641429185867, + 0.0767294242978096, + -0.0036762524396181107, + 0.01586092635989189, + -0.003127558156847954, + 0.0003715118218678981, + -0.022459890693426132, + 0.0158755574375391, + -0.019635943695902824, + -0.02999529428780079, + 0.03470674902200699, + 0.005823476705700159, + 0.011595741845667362, + 0.023703597486019135, + -0.04079360142350197, + -0.020557750016450882, + -0.001602187636308372, + -0.005903951823711395, + -0.007974358275532722, + 0.020235849544405937, + 0.015831662341952324, + 0.037925757467746735, + 0.01212248858064413, + 0.02796146646142006, + 0.11336757987737656, + 0.08410387486219406, + 0.032716818153858185, + 0.010651987046003342, + 0.06127819046378136, + 0.03508717939257622, + 0.011251892894506454, + 0.041612982749938965, + -0.04240310192108154, + 0.005475969985127449, + -0.009935026988387108, + -0.010842201299965382, + 0.023030532523989677, + -0.021625874564051628, + 0.0030214772559702396, + 0.023937707766890526, + -0.03535054996609688, + -0.025225309655070305, + 0.011500634253025055, + 0.03063909523189068, + -0.06110261008143425, + 0.00908637885004282, + -0.00311292614787817, + -0.05794212967157364, + -0.053669627755880356, + -0.016329145058989525, + 0.010688566602766514, + 0.010044765658676624, + 0.008237731643021107, + 0.07315925508737564, + 0.018567819148302078, + -0.05206012353301048, + 0.0002437117655063048, + -0.03558466210961342, + 0.0459732748568058, + 0.02212335728108883, + 0.005249176640063524, + 0.007092789746820927, + 0.017177792266011238, + 0.08328449726104736, + -0.016168195754289627, + -0.021655138581991196, + 0.03318503871560097, + 0.0026812865398824215, + -0.012400493025779724, + 0.01187374722212553, + 0.04284206032752991, + 0.029892871156334877, + -0.010110609233379364, + 0.054693859070539474, + 0.019431097432971, + 0.027551773935556412, + -0.030551305040717125, + -0.050626203417778015, + 0.00244534807279706, + 0.005695447791367769, + 0.03696005418896675, + 0.008157256990671158, + 0.023688966408371925, + 0.01701684296131134, + 0.007842672057449818, + -0.014200211502611637, + -0.003892072243615985, + -0.010125240311026573, + 0.014997647143900394, + 0.043778497725725174, + 0.005636920686811209, + 0.015612185001373291, + 0.010388613678514957, + 0.00806214939802885, + 0.0022514760494232178, + 0.018758032470941544, + 0.03783796727657318, + -0.027990730479359627, + 0.006858679931610823, + 0.008149940520524979, + -0.005468653980642557, + 0.008786425925791264, + -0.02033827267587185, + -0.029410019516944885, + -0.0037201480008661747, + -0.011193365789949894, + -0.010637355037033558, + 0.008596212603151798, + -0.05033356696367264, + 0.006017348729074001, + 0.01022034790366888, + 0.019401833415031433, + -0.003034279914572835, + -0.01105436310172081, + -0.029146647080779076, + -0.01651936024427414, + 0.00616366695612669, + -0.03748680278658867, + 0.009093695320189, + -0.0012089567026123405, + -0.047582779079675674, + -0.01726558431982994, + 0.0303464587777853, + -0.0005683559575118124, + -0.06519952416419983, + -0.003892072243615985, + 0.023089060559868813, + 0.010198400355875492, + -0.016607150435447693, + -0.019782261922955513, + 0.0009364384459331632, + -0.05554250627756119, + -0.034004420042037964, + -0.007381768431514502, + 0.006935497280210257, + -0.046324439346790314, + 0.03693079203367233, + 0.006536779459565878, + 0.006309985648840666, + -0.0036396728828549385, + 0.005622288677841425, + -0.0051394375041127205, + -0.0018481856677681208, + 0.020367536693811417, + -0.016665678471326828, + -0.03669667989015579, + -0.030053820461034775, + -0.027112819254398346, + -0.010286190547049046, + 0.030814677476882935, + 0.0013497882755473256, + -0.007067183963954449, + -0.05121147632598877, + 0.024084025993943214, + -0.0005633262335322797, + 0.014083156362175941, + -0.020396800711750984, + 0.01855318620800972, + -0.0009803340071812272, + 0.024947306141257286, + 0.0661359652876854, + -0.06765767931938171, + -0.04073507338762283, + 0.018611714243888855, + 0.08398682624101639, + -0.0017594799865037203, + 0.023015901446342468, + -0.017455797642469406, + 0.005786897148936987, + 0.015451233834028244, + 0.01689978688955307, + -0.028415054082870483, + 0.04784615337848663, + -0.06601890921592712, + 0.009978922083973885, + 0.05580587685108185, + 0.010147188790142536, + 0.06490688771009445, + 0.018772663548588753, + -0.06256579607725143, + -0.02020658552646637, + -0.019855421036481857, + -0.03213154524564743, + -0.010037449188530445, + 0.06116113439202309, + 0.020250480622053146, + -0.01830444484949112, + 0.04951418191194534, + -0.0016561426455155015, + 0.02237210050225258, + -0.021303974092006683, + -0.03201448917388916, + -0.06063438951969147, + -0.010366666130721569, + 0.008274311199784279, + 0.020923545584082603, + 0.03192669898271561, + -0.017060738056898117, + -0.0005459509557113051, + -0.016299881041049957, + -0.0073890844359993935, + 0.020660173147916794, + -0.03646257147192955, + -0.06707240641117096, + -0.0009318660013377666, + -0.02057238109409809, + -0.04322248697280884, + -0.005706421565264463, + 0.015407338738441467, + 0.0013900258345529437, + -0.036901526153087616, + 0.015070806257426739, + -0.016431568190455437, + -0.02351338416337967, + 0.07983137667179108, + -0.0006396862445399165, + -0.022269677370786667, + 0.006178298965096474, + -0.00470414012670517, + -0.015729239210486412, + -0.04620738327503204, + 0.025503315031528473, + -0.04875332489609718, + -0.025474052876234055, + -0.001649741199798882, + -0.0020009055733680725, + -0.016826627776026726, + 0.03757459297776222, + -0.04079360142350197, + 0.016665678471326828, + -0.024449821561574936, + -0.006551411002874374, + 0.05814697593450546, + -0.006686755921691656, + -0.013688095845282078, + 0.006372170988470316, + 0.019913949072360992, + 0.010256927460432053, + -0.03295092657208443, + 0.028502844274044037, + -0.019109196960926056, + 0.03382883965969086, + 0.03160479664802551, + -0.004941907711327076, + 0.03549686819314957, + 0.0010095976758748293, + -0.01448553241789341, + 0.026351962238550186, + 0.04208120331168175, + 0.008537684567272663, + 0.0021380791440606117, + -0.0027398141101002693, + 0.0092180659994483, + -0.00650751544162631, + -0.011361631564795971, + -0.01891898363828659, + 0.0009240928338840604, + -0.026644600555300713, + 0.053933002054691315, + 0.028371158987283707, + 0.04374923184514046, + -0.01919698715209961, + -0.02921980619430542, + -0.014090471900999546, + -0.03060983121395111, + 0.004989461041986942, + -0.009335121139883995, + -0.07830966264009476, + -0.005805186927318573, + 0.020894283428788185, + 0.04916301742196083, + -0.016095034778118134, + 0.056449681520462036, + 0.03049277700483799, + 0.02642512135207653, + 0.006862338166683912, + -0.029029591009020805, + 0.025605738162994385, + 0.0005610400112345815, + 0.007864619605243206, + 0.007001340389251709, + -0.0019149434519931674, + 0.11886915564537048, + 0.030404984951019287, + -0.0011705480283126235, + 0.04889964312314987, + -0.027551773935556412, + 0.05323067307472229, + -0.03300945460796356, + 0.02742008864879608, + 0.03994495049118996, + -0.0018399552209302783, + -0.02806388959288597, + -0.030463512986898422, + -0.003965231589972973, + 0.012919924221932888, + -0.019153092056512833, + -0.01676810160279274, + -0.009057115763425827, + -0.001569265965372324, + -0.03350693732500076, + 0.0335654653608799, + -0.0029044223483651876, + 0.004404187202453613, + -0.013263772241771221, + 0.04260794818401337, + 0.09779928624629974, + 0.028429685160517693, + 0.022298939526081085, + 0.03751606494188309, + -0.028868641704320908, + 0.02986360713839531, + -0.03254123404622078, + -0.022547682747244835, + 0.009861866943538189, + 0.03415073826909065, + 0.007480533793568611, + 0.004660244565457106, + 0.020001739263534546, + -0.006913549266755581, + -0.013322300277650356, + -0.021025968715548515, + 0.008230416104197502, + 0.009020536206662655, + 0.023937707766890526, + -0.005651552230119705, + 0.01865560933947563, + -0.0006808383041061461, + 0.002410597400739789, + -0.02389381267130375, + 0.017865490168333054, + 0.009269277565181255, + -0.005307703744620085, + -0.007261055987328291, + -0.017104633152484894, + -0.010037449188530445, + 0.05337699130177498, + -0.005121147725731134, + -0.003983521368354559, + -0.0027379849925637245, + 0.031341422349214554, + -0.013768571428954601, + 0.001310465158894658, + -0.015904821455478668, + -0.003906704019755125, + -0.02453761361539364, + 0.011800587177276611, + -9.752185178513173e-06, + 0.01589019037783146, + -0.018889719620347023, + -0.0015299428487196565, + -0.029058855026960373, + 0.007151316851377487, + -0.0021472240332514048, + -0.041086237877607346, + 0.050509147346019745, + 0.07023288309574127, + -0.005805186927318573, + 0.031575534492731094, + 0.004122524056583643, + 0.029702655971050262, + -0.028546741232275963, + 0.013797835446894169, + 0.004898012150079012, + 0.014778168871998787, + 0.01969447173178196, + -0.02592763863503933, + 0.02667386457324028, + -0.009166854433715343, + -0.040354643017053604, + 0.007096447516232729, + 0.007747564930468798, + -0.026761654764413834, + -0.019533520564436913, + 0.06022469699382782, + 0.02007489837706089, + -0.010110609233379364, + 0.016065772622823715, + 0.033477675169706345, + -0.023849915713071823, + -0.019767630845308304, + -0.014346529729664326, + 0.007359820883721113, + 0.027595670893788338, + -0.010227663442492485, + -0.013944153673946857, + -0.06086849793791771, + 0.006145377177745104, + -0.029395388439297676, + -0.036521099507808685, + 0.02857600338757038, + -0.0534062534570694, + -0.0022587920539081097, + -0.031107313930988312, + 0.04129108414053917, + -0.017938649281859398, + 0.01701684296131134, + 0.0224891547113657, + 0.0028495530132204294, + -0.03795501962304115, + 0.034238532185554504, + -0.0269518680870533, + 0.054196376353502274, + 0.012034697458148003, + -0.016051139682531357, + 0.05144558846950531, + 0.00457611121237278, + 0.010761725716292858, + -0.03549686819314957, + 0.007283003535121679, + 0.009254645556211472, + 0.036140672862529755, + 0.020265113562345505, + -0.005805186927318573, + 0.019284779205918312, + 0.0643216148018837, + 0.028883272781968117, + 0.023732861503958702, + -0.01232733391225338, + 0.011749375611543655, + -0.009057115763425827, + -0.0009048884967342019, + -0.02225504443049431, + 0.011412843130528927, + -0.019489625468850136, + 0.022811055183410645, + -0.027039660140872, + 0.00775488093495369, + -0.006156350951641798, + 0.020031003281474113, + 0.012063960544764996, + 0.0002841779787559062, + -0.04383702576160431, + 0.02986360713839531, + 0.02490340918302536, + -0.010856833308935165, + 0.00852305255830288, + -0.03151700645685196, + 0.012685814872384071, + -0.03391662985086441, + -0.015904821455478668, + 0.02566426619887352, + -0.020001739263534546, + 0.009291225112974644, + -0.027478614822030067, + 0.038540296256542206, + 0.023469489067792892, + 0.007180580869317055, + -0.013563725166022778, + -0.014712326228618622, + -0.024362031370401382, + -0.025503315031528473, + -0.04064727947115898, + 0.0028422370087355375, + 0.015919454395771027, + -0.043778497725725174, + 0.025444788858294487, + -0.010395930148661137, + -0.03611140698194504, + 0.016358409076929092, + -0.014873276464641094, + 0.00012619970948435366, + -0.03432632237672806, + -0.11916179209947586, + -0.0255472119897604, + 0.05653747171163559, + 0.012210279703140259, + -0.05276245251297951, + 0.041993413120508194, + -0.05785433575510979, + -0.037018582224845886, + 0.012473653070628643, + -0.003734779777005315, + -0.015158597379922867, + -0.06707240641117096, + -0.026600703597068787, + -0.060809969902038574, + -0.01174206007272005, + 0.04638296738266945, + 0.016929050907492638, + -0.016680309548974037, + -0.02543015591800213, + 0.002213067375123501, + 0.023586543276906013, + -0.00952533446252346, + -0.0013945982791483402, + 0.04611959308385849, + -0.04658781364560127, + 0.014500164426863194, + 0.009620442055165768, + 0.014500164426863194, + -0.06988172233104706, + -0.011500634253025055, + -0.0002711464767344296, + 0.024303503334522247, + 0.09235624223947525, + -0.008698634803295135, + 0.00768903736025095, + -0.041612982749938965, + 0.04445156082510948, + 0.0017018670914694667, + -0.005318677518516779, + -0.005289413966238499, + 0.01739726960659027, + -0.012415125034749508, + -0.05580587685108185, + 0.055835142731666565, + 0.017836226150393486, + 0.00952533446252346 + ], + "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\ThingOwner.txt\n\npublic class ThingOwner : ThingOwner, IList, ICollection, IEnumerable, IEnumerable where T : Thing\n{\n\tprivate List innerList = new List();\n\n\tpublic List InnerListForReading => innerList;\n\n\tpublic new T this[int index] => innerList[index];\n\n\tpublic override int Count => innerList.Count;\n\n\tT IList.this[int index]\n\t{\n\t\tget\n\t\t{\n\t\t\treturn innerList[index];\n\t\t}\n\t\tset\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow setting individual elements.\");\n\t\t}\n\t}\n\n\tbool ICollection.IsReadOnly => true;\n\n\tpublic ThingOwner()\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, bool oneStackOnly, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner, oneStackOnly, contentsLookMode, removeContentsIfDestroyed)\n\t{\n\t}\n\n\tpublic override void ExposeData()\n\t{\n\t\tbase.ExposeData();\n\t\tScribe_Collections.Look(ref innerList, \"innerList\", true, contentsLookMode);\n\t\tif (Scribe.mode == LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\tint num = innerList.RemoveAll((T x) => x == null || (x is MinifiedThing minifiedThing && minifiedThing.InnerThing == null));\n\t\t\tif (num > 0)\n\t\t\t{\n\t\t\t\tLog.Warning($\"ThingOwner removed {num} invalid entries during PostLoadInit.\");\n\t\t\t}\n\t\t}\n\t\tif (Scribe.mode != LoadSaveMode.LoadingVars && Scribe.mode != LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] != null)\n\t\t\t{\n\t\t\t\tinnerList[i].holdingOwner = this;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic List.Enumerator GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tpublic override int GetCountCanAccept(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (!(item is T))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn base.GetCountCanAccept(item, canMergeWithExistingStacks);\n\t}\n\n\tpublic override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (count <= 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item?.ToString() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + count + \" of \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tint stackCount = item.stackCount;\n\t\tint num = Mathf.Min(stackCount, count);\n\t\tThing thing = item.SplitOff(num);\n\t\tif (!TryAdd((T)thing, canMergeWithExistingStacks))\n\t\t{\n\t\t\tif (thing != item)\n\t\t\t{\n\t\t\t\tint result = stackCount - item.stackCount - thing.stackCount;\n\t\t\t\titem.TryAbsorbStack(thing, respectStackLimit: false);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn stackCount - item.stackCount;\n\t\t}\n\t\tCompPushable compPushable = item.TryGetComp();\n\t\tif (compPushable != null && owner is Pawn pawn)\n\t\t{\n\t\t\tcompPushable.OnStartedCarrying(pawn);\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (canMergeWithExistingStacks)\n\t\t{\n\t\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t\t{\n\t\t\t\tT val = innerList[i];\n\t\t\t\tif (!val.CanStackWith(item))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint num = Mathf.Min(item.stackCount, val.def.stackLimit - val.stackCount);\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tThing other = item.SplitOff(num);\n\t\t\t\t\tint stackCount = val.stackCount;\n\t\t\t\t\tval.TryAbsorbStack(other, respectStackLimit: true);\n\t\t\t\t\tif (val.stackCount > stackCount)\n\t\t\t\t\t{\n\t\t\t\t\t\tNotifyAddedAndMergedWith(val, val.stackCount - stackCount);\n\t\t\t\t\t}\n\t\t\t\t\tif (item.Destroyed || item.stackCount == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Count >= maxStacks)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\titem.holdingOwner = this;\n\t\tinnerList.Add(item2);\n\t\tNotifyAdded(item2);\n\t\treturn true;\n\t}\n\n\tprotected override void NotifyAdded(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemAdded(item as T);\n\t\t}\n\t\tbase.NotifyAdded(item);\n\t}\n\n\tprotected override void NotifyRemoved(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemRemoved(item as T);\n\t\t}\n\t\tbase.NotifyRemoved(item);\n\t}\n\n\tpublic void TryAddRangeOrTransfer(IEnumerable things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false)\n\t{\n\t\tif (things == this)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (things is ThingOwner thingOwner)\n\t\t{\n\t\t\tthingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks);\n\t\t\tif (destroyLeftover)\n\t\t\t{\n\t\t\t\tthingOwner.ClearAndDestroyContents();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (things is IList list)\n\t\t{\n\t\t\tfor (int i = 0; i < list.Count; i++)\n\t\t\t{\n\t\t\t\tif (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t\t{\n\t\t\t\t\tlist[i].Destroy();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tforeach (T thing in things)\n\t\t{\n\t\t\tif (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t{\n\t\t\t\tthing.Destroy();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int IndexOf(Thing item)\n\t{\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn -1;\n\t\t}\n\t\treturn innerList.IndexOf(item2);\n\t}\n\n\tpublic override bool Remove(Thing item)\n\t{\n\t\tif (!Contains(item))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner == this)\n\t\t{\n\t\t\titem.holdingOwner = null;\n\t\t}\n\t\tint index = innerList.LastIndexOf((T)item);\n\t\tinnerList.RemoveAt(index);\n\t\tNotifyRemoved(item);\n\t\treturn true;\n\t}\n\n\tpublic int RemoveAll(Predicate predicate)\n\t{\n\t\tint num = 0;\n\t\tfor (int num2 = innerList.Count - 1; num2 >= 0; num2--)\n\t\t{\n\t\t\tif (predicate(innerList[num2]))\n\t\t\t{\n\t\t\t\tRemove(innerList[num2]);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t\treturn num;\n\t}\n\n\tprotected override Thing GetAt(int index)\n\t{\n\t\treturn innerList[index];\n\t}\n\n\tpublic void GetThingsOfType(List list) where J : Thing\n\t{\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] is J item)\n\t\t\t{\n\t\t\t\tlist.Add(item);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true)\n\t{\n\t\tThing resultingTransferredItem2;\n\t\tint result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks);\n\t\tresultingTransferredItem = (T)resultingTransferredItem2;\n\t\treturn result;\n\t}\n\n\tpublic new T Take(Thing thing, int count)\n\t{\n\t\treturn (T)base.Take(thing, count);\n\t}\n\n\tpublic new T Take(Thing thing)\n\t{\n\t\treturn (T)base.Take(thing);\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out T resultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing resultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, count, out resultingThing2, placedAction2, nearPlaceValidator);\n\t\tresultingThing = (T)resultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, mode, out lastResultingThing2, placedAction2, nearPlaceValidator);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, out lastResultingThing2, placedAction2, nearPlaceValidator, playDropSound: true);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tint IList.IndexOf(T item)\n\t{\n\t\treturn innerList.IndexOf(item);\n\t}\n\n\tvoid IList.Insert(int index, T item)\n\t{\n\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow inserting individual elements at any position.\");\n\t}\n\n\tvoid ICollection.Add(T item)\n\t{\n\t\tTryAdd(item);\n\t}\n\n\tvoid ICollection.CopyTo(T[] array, int arrayIndex)\n\t{\n\t\tinnerList.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection.Contains(T item)\n\t{\n\t\treturn innerList.Contains(item);\n\t}\n\n\tbool ICollection.Remove(T item)\n\t{\n\t\treturn Remove(item);\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n}\n\n", + "timestamp": "2025-08-24 20:53:10,931" + }, + "ThingOwner": { + "keywords": [ + "ThingOwner" + ], + "question": "public abstract class ThingOwner", + "embedding": [ + -0.010147521272301674, + 0.008173150010406971, + 0.036745648831129074, + 0.00934287253767252, + -0.07223962247371674, + 0.032156169414520264, + 0.004172255285084248, + 0.06139175966382027, + 0.051437947899103165, + 0.09852483123540878, + -0.02407987415790558, + -0.06705410778522491, + -0.01253166701644659, + -0.07605426013469696, + 0.061272550374269485, + -0.03811653330922127, + 0.02048875391483307, + -0.07551782578229904, + -0.030144546180963516, + -0.022112954407930374, + 0.02022053860127926, + 0.06878261268138885, + -0.003967368043959141, + 0.023245424032211304, + 0.023632846772670746, + -0.019639402627944946, + -0.016942337155342102, + 0.048576973378658295, + -0.02101028710603714, + -0.01197288278490305, + 0.002253762912005186, + 0.015131876803934574, + -0.03316942974925041, + -0.003548279870301485, + -0.010996873490512371, + 0.026940850540995598, + -0.05000746250152588, + 0.023588145151734352, + 0.011063927784562111, + 0.0006235100445337594, + -0.009126808494329453, + -0.008173150010406971, + -0.009581286460161209, + 0.001336425542831421, + -0.04184176027774811, + 0.019997024908661842, + 0.02627030946314335, + -0.030472366139292717, + -0.035136353224515915, + 0.026568327099084854, + -0.0013932352885603905, + -0.005956639535725117, + -0.03683505579829216, + 0.02266428805887699, + -0.005148265045136213, + -0.0006379453116096556, + 0.02913128398358822, + -0.023111315444111824, + -0.020637763664126396, + 0.03710327297449112, + 0.00791238434612751, + 0.0011613398091867566, + -0.02805841900408268, + -0.03644763305783272, + 0.0452093668282032, + -0.0007413203711621463, + 0.04553718864917755, + 0.025614667683839798, + 0.00575175229460001, + -0.037133075296878815, + -0.014178218320012093, + 0.028371337801218033, + -0.013157505542039871, + 0.011518405750393867, + -0.03930860757827759, + 0.032543592154979706, + 0.009007601998746395, + 0.017717184498906136, + -0.01922217756509781, + -0.023111315444111824, + -0.00934287253767252, + -0.03203696012496948, + -0.010318881832063198, + 0.02539115399122238, + 0.08159739524126053, + 0.003002533921971917, + 0.04860677570104599, + -0.07390852272510529, + -0.01306064985692501, + 0.10996873676776886, + -0.045984216034412384, + 0.0006505179335363209, + 0.014640146866440773, + 0.02333482913672924, + -0.014945615082979202, + 0.09131278842687607, + -0.05936523526906967, + 0.0036227842792868614, + -0.0176277793943882, + 0.028416039422154427, + -0.01153330598026514, + -0.07700791209936142, + -0.020831475034356117, + 0.03948741778731346, + 0.011808972805738449, + 0.04661005362868309, + -0.026046795770525932, + -0.008359411731362343, + -0.010840414091944695, + 0.010244376957416534, + -0.0012898602290078998, + -0.016107887029647827, + -0.0038630615454167128, + 0.04154374450445175, + -0.04357026889920235, + 0.047444503754377365, + -0.04208017513155937, + 0.017136048525571823, + -0.003904039040207863, + -0.0008572681108489633, + 0.04115632176399231, + -0.020116232335567474, + 0.007625542115420103, + -0.023707352578639984, + -0.024318289011716843, + 0.006474446505308151, + 0.0186112392693758, + -0.003257711883634329, + -0.006239756941795349, + -0.008016690611839294, + -0.05158695951104164, + -0.003412308869883418, + 0.0029503805562853813, + -0.035017143934965134, + -0.005889585707336664, + 0.013440622948110104, + 0.07617346197366714, + 0.007599465548992157, + -0.1050812378525734, + 0.00821040291339159, + -0.03954702243208885, + 0.006314261816442013, + -0.06282224506139755, + 0.00560274301096797, + 0.08946508169174194, + -0.0013625022256746888, + -0.042646411806344986, + -0.03158993273973465, + -0.02640441618859768, + 0.009804800152778625, + -0.014506038278341293, + -0.009655791334807873, + -0.003330353880301118, + 0.04622263088822365, + 0.01083296351134777, + -0.03153033182024956, + 0.016271796077489853, + -0.041454337537288666, + -0.005341976881027222, + -0.029235590249300003, + 0.008292357437312603, + 0.031679339706897736, + -0.060527507215738297, + 2.5378116333740763e-05, + -0.0019371185917407274, + -0.033407844603061676, + -0.011883477680385113, + 0.030040239915251732, + -0.005435107741504908, + 0.02539115399122238, + 0.047653116285800934, + 0.007223217282444239, + 0.020458953455090523, + 0.02632991224527359, + 0.026225605979561806, + -0.013418271206319332, + 0.04446432366967201, + 0.053613483905792236, + 0.02002682536840439, + -0.04568619653582573, + 0.04497095197439194, + 0.011324693448841572, + 0.11580988764762878, + 0.0018104608170688152, + 0.005021607503294945, + -0.02632991224527359, + -0.014118614606559277, + 0.03236478194594383, + 0.0033117278944700956, + 0.0372522808611393, + -0.02247057668864727, + 0.028907770290970802, + 0.0239308662712574, + 0.05206378921866417, + -0.05605723336338997, + -0.017597977072000504, + -0.016599616035819054, + 0.041931167244911194, + -0.04306363686919212, + -0.010683953762054443, + 0.006005067843943834, + 0.03078528493642807, + 0.002898227423429489, + 0.015184029936790466, + 0.057755935937166214, + -0.03376546874642372, + 0.021457314491271973, + -0.02706005610525608, + 0.027432579547166824, + 0.012256000190973282, + 0.03963642567396164, + -0.010356133803725243, + 0.01213679276406765, + -0.027179263532161713, + -0.06011028215289116, + -0.009223665110766888, + -0.03909999504685402, + 0.016137687489390373, + -0.003445836016908288, + -0.018000302836298943, + -0.01220384705811739, + 0.008597826585173607, + -0.0037792439106851816, + 0.0292653925716877, + 0.03749069571495056, + -0.010751008056104183, + 0.013693938963115215, + 0.04821935296058655, + 0.016644319519400597, + -0.03236478194594383, + 0.0037270907778292894, + 0.03936821222305298, + -0.0671137124300003, + 0.010147521272301674, + -0.0025368803180754185, + -0.01642080582678318, + 0.005368053913116455, + -0.04362986981868744, + 0.028892869129776955, + 0.035464171320199966, + -0.021859638392925262, + 0.029742220416665077, + -0.010654152370989323, + 0.03531516343355179, + -0.01601848006248474, + 0.030904492363333702, + -0.07164358347654343, + 0.011697215959429741, + 0.022857999429106712, + -0.032871413975954056, + 0.009767548181116581, + 0.0419013649225235, + -0.017523473128676414, + -0.011145882308483124, + -0.009037403389811516, + 0.059544045478105545, + -0.0111384317278862, + 0.018432429060339928, + -0.02327522449195385, + -0.02387126162648201, + -0.033944278955459595, + 0.029548509046435356, + 0.011630162596702576, + -0.02832663431763649, + -0.019788412377238274, + 0.023781856521964073, + 0.024959027767181396, + 0.02312621660530567, + -0.0651467889547348, + -0.061332155019044876, + -0.022843098267912865, + 0.02866935543715954, + 0.020980484783649445, + -0.02998063527047634, + -0.04109671711921692, + 0.011384297162294388, + 0.002916853642091155, + 0.024154379963874817, + -0.08821339905261993, + -0.013053199276328087, + -0.00920876394957304, + 0.020444052293896675, + -0.029548509046435356, + -0.029280293732881546, + -0.02148711495101452, + 0.02679184079170227, + 0.04342125728726387, + -0.03111310489475727, + -0.0005126845207996666, + -0.0018048729980364442, + 0.031083302572369576, + -0.012986144982278347, + -0.0259275883436203, + -0.02135300822556019, + -0.009246015921235085, + 0.03403368219733238, + -0.005394130479544401, + 0.01076590921729803, + -0.026419317349791527, + 0.019594699144363403, + -0.00011193146201549098, + 0.0025033531710505486, + -0.005144540220499039, + -0.023111315444111824, + 0.04753391072154045, + -0.0018700645305216312, + -0.013470425270497799, + -0.09018032252788544, + -0.007763375528156757, + -0.08964388817548752, + -0.007375951856374741, + -0.008754285983741283, + -0.03933840990066528, + 0.0015673896996304393, + -0.002305916277691722, + 0.0019650578033179045, + -0.020190736278891563, + -0.0037159151397645473, + -0.004261660855263472, + 0.03385487198829651, + 0.021785134449601173, + 0.015087174251675606, + 0.029816726222634315, + 0.01816421188414097, + -0.03695426136255264, + -0.015161678194999695, + 0.021621223539114, + 0.01676352694630623, + -0.016778428107500076, + 0.026881245896220207, + -0.00960363820195198, + 0.004984355065971613, + 0.01353002805262804, + 0.018790051341056824, + 0.007629266940057278, + -0.00455595413222909, + 0.021636124700307846, + -0.005215319339185953, + 0.04109671711921692, + 0.007070483174175024, + -0.01847713068127632, + -0.018402626737952232, + 0.03385487198829651, + 0.01306064985692501, + -0.008255105465650558, + 0.009335421957075596, + -0.01127254031598568, + 0.04899419844150543, + 0.03051706776022911, + 0.013701388612389565, + 0.018849654123187065, + -0.00218670885078609, + -0.03918939828872681, + 0.03263299912214279, + -0.015243633650243282, + -0.02120399847626686, + 0.017985401675105095, + -0.0003287513682153076, + -0.01901356503367424, + 0.013172406703233719, + -0.003952466882765293, + 0.04273581504821777, + 0.028013715520501137, + 0.03549397364258766, + 0.03430189937353134, + -0.009156610816717148, + -0.012710478156805038, + 0.041066914796829224, + -0.02413947880268097, + -0.0037643429823219776, + 0.011585459113121033, + -0.050692904740571976, + -0.01820891536772251, + 0.021919243037700653, + -0.00987930502742529, + 0.0020209362264722586, + 0.013850398361682892, + -0.04801074042916298, + 0.007204591296613216, + 0.04005365073680878, + 0.08010730147361755, + 0.01682312972843647, + -0.020235439762473106, + -0.052421409636735916, + -0.028967373073101044, + -0.023617945611476898, + 0.022843098267912865, + -0.01350022666156292, + 0.020861277356743813, + -0.07885562628507614, + 0.006012517958879471, + 0.016733724623918533, + -0.028147824108600616, + -0.00997616071254015, + 0.03176874667406082, + 0.016331400722265244, + 0.0004609969910234213, + 0.04747430607676506, + -0.01289673987776041, + 0.02805841900408268, + 0.0005448146257549524, + -0.022023549303412437, + -0.04240799695253372, + -0.00024353679327759892, + -0.0009955671848729253, + -0.0285799503326416, + 0.024437496438622475, + 0.015735363587737083, + -0.010326332412660122, + 0.03981523960828781, + -0.06669648736715317, + 0.023960666730999947, + 0.08892864733934402, + -0.035344965755939484, + -0.06538520008325577, + -0.002847936935722828, + 0.029429301619529724, + -0.016808228567242622, + 0.05906721577048302, + -0.07271645218133926, + 0.01734466291964054, + 0.06532560288906097, + 0.01636120118200779, + -0.0398748405277729, + 0.006597378756850958, + 0.07599465548992157, + -0.0332290343940258, + -0.021963944658637047, + -0.01353002805262804, + 0.023111315444111824, + -0.01807480677962303, + -0.01350022666156292, + -0.045119963586330414, + 0.0691402330994606, + 0.0018616827437654138, + -0.04440471902489662, + 0.0009601775673218071, + 0.010251827538013458, + -0.026210704818367958, + -0.001405342249199748, + -0.07742514461278915, + -0.023156017065048218, + -0.0013336316915228963, + 0.01655491441488266, + -0.07855761051177979, + -0.006504248362034559, + 0.011920729652047157, + -0.005118463188409805, + -0.0005443489644676447, + -0.0055021620355546474, + -0.006548950914293528, + 0.017702283337712288, + 0.018402626737952232, + 0.02632991224527359, + 0.015161678194999695, + 0.04082849994301796, + -0.02406497299671173, + 0.0020414250902831554, + -0.0139621552079916, + -0.002460513263940811, + 0.003315452951937914, + -0.045179568231105804, + -0.006884221453219652, + 0.011242737993597984, + -0.012151693925261497, + -0.03352705389261246, + -0.006921473890542984, + -0.0008307258831337094, + -0.01279988419264555, + -0.057547323405742645, + 0.0024810018949210644, + 0.00021711095178034157, + 0.01160036027431488, + -0.017538374289870262, + 0.018387725576758385, + 0.03468932583928108, + -0.01333631668239832, + 0.008188051171600819, + 0.012293253093957901, + 0.007822979241609573, + 0.010512594133615494, + -0.008314709179103374, + -0.02135300822556019, + 0.0285799503326416, + -0.08600806444883347, + -0.008024141192436218, + -0.05996127054095268, + -0.003941291477531195, + 0.023483838886022568, + -0.03558338060975075, + 0.00025867053773254156, + -0.04070929437875748, + -0.0019538821652531624, + 0.0008302602218464017, + -0.0031664439011365175, + -0.010713756084442139, + -0.014625245705246925, + 0.06687529385089874, + -0.010490242391824722, + -0.08761736750602722, + -0.024556703865528107, + 0.025823282077908516, + -0.02667263336479664, + 0.0069624511525034904, + -0.0013205934083089232, + 0.00807629432529211, + -0.06139175966382027, + -0.022649386897683144, + -0.0018039416754618287, + -0.010981972329318523, + 0.00781552866101265, + 0.017791690304875374, + 0.04792133346199989, + -0.04735510051250458, + -0.018983762711286545, + 0.013373568654060364, + 0.08392193913459778, + 0.002819997724145651, + 0.033080026507377625, + -0.0037326784804463387, + 0.00911190826445818, + -0.04488154873251915, + -0.030934294685721397, + -0.02068246714770794, + -0.040798697620630264, + 0.03671584650874138, + -0.0032204596791416407, + -0.0049433778040111065, + 0.05534198880195618, + -0.057487718760967255, + -0.013798245228827, + 0.00460438197478652, + 0.030397862195968628, + -0.045984216034412384, + 0.008165700361132622, + 0.020697366446256638, + 0.06508718430995941, + 0.003429072443395853, + 0.025242146104574203, + 0.08356431871652603, + 0.07814038544893265, + 0.04210997745394707, + 0.010877666063606739, + 0.045835208147764206, + 0.05480555444955826, + -0.019505294039845467, + 0.03471912443637848, + -0.02074206992983818, + 0.01701684109866619, + -0.013321415521204472, + 0.005755477584898472, + 0.015012669377028942, + -0.00830725859850645, + 0.00286656292155385, + 0.011153332889080048, + -0.0030137095600366592, + -0.026583228260278702, + 0.0305766724050045, + 0.019132772460579872, + -0.04818955063819885, + -0.020265240222215652, + -0.007986889220774174, + -0.0399046428501606, + -0.025108037516474724, + 0.007074207998812199, + 0.016987040638923645, + 0.02241097204387188, + -0.013112802989780903, + 0.06705410778522491, + 0.014140966348350048, + -0.029220689088106155, + 0.01774698682129383, + -0.016778428107500076, + 0.03868276998400688, + 0.03960662707686424, + -0.0012554018758237362, + -0.0071375370025634766, + 0.031083302572369576, + 0.08290867507457733, + -0.02421398274600506, + -0.01090001780539751, + 0.028445841744542122, + 0.024586506187915802, + -0.012263450771570206, + 0.008575474843382835, + 0.01701684109866619, + 0.017836391925811768, + -0.034599918872117996, + 0.05942483991384506, + -0.005025332793593407, + 0.030040239915251732, + -0.00218670885078609, + -0.04315304383635521, + -0.008337060920894146, + -0.007148712873458862, + 0.02354344166815281, + 0.008925646543502808, + 0.01981821283698082, + 0.005111013073474169, + 0.033407844603061676, + 0.005572941154241562, + -0.0007161751273088157, + -0.013917452655732632, + 0.012419910170137882, + 0.04643124341964722, + -0.01688273437321186, + 0.013939803466200829, + 0.01189837884157896, + 0.006623455788940191, + 0.0003471446980256587, + 0.039070192724466324, + 0.032483987510204315, + -0.018298320472240448, + 0.007681420538574457, + 0.018909258767962456, + 0.007618091534823179, + 0.02181493490934372, + 0.00042164925253018737, + -0.011548207141458988, + -0.011615261435508728, + -0.018790051341056824, + -0.01728505827486515, + 0.0004279355925973505, + -0.027834905311465263, + -0.0007329386426135898, + -0.000144818244734779, + 0.02758158929646015, + 0.007372226566076279, + -0.01935628615319729, + -0.0004281683941371739, + -0.0558486208319664, + 0.00884369108825922, + -0.030934294685721397, + 0.009953809902071953, + 0.00860527716577053, + -0.032603196799755096, + -0.012159144505858421, + 0.01603338122367859, + -0.0007497021579183638, + -0.05659366399049759, + 0.003632097505033016, + 0.018834752961993217, + 0.024020271375775337, + -0.011615261435508728, + -0.010937269777059555, + -0.007942186668515205, + -0.02732827328145504, + -0.02506333403289318, + 0.015973778441548347, + -0.0035799441393464804, + -0.04801074042916298, + 0.032603196799755096, + 0.016659220680594444, + 0.0004973179311491549, + 0.007115185726433992, + 0.02254508063197136, + -0.004459097981452942, + -0.012360306456685066, + 0.016256894916296005, + -0.01512442622333765, + -0.041513942182064056, + -0.0625242292881012, + -0.021978845819830894, + -0.015273435041308403, + 0.03915959969162941, + 0.01326926238834858, + -0.02300700917840004, + -0.03862316533923149, + 0.008120996877551079, + -0.017657581716775894, + 0.0242586862295866, + -0.0005462115514092147, + 0.008724484592676163, + -0.0014416632475331426, + 0.03032335638999939, + 0.05638505145907402, + -0.08678291738033295, + -0.04929221794009209, + -0.004544778261333704, + 0.06163017451763153, + -0.0011073240311816335, + 0.03609000891447067, + -0.023096414282917976, + 0.013887650333344936, + 0.026896147057414055, + 0.023617945611476898, + 0.0016065046656876802, + 0.043838486075401306, + -0.07831919938325882, + 0.007025780156254768, + 0.04440471902489662, + -0.008411564864218235, + 0.0531962588429451, + 0.021755332127213478, + -0.05638505145907402, + -0.018864555284380913, + -0.02168082818388939, + -0.02886306680738926, + -0.01621219329535961, + 0.03647743538022041, + 0.004839071538299322, + -0.02066756598651409, + 0.07086873799562454, + 0.0012498140567913651, + 0.009223665110766888, + -0.020846376195549965, + -0.016793327406048775, + -0.04333185404539108, + -0.011287441477179527, + -0.011026674881577492, + 0.007293996401131153, + 0.007234393153339624, + 0.0032372232526540756, + -0.0005285167135298252, + -0.02381165884435177, + -0.0037662056274712086, + 0.029935933649539948, + -0.04181196168065071, + -0.03662644326686859, + -0.005606468301266432, + -0.02840113826096058, + -0.012285802513360977, + 0.005543139297515154, + 0.02878856286406517, + 0.025301748886704445, + -0.0684845969080925, + 0.01749367080628872, + -0.023617945611476898, + 0.0159588772803545, + 0.0751006007194519, + -0.01273282989859581, + -0.045656394213438034, + -0.00475339125841856, + -0.01269557699561119, + 0.0020246615167707205, + -0.053613483905792236, + 0.008217853493988514, + -0.04294443130493164, + -0.026344813406467438, + 0.010922368615865707, + -0.002285427413880825, + -0.021695729345083237, + 0.05221279710531235, + -0.03150052949786186, + 0.03564298152923584, + -0.012069739401340485, + -0.018924158066511154, + 0.04362986981868744, + -0.010296530090272427, + -0.007644168101251125, + 0.011101179756224155, + 0.025614667683839798, + -0.04196096956729889, + -0.020369546487927437, + -0.003484950866550207, + -0.019982123747467995, + 0.021725529804825783, + 0.03519595414400101, + -0.023960666730999947, + 0.046848468482494354, + -0.002313366625458002, + 0.00967069249600172, + 0.014997768215835094, + 0.03445091098546982, + 0.007644168101251125, + 0.012263450771570206, + 0.030546870082616806, + -0.002363657345995307, + -0.014647596515715122, + -0.028341535478830338, + -0.013686488382518291, + -0.007621816825121641, + -0.029623012989759445, + 0.07277605682611465, + 0.02254508063197136, + 0.03078528493642807, + -0.006206229794770479, + -0.020369546487927437, + -0.024109676480293274, + -0.015318137593567371, + 0.02154671959578991, + 0.024690812453627586, + -0.04416630417108536, + -0.00037997326580807567, + 0.02014603279531002, + 0.024512000381946564, + -0.03701386600732803, + 0.04559679329395294, + 0.014342128299176693, + 0.019117871299386024, + 0.011630162596702576, + -0.03957682475447655, + 0.011637612245976925, + 0.015407543629407883, + 0.0007632061024196446, + -0.004131278023123741, + -0.014573092572391033, + 0.11390257626771927, + 0.02606169506907463, + -0.006466995924711227, + 0.03617941588163376, + -0.0531962588429451, + 0.06633885949850082, + -0.011287441477179527, + 0.024288486689329147, + 0.025093136355280876, + -0.0005713568534702063, + -0.0399046428501606, + -0.03495753929018974, + -0.027238868176937103, + 0.014699749648571014, + -0.0016037106979638338, + 0.0038630615454167128, + -0.005330801475793123, + 0.008828790858387947, + -0.03889138251543045, + 0.033020421862602234, + -0.0024381617549806833, + -0.011279990896582603, + 0.01289673987776041, + 0.029161086305975914, + 0.06878261268138885, + 0.028565049171447754, + 0.0018812401685863733, + 0.013537478633224964, + 0.020265240222215652, + 0.033676061779260635, + -0.03838475048542023, + -0.028311733156442642, + -0.0009611088316887617, + 0.03650723397731781, + -0.010840414091944695, + -0.019460592418909073, + 0.03293101489543915, + 0.0017750711413100362, + -0.0024251234717667103, + -0.0058448826894164085, + 0.017985401675105095, + 0.018536735326051712, + -0.006567577365785837, + -0.014774254523217678, + 0.016391003504395485, + -0.0001331769017269835, + -0.0013261812273412943, + -0.02074206992983818, + 0.03439130634069443, + 0.012069739401340485, + 0.0029969459865242243, + -0.02168082818388939, + -0.03164953738451004, + -0.020309943705797195, + 0.03111310489475727, + -0.010162422433495522, + -0.022232161834836006, + -0.012069739401340485, + 0.016718823462724686, + -0.012121892534196377, + -0.02101028710603714, + 0.005010431632399559, + 0.008798988536000252, + -0.024765316396951675, + 0.0166145171970129, + 0.00586723443120718, + 0.014066461473703384, + -0.0399046428501606, + 0.02671733684837818, + -0.02200864814221859, + 0.003483088221400976, + -0.0037811065558344126, + -0.03629862144589424, + 0.038593363016843796, + 0.06028909236192703, + -0.02233646810054779, + 0.027432579547166824, + -0.014111164025962353, + 0.008351961150765419, + -0.027149463072419167, + 0.00950678251683712, + 3.620456118369475e-05, + -0.011361945420503616, + 0.01203993707895279, + -0.014237822033464909, + 0.04488154873251915, + -0.00904485397040844, + -0.017240354791283607, + -0.0013317690463736653, + -0.0008060462423600256, + -0.018268518149852753, + -0.004492625128477812, + 0.045447781682014465, + 0.011011774651706219, + -0.014386830851435661, + 0.016048282384872437, + 0.03209656476974487, + -0.021129494532942772, + -0.037669505923986435, + -0.04127552732825279, + -0.0015115112764760852, + 0.0186112392693758, + -0.01782149076461792, + 0.02598719112575054, + -0.05844137817621231, + 0.035344965755939484, + -0.020175835117697716, + -0.027030255645513535, + 0.011913279071450233, + -0.047504108399152756, + 0.006128000095486641, + -0.04908360540866852, + 0.017657581716775894, + -0.01747876964509487, + 0.023379530757665634, + 0.02612129971385002, + 0.0006998772150836885, + -0.036596640944480896, + 0.025942487642169, + -0.045179568231105804, + 0.05963345244526863, + 0.01868574507534504, + -0.02354344166815281, + 0.0458948090672493, + 0.03358665481209755, + -0.004224408883601427, + -0.027238868176937103, + 0.004846521653234959, + 0.01655491441488266, + 0.00465280981734395, + 0.03704366832971573, + -0.0055692158639431, + 0.01456564199179411, + 0.04881538823246956, + 0.03129191696643829, + 0.04592461138963699, + 0.01399195659905672, + -0.004976904951035976, + -0.019505294039845467, + 0.006090748123824596, + -0.0159588772803545, + 0.002218373352661729, + -0.021770233288407326, + 0.015079723671078682, + -0.01622709445655346, + 0.0020749520044773817, + 0.0026542250998318195, + 0.007338699419051409, + 0.019862916320562363, + 0.0038220840506255627, + -0.0372224785387516, + 0.03814633563160896, + -0.0025927587412297726, + -0.02267918922007084, + 0.007215766701847315, + -0.02533155120909214, + -0.015251084230840206, + -0.049202810972929, + -0.027358075603842735, + 0.03072568215429783, + -0.03811653330922127, + 0.0012991733383387327, + -0.03871257230639458, + 0.04824915528297424, + 0.04249740391969681, + -0.010087917558848858, + -0.005151990335434675, + -0.005051409360021353, + -0.03489793837070465, + -0.03051706776022911, + -0.038742370903491974, + 1.307467755395919e-05, + 0.006884221453219652, + -0.017702283337712288, + 0.038742370903491974, + -0.018179113045334816, + -0.033825069665908813, + 0.004429296124726534, + -0.03847415745258331, + 0.010944720357656479, + -0.028758760541677475, + -0.14519448578357697, + -0.01603338122367859, + 0.057219505310058594, + 0.006943825166672468, + -0.03364625945687294, + 0.04148413985967636, + -0.028237229213118553, + -0.04911340773105621, + 0.018462231382727623, + -0.02320072054862976, + 0.00691402330994606, + -0.09661751985549927, + -0.01402920950204134, + -0.06082552298903465, + 0.006578752771019936, + 0.020905980840325356, + 0.0030230225529521704, + -0.04446432366967201, + -0.02446729876101017, + -0.004816719796508551, + 0.031232312321662903, + -0.023349730297923088, + -0.015809867531061172, + 0.04136493429541588, + -0.060676515102386475, + 0.005111013073474169, + 0.005114738363772631, + 0.0018654079176485538, + -0.05400090664625168, + 0.007986889220774174, + -0.0014099988620728254, + -8.89398215804249e-05, + 0.0745045617222786, + -0.0046751610934734344, + 0.02972732111811638, + -0.03954702243208885, + 0.041066914796829224, + -0.004582030698657036, + -0.0030993898399174213, + 0.0020954408682882786, + -0.012047387659549713, + -0.01528833620250225, + -0.03802713006734848, + 0.06770974397659302, + -0.01855163648724556, + 0.009849502705037594 + ], + "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\ThingOwner.txt\n\npublic class ThingOwner : ThingOwner, IList, ICollection, IEnumerable, IEnumerable where T : Thing\n{\n\tprivate List innerList = new List();\n\n\tpublic List InnerListForReading => innerList;\n\n\tpublic new T this[int index] => innerList[index];\n\n\tpublic override int Count => innerList.Count;\n\n\tT IList.this[int index]\n\t{\n\t\tget\n\t\t{\n\t\t\treturn innerList[index];\n\t\t}\n\t\tset\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow setting individual elements.\");\n\t\t}\n\t}\n\n\tbool ICollection.IsReadOnly => true;\n\n\tpublic ThingOwner()\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, bool oneStackOnly, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner, oneStackOnly, contentsLookMode, removeContentsIfDestroyed)\n\t{\n\t}\n\n\tpublic override void ExposeData()\n\t{\n\t\tbase.ExposeData();\n\t\tScribe_Collections.Look(ref innerList, \"innerList\", true, contentsLookMode);\n\t\tif (Scribe.mode == LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\tint num = innerList.RemoveAll((T x) => x == null || (x is MinifiedThing minifiedThing && minifiedThing.InnerThing == null));\n\t\t\tif (num > 0)\n\t\t\t{\n\t\t\t\tLog.Warning($\"ThingOwner removed {num} invalid entries during PostLoadInit.\");\n\t\t\t}\n\t\t}\n\t\tif (Scribe.mode != LoadSaveMode.LoadingVars && Scribe.mode != LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] != null)\n\t\t\t{\n\t\t\t\tinnerList[i].holdingOwner = this;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic List.Enumerator GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tpublic override int GetCountCanAccept(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (!(item is T))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn base.GetCountCanAccept(item, canMergeWithExistingStacks);\n\t}\n\n\tpublic override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (count <= 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item?.ToString() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + count + \" of \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tint stackCount = item.stackCount;\n\t\tint num = Mathf.Min(stackCount, count);\n\t\tThing thing = item.SplitOff(num);\n\t\tif (!TryAdd((T)thing, canMergeWithExistingStacks))\n\t\t{\n\t\t\tif (thing != item)\n\t\t\t{\n\t\t\t\tint result = stackCount - item.stackCount - thing.stackCount;\n\t\t\t\titem.TryAbsorbStack(thing, respectStackLimit: false);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn stackCount - item.stackCount;\n\t\t}\n\t\tCompPushable compPushable = item.TryGetComp();\n\t\tif (compPushable != null && owner is Pawn pawn)\n\t\t{\n\t\t\tcompPushable.OnStartedCarrying(pawn);\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (canMergeWithExistingStacks)\n\t\t{\n\t\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t\t{\n\t\t\t\tT val = innerList[i];\n\t\t\t\tif (!val.CanStackWith(item))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint num = Mathf.Min(item.stackCount, val.def.stackLimit - val.stackCount);\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tThing other = item.SplitOff(num);\n\t\t\t\t\tint stackCount = val.stackCount;\n\t\t\t\t\tval.TryAbsorbStack(other, respectStackLimit: true);\n\t\t\t\t\tif (val.stackCount > stackCount)\n\t\t\t\t\t{\n\t\t\t\t\t\tNotifyAddedAndMergedWith(val, val.stackCount - stackCount);\n\t\t\t\t\t}\n\t\t\t\t\tif (item.Destroyed || item.stackCount == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Count >= maxStacks)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\titem.holdingOwner = this;\n\t\tinnerList.Add(item2);\n\t\tNotifyAdded(item2);\n\t\treturn true;\n\t}\n\n\tprotected override void NotifyAdded(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemAdded(item as T);\n\t\t}\n\t\tbase.NotifyAdded(item);\n\t}\n\n\tprotected override void NotifyRemoved(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemRemoved(item as T);\n\t\t}\n\t\tbase.NotifyRemoved(item);\n\t}\n\n\tpublic void TryAddRangeOrTransfer(IEnumerable things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false)\n\t{\n\t\tif (things == this)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (things is ThingOwner thingOwner)\n\t\t{\n\t\t\tthingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks);\n\t\t\tif (destroyLeftover)\n\t\t\t{\n\t\t\t\tthingOwner.ClearAndDestroyContents();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (things is IList list)\n\t\t{\n\t\t\tfor (int i = 0; i < list.Count; i++)\n\t\t\t{\n\t\t\t\tif (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t\t{\n\t\t\t\t\tlist[i].Destroy();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tforeach (T thing in things)\n\t\t{\n\t\t\tif (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t{\n\t\t\t\tthing.Destroy();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int IndexOf(Thing item)\n\t{\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn -1;\n\t\t}\n\t\treturn innerList.IndexOf(item2);\n\t}\n\n\tpublic override bool Remove(Thing item)\n\t{\n\t\tif (!Contains(item))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner == this)\n\t\t{\n\t\t\titem.holdingOwner = null;\n\t\t}\n\t\tint index = innerList.LastIndexOf((T)item);\n\t\tinnerList.RemoveAt(index);\n\t\tNotifyRemoved(item);\n\t\treturn true;\n\t}\n\n\tpublic int RemoveAll(Predicate predicate)\n\t{\n\t\tint num = 0;\n\t\tfor (int num2 = innerList.Count - 1; num2 >= 0; num2--)\n\t\t{\n\t\t\tif (predicate(innerList[num2]))\n\t\t\t{\n\t\t\t\tRemove(innerList[num2]);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t\treturn num;\n\t}\n\n\tprotected override Thing GetAt(int index)\n\t{\n\t\treturn innerList[index];\n\t}\n\n\tpublic void GetThingsOfType(List list) where J : Thing\n\t{\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] is J item)\n\t\t\t{\n\t\t\t\tlist.Add(item);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true)\n\t{\n\t\tThing resultingTransferredItem2;\n\t\tint result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks);\n\t\tresultingTransferredItem = (T)resultingTransferredItem2;\n\t\treturn result;\n\t}\n\n\tpublic new T Take(Thing thing, int count)\n\t{\n\t\treturn (T)base.Take(thing, count);\n\t}\n\n\tpublic new T Take(Thing thing)\n\t{\n\t\treturn (T)base.Take(thing);\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out T resultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing resultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, count, out resultingThing2, placedAction2, nearPlaceValidator);\n\t\tresultingThing = (T)resultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, mode, out lastResultingThing2, placedAction2, nearPlaceValidator);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, out lastResultingThing2, placedAction2, nearPlaceValidator, playDropSound: true);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tint IList.IndexOf(T item)\n\t{\n\t\treturn innerList.IndexOf(item);\n\t}\n\n\tvoid IList.Insert(int index, T item)\n\t{\n\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow inserting individual elements at any position.\");\n\t}\n\n\tvoid ICollection.Add(T item)\n\t{\n\t\tTryAdd(item);\n\t}\n\n\tvoid ICollection.CopyTo(T[] array, int arrayIndex)\n\t{\n\t\tinnerList.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection.Contains(T item)\n\t{\n\t\treturn innerList.Contains(item);\n\t}\n\n\tbool ICollection.Remove(T item)\n\t{\n\t\treturn Remove(item);\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n}\n\n", + "timestamp": "2025-08-24 20:53:27,802" + }, + "ThingOwner-TryAdd-override-virtual": { + "keywords": [ + "ThingOwner", + "TryAdd", + "virtual", + "override" + ], + "question": "public abstract class ThingOwner virtual override TryAdd", + "embedding": [ + -0.0049171303398907185, + 0.0012670025462284684, + 0.019699471071362495, + -0.01261199451982975, + -0.08294514566659927, + 0.0006480089505203068, + 0.017130648717284203, + 0.04450564086437225, + 0.02870582789182663, + 0.07916928082704544, + -0.055399928241968155, + -0.0877113938331604, + -0.011567442677915096, + -0.05781400203704834, + 0.004495440982282162, + -0.0044722286984324455, + -0.01843053475022316, + -0.0782407894730568, + -0.03262096270918846, + 0.026926221325993538, + 0.01801271364092827, + 0.0709366649389267, + 0.013463110662996769, + 0.0554618276655674, + 0.04150352254509926, + -0.0018540793098509312, + -0.0014275539433583617, + 0.06069232150912285, + -0.01242629624903202, + -0.008774233981966972, + -0.03707771748304367, + 0.026260804384946823, + -0.005396850407123566, + -0.021680250763893127, + 0.02480616793036461, + 0.012735793367028236, + -0.056173671036958694, + 0.0025939701590687037, + 0.014600511640310287, + -0.012975653633475304, + -0.01609383337199688, + -0.01444576308131218, + -0.004356167279183865, + 0.0029382852371782064, + -0.026632199063897133, + 0.03546833246946335, + 0.01826031133532524, + -0.04462943971157074, + -0.007671651896089315, + 0.05902104079723358, + -0.008588536642491817, + 0.006039056461304426, + -0.024713318794965744, + -0.029170073568820953, + -0.01337799895554781, + 0.018291261047124863, + -0.003855169517919421, + -0.019668521359562874, + -0.019885169342160225, + 0.04370094835758209, + -0.014283277094364166, + 0.03136749938130379, + -0.02638460136950016, + -0.027870187535881996, + 0.049364738166332245, + 0.017362769693136215, + 0.003957690205425024, + 0.04193681478500366, + 0.011157359927892685, + -0.02989739179611206, + -0.004781725350767374, + -0.008457000367343426, + -0.06938917934894562, + 0.011497805826365948, + -0.05567847564816475, + 0.061187516897916794, + 0.021277904510498047, + 0.02735951729118824, + -0.007307993248105049, + 0.010252081789076328, + -0.011668029241263866, + -0.021695725619792938, + -0.028968900442123413, + 0.013849982060492039, + 0.07731229811906815, + 0.024187175557017326, + -0.003183948341757059, + -0.09049686789512634, + -0.04688876494765282, + 0.10262914001941681, + -0.007509165909141302, + 0.024109801277518272, + 0.015699224546551704, + -0.02189689874649048, + -0.01648070476949215, + 0.08690670132637024, + -0.06976057589054108, + 0.015629587695002556, + -0.017687741667032242, + 0.010669901967048645, + -0.012844117358326912, + -0.10300053656101227, + -0.02797851152718067, + 0.07564102113246918, + 0.0016954621532931924, + 0.05960908532142639, + -0.009818785823881626, + -0.00341993966139853, + -0.017409194260835648, + 0.01846148446202278, + -0.032682862132787704, + -0.018151987344026566, + 0.03395180031657219, + 0.028783202171325684, + -0.02231471985578537, + 0.03124370239675045, + -0.009223004803061485, + -0.03203291818499565, + -1.2973779121239204e-05, + -0.011296633630990982, + 0.05397624149918556, + -0.0009255888871848583, + 0.005304001271724701, + -0.013873194344341755, + -0.010724063962697983, + 0.03280666097998619, + -0.006990759167820215, + 0.013842244632542133, + -0.014724310487508774, + 0.015358778648078442, + -0.014995119534432888, + -0.015536739490926266, + -0.026137005537748337, + -0.03729436546564102, + -0.0056289732456207275, + -0.01917332597076893, + 0.021865949034690857, + 0.006588412914425135, + -0.09879137575626373, + 0.008395100943744183, + -0.02407885156571865, + 0.007133901119232178, + -0.00038348586531355977, + -0.0005628973012790084, + 0.08597820997238159, + -0.020906507968902588, + -0.05574037507176399, + -0.02327415905892849, + -0.015258192084729671, + 0.005950076039880514, + -0.009617612697184086, + -0.01114962249994278, + -0.005346557125449181, + 0.039275143295526505, + 0.020983882248401642, + 0.0028067491948604584, + 0.019065003842115402, + -0.035777829587459564, + -0.0038803161587566137, + -0.0349731370806694, + 0.005160859320312738, + 0.029541470110416412, + -0.03720151633024216, + 0.008836133405566216, + 0.014391601085662842, + -0.024001477286219597, + 0.023630080744624138, + 0.004746907390654087, + 0.04233916103839874, + 0.03317805752158165, + 0.039306093007326126, + -0.008820658549666405, + 0.034230347722768784, + 0.04274150729179382, + 0.020132767036557198, + -0.053821492940187454, + 0.04116307571530342, + 0.05515233054757118, + 0.02910817414522171, + -0.05834014713764191, + 0.060599472373723984, + 0.002671344205737114, + 0.018585283309221268, + 0.00245276209898293, + -0.007373761385679245, + -0.03751101344823837, + 0.010468728840351105, + 0.02307298593223095, + 0.022670641541481018, + 0.04942663758993149, + 0.015366516076028347, + 0.04964328557252884, + 0.02113863080739975, + 0.031909119337797165, + -0.02482164278626442, + -0.01114962249994278, + -0.03438509628176689, + 0.04948853701353073, + -0.11878487467765808, + 0.0068205357529222965, + 0.0029266790952533484, + 0.010375880636274815, + 0.01097939908504486, + -0.007725813891738653, + 0.03008308820426464, + -0.02233019471168518, + -0.0021471341606229544, + -0.032868560403585434, + 0.01590813510119915, + 0.006468483246862888, + 0.03608732670545578, + -0.008371888659894466, + 0.008905770257115364, + -0.048436250537633896, + -0.03299235925078392, + -0.023614605888724327, + -0.02889152616262436, + 0.005775983911007643, + 0.03413749858736992, + -0.004100832622498274, + 0.004356167279183865, + 0.018291261047124863, + -0.00843378808349371, + -0.0020136635284870863, + 0.017950814217329025, + -0.021633826196193695, + 0.025115665048360825, + 0.0538833923637867, + 0.03155319765210152, + -0.02290276251733303, + -0.013246462680399418, + 0.016449755057692528, + -0.05119077116250992, + 0.00597328832373023, + 0.016062883660197258, + -0.03881089761853218, + -0.007598146330565214, + -0.011551967822015285, + 0.043360501527786255, + 0.012256073765456676, + -0.03806810826063156, + 0.029727168381214142, + -0.008805183693766594, + 0.026090580970048904, + -0.004255581181496382, + 0.00941644050180912, + -0.035251684486866, + 0.01329288724809885, + 0.035623081028461456, + -0.008070128969848156, + 0.024388348683714867, + 0.034446995705366135, + -0.04602217301726341, + 0.025270413607358932, + -0.011497805826365948, + 0.03785146027803421, + -0.012929229065775871, + 0.011079985648393631, + -0.009989009238779545, + -0.039677489548921585, + -0.02718929387629032, + 0.024868067353963852, + 0.012372134253382683, + -0.017115173861384392, + -0.036768220365047455, + 0.008387363515794277, + 0.00979557354003191, + 0.007923117838799953, + -0.06784170120954514, + -0.0627659484744072, + -0.008309989236295223, + 0.040048886090517044, + 0.010623477399349213, + -0.0454341284930706, + -0.046826865524053574, + -0.013053027912974358, + 0.02636912651360035, + 0.038687098771333694, + -0.04933378845453262, + -0.002611379139125347, + -0.022825388237833977, + 0.011304371058940887, + -0.055214229971170425, + -0.007176456972956657, + -0.02559538558125496, + 0.017935339361429214, + 0.02986644208431244, + -0.06901778280735016, + -0.006793454755097628, + -0.027514265850186348, + 0.0036636684089899063, + 0.06425153464078903, + -0.03494218736886978, + 0.006743161473423243, + -0.027669014409184456, + 0.020999357104301453, + -0.01883288100361824, + 0.003584359772503376, + -0.018925730139017105, + 0.02347533218562603, + -0.013702970929443836, + -0.0049287364818155766, + 0.0015658603515475988, + 0.018523383885622025, + 0.03413749858736992, + 0.00030417731613852084, + -0.003491510869935155, + -0.12348922342061996, + 0.026276279240846634, + -0.09136345237493515, + -0.01649617962539196, + 0.01251140795648098, + -0.013122664764523506, + 0.005516780540347099, + -0.018538858741521835, + 0.016960425302386284, + -0.05942338705062866, + 0.0022960794158279896, + 0.010716326534748077, + 0.02172667533159256, + 0.009060518816113472, + 0.013339311815798283, + -0.0005063174176029861, + 0.019126901403069496, + -0.02561086043715477, + 0.0028995980974286795, + 0.021432653069496155, + 0.008201665244996548, + -0.00788829941302538, + 0.007690995465964079, + -0.03277571126818657, + -0.003688815049827099, + 0.040234584361314774, + 0.008178452961146832, + 0.005269182845950127, + -0.0011248274240642786, + 0.012534620240330696, + -0.033487554639577866, + 0.010453253984451294, + 0.019683996215462685, + -0.010321718640625477, + -0.05047892779111862, + 0.026817897334694862, + 0.018306735903024673, + 0.023336058482527733, + 0.010027696378529072, + -0.01903405413031578, + 0.041627321392297745, + 0.022221870720386505, + 0.008944457396864891, + 8.41444416437298e-05, + -0.008170715533196926, + -0.01784249022603035, + 0.03877994790673256, + 0.001028109691105783, + -0.019838744774460793, + 0.013819032348692417, + -0.005164728034287691, + -0.03602542728185654, + 0.00902956910431385, + -0.015575426630675793, + 0.013826769776642323, + 0.008565324358642101, + 0.021680250763893127, + 0.02929387241601944, + 0.023583656176924706, + -0.002363781910389662, + 0.05837109684944153, + -0.013153614476323128, + -0.007385367527604103, + 0.011141885071992874, + -0.0699462741613388, + -0.017579417675733566, + 0.005903651472181082, + 0.009679512120783329, + -0.033673252910375595, + 0.01706874929368496, + -0.02287181280553341, + 0.003205226268619299, + 0.07898358255624771, + 0.048436250537633896, + -0.0014643067261204123, + 0.0021355280186980963, + -0.03556118160486221, + -0.02752974070608616, + 0.010004484094679356, + -0.018693607300519943, + 0.025146614760160446, + 0.031135378405451775, + -0.062363605946302414, + 0.017734166234731674, + 0.025548961013555527, + -0.03342565521597862, + -0.011451381258666515, + 0.01357917208224535, + 0.013726183213293552, + 0.000961858022492379, + 0.04794105514883995, + 0.03146034851670265, + 0.0029537600930780172, + 0.010615739971399307, + -0.015057018958032131, + -0.020287515595555305, + 0.040853578597307205, + 0.006104824598878622, + -0.03983223810791969, + 0.022252820432186127, + 0.019838744774460793, + -0.008774233981966972, + 0.030315211042761803, + -0.04695066437125206, + 0.00044780317693948746, + 0.030005713924765587, + -0.0037255678325891495, + -0.03203291818499565, + -0.011768615804612637, + 0.02327415905892849, + -0.009927109815180302, + 0.08449262380599976, + -0.0768171027302742, + -0.01884835585951805, + 0.04326765239238739, + 0.01561411377042532, + 0.02889152616262436, + 0.013672021217644215, + 0.009385490790009499, + 0.0020600880961865187, + -0.028086835518479347, + -0.011056773364543915, + 0.0011693176347762346, + 0.008658172562718391, + -0.003127851989120245, + -0.022825388237833977, + 0.0695129781961441, + 0.00806239154189825, + -0.025966782122850418, + 0.02172667533159256, + 0.02660124935209751, + -0.05236686021089554, + -0.012828642502427101, + -0.032280515879392624, + -0.007013971451669931, + -0.019111426547169685, + -0.009772361256182194, + -0.037572912871837616, + -0.0388418473303318, + 0.024713318794965744, + 0.009509289637207985, + 0.021200530230998993, + 0.023336058482527733, + -0.0014497990487143397, + -0.0012225123355165124, + -0.0004782692703884095, + 0.018167462199926376, + 0.03664442151784897, + 0.042958155274391174, + -0.05292395129799843, + -0.025177564471960068, + -0.014871321618556976, + 0.01436065137386322, + -0.021448127925395966, + -0.032094817608594894, + 0.008542112074792385, + 0.004920999053865671, + -0.0016151864547282457, + 0.00490552419796586, + -0.02674052305519581, + 0.00645687710493803, + -0.015730174258351326, + -0.05601892247796059, + 0.01824483647942543, + -0.0252239890396595, + -0.0052459705621004105, + -0.018182937055826187, + 0.011157359927892685, + -0.023939577862620354, + -0.027313092723488808, + 0.023722929880023003, + 0.006433664821088314, + -0.00854984950274229, + 0.020504163578152657, + -0.004495440982282162, + -0.005880439188331366, + 0.012062638066709042, + -0.036582522094249725, + -0.06858449429273605, + -0.06815119832754135, + -0.03280666097998619, + 0.007311861962080002, + -0.04574362561106682, + -0.006077743601053953, + -0.05057177692651749, + -0.0050447979010641575, + 0.016805676743388176, + -0.010731801390647888, + 0.0016451689880341291, + -0.012735793367028236, + 0.06437533348798752, + -0.022469468414783478, + -0.13877835869789124, + -0.033394705504179, + 0.03376610204577446, + -0.023011086508631706, + 0.010623477399349213, + 0.033642303198575974, + 0.008936719968914986, + -0.04478418827056885, + 0.0021896897815167904, + -0.002996315946802497, + 0.008526637218892574, + -0.012449508532881737, + 0.007865087129175663, + 0.046672116965055466, + -0.04193681478500366, + -0.029371246695518494, + 0.01801271364092827, + 0.05821634829044342, + -0.017796065658330917, + 0.023630080744624138, + 0.026260804384946823, + 0.005745034199208021, + -0.03432319685816765, + -0.0050834850408136845, + -0.02850465476512909, + -0.04487703740596771, + 0.037170566618442535, + 0.010932974517345428, + -0.018337685614824295, + 0.043731898069381714, + -0.03311615809798241, + -0.04487703740596771, + -0.0016828888328745961, + -0.020519638434052467, + -0.024156225845217705, + 0.022593267261981964, + 0.05233591049909592, + 0.02113863080739975, + 0.0052575767040252686, + 0.03305425867438316, + 0.0676560029387474, + 0.0577521026134491, + 0.026322703808546066, + 0.005598023533821106, + -0.017238972708582878, + 0.06555142253637314, + -0.004824281204491854, + 0.044753238558769226, + -0.07489822804927826, + 0.011907889507710934, + -0.024976391345262527, + -0.0038029418792575598, + 0.04555792734026909, + -0.00015523198817390949, + 0.03221861645579338, + -0.0013027881504967809, + -0.008805183693766594, + 0.0029943815898150206, + 0.01651165448129177, + 0.016821151599287987, + -0.060444723814725876, + 0.0050061107613146305, + -0.01269710622727871, + -0.030887780711054802, + -0.05125267058610916, + 0.0014062761329114437, + 0.013819032348692417, + 0.025301363319158554, + 0.019065003842115402, + 0.051685966551303864, + -0.021045781672000885, + -0.027792813256382942, + 0.021633826196193695, + -0.03583972901105881, + 0.03933704271912575, + 0.042586758732795715, + 0.0017022324027493596, + 0.023119410499930382, + 0.03395180031657219, + 0.06381823867559433, + -0.009238479658961296, + 0.006244097836315632, + 0.03942989185452461, + 0.008665909990668297, + -0.02500734105706215, + 0.03648967295885086, + 0.01937449909746647, + 0.01242629624903202, + -0.003154932986944914, + -0.011521018110215664, + -0.0029614975210279226, + 0.02988191694021225, + -0.0009768492309376597, + -0.07167945802211761, + -0.005988763179630041, + -0.0262298546731472, + 0.03608732670545578, + 0.0013066567480564117, + 0.07130806148052216, + -0.008650435134768486, + 0.003787467023357749, + -0.01686757616698742, + 0.0034489550162106752, + -0.026075106114149094, + 0.020891033113002777, + 0.03416844829916954, + -0.006371765397489071, + -0.0031742765568196774, + 0.00891350768506527, + 0.017347294837236404, + -0.007586540188640356, + 0.04391759634017944, + 0.04639356955885887, + -0.018709082156419754, + 0.006538120098412037, + 0.015118918381631374, + -0.017393719404935837, + 0.019095951691269875, + -0.02189689874649048, + -0.0026191165670752525, + 0.0021800179965794086, + 0.006379502825438976, + -0.018678132444620132, + 0.02231471985578537, + -0.04283435642719269, + -0.006805060897022486, + 0.0013569500297307968, + 0.02000896818935871, + 0.014701098203659058, + -0.01436065137386322, + 0.0022612609900534153, + -0.017208022996783257, + 0.024883542209863663, + -0.06914158165454865, + 0.042555809020996094, + 0.021448127925395966, + -0.0147629976272583, + 0.02678694762289524, + 0.028999850153923035, + -0.005362031981348991, + -0.040079835802316666, + 0.01821388676762581, + 0.026910746470093727, + 0.022577792406082153, + -0.015730174258351326, + -0.0008685254142619669, + -0.02539421245455742, + -0.012766743078827858, + -0.04345335066318512, + 0.014167215675115585, + -0.015103443525731564, + 0.005481962114572525, + 0.02209807187318802, + 0.004131782334297895, + -0.029572419822216034, + -0.031940069049596786, + 0.01668187789618969, + 0.01844600960612297, + 0.018322210758924484, + 0.014724310487508774, + -0.020318465307354927, + -0.028071360662579536, + -0.024171700701117516, + -0.030423535034060478, + -0.014468975365161896, + 0.04794105514883995, + -0.006650312338024378, + -0.008573061786592007, + -0.01785796508193016, + 0.027715438976883888, + -0.01262746937572956, + 0.024310974404215813, + -0.0038609725888818502, + 0.017300870269536972, + -0.02757616527378559, + 0.024295499548316002, + 0.05184071511030197, + -0.008758759126067162, + -0.05100507289171219, + -0.0038396946620196104, + 0.05199546366930008, + 0.02195879817008972, + 0.018167462199926376, + -0.03243526443839073, + 0.002692622132599354, + 0.015761123970150948, + -0.003491510869935155, + -0.0195601973682642, + 0.051593117415905, + -0.03893469646573067, + -0.023227734491229057, + 0.06323019415140152, + -0.012333447113633156, + 0.02910817414522171, + 0.018786456435918808, + -0.05038607865571976, + -0.01577659882605076, + -0.009068256244063377, + -0.035963527858257294, + -0.00788829941302538, + 0.0520264133810997, + 0.0028086835518479347, + -0.009106943383812904, + 0.05722595751285553, + 0.010159232653677464, + -0.002539808163419366, + -0.016372380778193474, + -0.01349406037479639, + -0.03667537122964859, + -0.0017505913274362683, + -0.03141392394900322, + -0.011234734207391739, + 0.05063367635011673, + -0.024403823539614677, + -0.00902956910431385, + -0.0051221721805632114, + 0.018585283309221268, + 0.04636261984705925, + -0.0246514193713665, + -0.03995603695511818, + 0.007184194400906563, + -0.034632690250873566, + -0.019683996215462685, + -0.006518776528537273, + 0.015567689202725887, + -0.012658419087529182, + -0.016728302463889122, + 0.010329456068575382, + -0.014414813369512558, + -0.03515883535146713, + 0.0547499842941761, + -0.007246093824505806, + -0.022392094135284424, + -0.017146123573184013, + 0.02757616527378559, + 0.010608002543449402, + -0.02927839756011963, + 0.014708835631608963, + -0.03023783676326275, + -0.010128282941877842, + 0.028566554188728333, + -0.007687126751989126, + -0.014600511640310287, + 0.09606780856847763, + -0.0508812740445137, + 0.028396330773830414, + 0.004085357766598463, + -0.005818539764732122, + 0.03136749938130379, + 0.008820658549666405, + -0.0013492126017808914, + 0.024914491921663284, + 0.01524271722882986, + -0.025951307266950607, + 0.002990512875840068, + 0.029340296983718872, + -0.027050020173192024, + 0.04964328557252884, + 0.012774480506777763, + 0.0021896897815167904, + 0.0262298546731472, + 0.02112315595149994, + -0.012449508532881737, + 0.01329288724809885, + 0.01066216453909874, + 0.003195554483681917, + 0.02834990620613098, + 0.033394705504179, + 0.017409194260835648, + -0.02268611639738083, + -0.005126040894538164, + -0.018956679850816727, + 0.030980629846453667, + -0.04933378845453262, + 0.05601892247796059, + -0.005547730252146721, + 0.02542516216635704, + -0.013757132925093174, + -0.011172834783792496, + -0.05205736309289932, + -0.048621948808431625, + 0.0434224009513855, + 0.006843748036772013, + -0.05964003503322601, + -0.0042710560373961926, + 0.022639691829681396, + 0.03218766674399376, + -0.012851854786276817, + 0.055771324783563614, + 0.010468728840351105, + 0.06072327122092247, + 0.004909392911940813, + -0.020287515595555305, + 0.011637079529464245, + 0.021448127925395966, + -0.01940544880926609, + -0.015258192084729671, + -0.004031195770949125, + 0.11519470810890198, + 0.04484608769416809, + -0.0007732583908364177, + 0.03240431472659111, + -0.04035838320851326, + 0.017966289073228836, + -0.008356413803994656, + 0.033673252910375595, + 0.04561982676386833, + -0.007617489900439978, + -0.03062470816075802, + -0.03822285309433937, + 0.0004688392800744623, + -0.017718691378831863, + -0.0162640567868948, + 0.004526390694081783, + -0.00611643074080348, + 0.008387363515794277, + -0.01883288100361824, + 0.028009461238980293, + 0.0075942776165902615, + 0.00933132879436016, + -0.014801684767007828, + 0.03788240998983383, + 0.06784170120954514, + 0.0349731370806694, + -0.011977526359260082, + 0.04302005469799042, + 0.002655869349837303, + 0.033085208386182785, + -0.044319942593574524, + -0.012333447113633156, + 0.005748902913182974, + 0.025657285004854202, + -0.02019466646015644, + -0.018863830715417862, + 0.06462293118238449, + 0.021680250763893127, + 0.009532501921057701, + -0.031692471355199814, + 0.004619239829480648, + -0.008101078681647778, + -0.032280515879392624, + -0.031197277829051018, + 0.01162934210151434, + 0.004154994618147612, + -0.019730420783162117, + -0.008480212651193142, + 0.0161247830837965, + -0.013819032348692417, + -0.01940544880926609, + 0.0038222854491323233, + -0.030330685898661613, + -0.005930732470005751, + 0.028814151883125305, + 0.014414813369512558, + 0.010375880636274815, + 0.03240431472659111, + 0.05648316442966461, + 0.0018627839162945747, + -0.0027119657024741173, + 0.0030059877317398787, + -0.00572955934330821, + -0.008689122274518013, + 0.009339066222310066, + -0.01881740614771843, + 0.008379626087844372, + -0.03472553938627243, + 0.009772361256182194, + 0.011141885071992874, + 0.004127913620322943, + -0.002698425203561783, + -0.03155319765210152, + 0.02830348163843155, + 0.08573061227798462, + -0.003996377345174551, + 0.021401703357696533, + 0.02152550220489502, + -0.013145877048373222, + -0.025734659284353256, + 0.015196292661130428, + 0.0055013056844472885, + 0.024001477286219597, + -0.03262096270918846, + -0.024388348683714867, + 0.038501400500535965, + -0.015165342949330807, + -0.08430692553520203, + 0.0035437382757663727, + 0.03766576200723648, + -0.0007945363176986575, + -0.026461975648999214, + 0.04806485399603844, + 0.0006465581827796996, + -0.013919618912041187, + 0.02367650531232357, + 0.03028426133096218, + 0.0031375237740576267, + -0.0041433884762227535, + -0.03435414656996727, + 0.03064018301665783, + 0.024109801277518272, + -0.017579417675733566, + -0.006878566462546587, + -0.08053106814622879, + 0.004576683975756168, + -0.03673727065324783, + -0.03902754560112953, + -0.027653539553284645, + -0.027684489265084267, + -0.003826154163107276, + -0.026709573343396187, + 0.04286530613899231, + -0.002748718485236168, + 0.026461975648999214, + 0.02774638868868351, + 0.02191237360239029, + -0.013849982060492039, + 0.010747276246547699, + -0.024001477286219597, + 0.06610851734876633, + 0.00941644050180912, + -0.028458230197429657, + 0.029773592948913574, + 0.004414197988808155, + -0.0018318342044949532, + -0.038130007684230804, + 0.01094844937324524, + 0.035592131316661835, + 0.043762847781181335, + 0.023753879591822624, + -0.0180591382086277, + 0.05007658153772354, + 0.038872797042131424, + 0.02640007622539997, + 0.034632690250873566, + 0.008240352384746075, + 0.02500734105706215, + -0.0070255775935947895, + -0.00543166883289814, + -0.03843950107693672, + -0.035035036504268646, + -0.039863187819719315, + 0.02833443135023117, + -0.010174707509577274, + 0.003568884916603565, + 0.022392094135284424, + 0.0013956371694803238, + 0.027313092723488808, + 0.007350549101829529, + -0.018399585038423538, + 0.028860576450824738, + -0.006688999477773905, + -0.038903746753931046, + -0.006642574910074472, + -0.03924419358372688, + 0.01898762956261635, + -0.04908619076013565, + 0.029850967228412628, + 0.02796303667128086, + -0.0010571250459179282, + -0.009872947819530964, + -0.033487554639577866, + 0.07570292055606842, + 0.020844610407948494, + -0.011853727512061596, + 0.0017080354737117887, + -0.010174707509577274, + -0.028071360662579536, + -0.014724310487508774, + -0.04017268493771553, + -0.016542604193091393, + 0.01807461306452751, + -0.02754521556198597, + 0.02907722443342209, + -0.004418066702783108, + -0.047043513506650925, + 0.009153367951512337, + 0.018105562776327133, + -0.00790377426892519, + -0.03819190338253975, + -0.11965146660804749, + 0.003127851989120245, + -0.009145630523562431, + 0.021571926772594452, + -0.041410673409700394, + 0.013548222370445728, + -0.024202650412917137, + -0.050355128943920135, + 0.006309865973889828, + -0.022423043847084045, + 0.024202650412917137, + -0.043143853545188904, + -0.019885169342160225, + -0.05979478359222412, + -0.013718445785343647, + 0.05574037507176399, + 0.031909119337797165, + -0.029015325009822845, + -0.06425153464078903, + -0.0013772607780992985, + 0.003013725159689784, + -0.020999357104301453, + 0.027808288112282753, + 0.05744260549545288, + -0.01632595621049404, + -0.005358163267374039, + 0.01881740614771843, + 0.016186682507395744, + -0.09495361894369125, + 0.016604503616690636, + -0.007849612273275852, + 0.028458230197429657, + 0.06288974732160568, + 0.01094844937324524, + 0.023614605888724327, + -0.038903746753931046, + 0.05663791298866272, + -0.01866265758872032, + -0.01047646626830101, + 0.0017496241489425302, + 0.012875067070126534, + -0.002197427209466696, + -0.018740031868219376, + 0.07774559408426285, + 0.05725690722465515, + -0.0022631953470408916 + ], + "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\ThingOwner.txt\n\npublic class ThingOwner : ThingOwner, IList, ICollection, IEnumerable, IEnumerable where T : Thing\n{\n\tprivate List innerList = new List();\n\n\tpublic List InnerListForReading => innerList;\n\n\tpublic new T this[int index] => innerList[index];\n\n\tpublic override int Count => innerList.Count;\n\n\tT IList.this[int index]\n\t{\n\t\tget\n\t\t{\n\t\t\treturn innerList[index];\n\t\t}\n\t\tset\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow setting individual elements.\");\n\t\t}\n\t}\n\n\tbool ICollection.IsReadOnly => true;\n\n\tpublic ThingOwner()\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, bool oneStackOnly, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner, oneStackOnly, contentsLookMode, removeContentsIfDestroyed)\n\t{\n\t}\n\n\tpublic override void ExposeData()\n\t{\n\t\tbase.ExposeData();\n\t\tScribe_Collections.Look(ref innerList, \"innerList\", true, contentsLookMode);\n\t\tif (Scribe.mode == LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\tint num = innerList.RemoveAll((T x) => x == null || (x is MinifiedThing minifiedThing && minifiedThing.InnerThing == null));\n\t\t\tif (num > 0)\n\t\t\t{\n\t\t\t\tLog.Warning($\"ThingOwner removed {num} invalid entries during PostLoadInit.\");\n\t\t\t}\n\t\t}\n\t\tif (Scribe.mode != LoadSaveMode.LoadingVars && Scribe.mode != LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] != null)\n\t\t\t{\n\t\t\t\tinnerList[i].holdingOwner = this;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic List.Enumerator GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tpublic override int GetCountCanAccept(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (!(item is T))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn base.GetCountCanAccept(item, canMergeWithExistingStacks);\n\t}\n\n\tpublic override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (count <= 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item?.ToString() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + count + \" of \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tint stackCount = item.stackCount;\n\t\tint num = Mathf.Min(stackCount, count);\n\t\tThing thing = item.SplitOff(num);\n\t\tif (!TryAdd((T)thing, canMergeWithExistingStacks))\n\t\t{\n\t\t\tif (thing != item)\n\t\t\t{\n\t\t\t\tint result = stackCount - item.stackCount - thing.stackCount;\n\t\t\t\titem.TryAbsorbStack(thing, respectStackLimit: false);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn stackCount - item.stackCount;\n\t\t}\n\t\tCompPushable compPushable = item.TryGetComp();\n\t\tif (compPushable != null && owner is Pawn pawn)\n\t\t{\n\t\t\tcompPushable.OnStartedCarrying(pawn);\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (canMergeWithExistingStacks)\n\t\t{\n\t\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t\t{\n\t\t\t\tT val = innerList[i];\n\t\t\t\tif (!val.CanStackWith(item))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint num = Mathf.Min(item.stackCount, val.def.stackLimit - val.stackCount);\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tThing other = item.SplitOff(num);\n\t\t\t\t\tint stackCount = val.stackCount;\n\t\t\t\t\tval.TryAbsorbStack(other, respectStackLimit: true);\n\t\t\t\t\tif (val.stackCount > stackCount)\n\t\t\t\t\t{\n\t\t\t\t\t\tNotifyAddedAndMergedWith(val, val.stackCount - stackCount);\n\t\t\t\t\t}\n\t\t\t\t\tif (item.Destroyed || item.stackCount == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Count >= maxStacks)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\titem.holdingOwner = this;\n\t\tinnerList.Add(item2);\n\t\tNotifyAdded(item2);\n\t\treturn true;\n\t}\n\n\tprotected override void NotifyAdded(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemAdded(item as T);\n\t\t}\n\t\tbase.NotifyAdded(item);\n\t}\n\n\tprotected override void NotifyRemoved(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemRemoved(item as T);\n\t\t}\n\t\tbase.NotifyRemoved(item);\n\t}\n\n\tpublic void TryAddRangeOrTransfer(IEnumerable things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false)\n\t{\n\t\tif (things == this)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (things is ThingOwner thingOwner)\n\t\t{\n\t\t\tthingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks);\n\t\t\tif (destroyLeftover)\n\t\t\t{\n\t\t\t\tthingOwner.ClearAndDestroyContents();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (things is IList list)\n\t\t{\n\t\t\tfor (int i = 0; i < list.Count; i++)\n\t\t\t{\n\t\t\t\tif (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t\t{\n\t\t\t\t\tlist[i].Destroy();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tforeach (T thing in things)\n\t\t{\n\t\t\tif (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t{\n\t\t\t\tthing.Destroy();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int IndexOf(Thing item)\n\t{\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn -1;\n\t\t}\n\t\treturn innerList.IndexOf(item2);\n\t}\n\n\tpublic override bool Remove(Thing item)\n\t{\n\t\tif (!Contains(item))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner == this)\n\t\t{\n\t\t\titem.holdingOwner = null;\n\t\t}\n\t\tint index = innerList.LastIndexOf((T)item);\n\t\tinnerList.RemoveAt(index);\n\t\tNotifyRemoved(item);\n\t\treturn true;\n\t}\n\n\tpublic int RemoveAll(Predicate predicate)\n\t{\n\t\tint num = 0;\n\t\tfor (int num2 = innerList.Count - 1; num2 >= 0; num2--)\n\t\t{\n\t\t\tif (predicate(innerList[num2]))\n\t\t\t{\n\t\t\t\tRemove(innerList[num2]);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t\treturn num;\n\t}\n\n\tprotected override Thing GetAt(int index)\n\t{\n\t\treturn innerList[index];\n\t}\n\n\tpublic void GetThingsOfType(List list) where J : Thing\n\t{\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] is J item)\n\t\t\t{\n\t\t\t\tlist.Add(item);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true)\n\t{\n\t\tThing resultingTransferredItem2;\n\t\tint result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks);\n\t\tresultingTransferredItem = (T)resultingTransferredItem2;\n\t\treturn result;\n\t}\n\n\tpublic new T Take(Thing thing, int count)\n\t{\n\t\treturn (T)base.Take(thing, count);\n\t}\n\n\tpublic new T Take(Thing thing)\n\t{\n\t\treturn (T)base.Take(thing);\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out T resultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing resultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, count, out resultingThing2, placedAction2, nearPlaceValidator);\n\t\tresultingThing = (T)resultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, mode, out lastResultingThing2, placedAction2, nearPlaceValidator);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, out lastResultingThing2, placedAction2, nearPlaceValidator, playDropSound: true);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tint IList.IndexOf(T item)\n\t{\n\t\treturn innerList.IndexOf(item);\n\t}\n\n\tvoid IList.Insert(int index, T item)\n\t{\n\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow inserting individual elements at any position.\");\n\t}\n\n\tvoid ICollection.Add(T item)\n\t{\n\t\tTryAdd(item);\n\t}\n\n\tvoid ICollection.CopyTo(T[] array, int arrayIndex)\n\t{\n\t\tinnerList.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection.Contains(T item)\n\t{\n\t\treturn innerList.Contains(item);\n\t}\n\n\tbool ICollection.Remove(T item)\n\t{\n\t\treturn Remove(item);\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n}\n\n", + "timestamp": "2025-08-24 20:56:15,798" + }, + "ThingOwner-TryAdd-abstract-override-virtual": { + "keywords": [ + "ThingOwner", + "TryAdd", + "virtual", + "override", + "abstract" + ], + "question": "ThingOwner TryAdd virtual override abstract methods", + "embedding": [ + 0.006892177741974592, + -0.005672356579452753, + -0.007039462681859732, + 0.0001993302721530199, + -0.05933693051338196, + 0.038037266582250595, + 0.0027663125656545162, + 0.05111918970942497, + 0.029139749705791473, + 0.05743355676531792, + -0.020544353872537613, + -0.07142184674739838, + -0.019743729382753372, + -0.02217581868171692, + -0.0059593734331429005, + -0.008240400813519955, + -0.012371931225061417, + -0.08973048627376556, + -0.05160258337855339, + 0.0030741000082343817, + 0.06090796738862991, + 0.06441259384155273, + 0.0151363555341959, + 0.06284155696630478, + 0.06169348955154419, + 0.03513688966631889, + 0.011896087788045406, + 0.04601331055164337, + 0.008368803188204765, + 0.025302790105342865, + -0.01186587568372488, + 0.0035537201911211014, + 0.014645406045019627, + -0.03465349227190018, + 0.03900406137108803, + 0.014977741055190563, + -0.029804419726133347, + -0.020091170445084572, + 0.02022712491452694, + 0.034834764897823334, + -0.03087695688009262, + 0.0015691505977883935, + -0.002292357152327895, + -0.013066813349723816, + -0.031209291890263557, + 0.03205523639917374, + -0.003870949149131775, + -0.04296186938881874, + 0.0003927597135771066, + 0.03707047551870346, + -0.012032043188810349, + 0.019804153591394424, + -0.043535903096199036, + -0.014305517077445984, + 0.013444467447698116, + 0.010506322607398033, + -0.04084701091051102, + -0.005306032951921225, + -0.013716378249228, + 0.050333667546510696, + -0.008602948859333992, + 0.012296400032937527, + -0.006178412586450577, + -0.021360086277127266, + 0.05154215916991234, + 0.0006198239279910922, + 0.005464647430926561, + 0.01998542807996273, + 0.013942969962954521, + -0.040182340890169144, + -0.01148822158575058, + -0.02013648860156536, + -0.04640607163310051, + 0.031994812190532684, + -0.05124003812670708, + 0.05441232770681381, + 0.03136035427451134, + 0.0036141446325927973, + -0.022855594754219055, + 0.025589806959033012, + -0.009161875583231449, + -0.015921873971819878, + -0.0033120219595730305, + 0.04250868782401085, + 0.08308378607034683, + 0.034593068063259125, + 0.00490571977570653, + -0.1038094162940979, + -0.04021255299448967, + 0.042689960449934006, + 0.006548513192683458, + 0.022221136838197708, + 0.026148732751607895, + -0.017719505354762077, + -0.011254076845943928, + 0.07510774582624435, + -0.08247954398393631, + -0.008368803188204765, + -0.026390431448817253, + 0.02527257800102234, + -0.017462700605392456, + -0.0561344288289547, + -0.013837226666510105, + 0.09837120026350021, + -0.024743862450122833, + 0.10634724795818329, + -0.04196486622095108, + 0.012545651756227016, + -0.02782551571726799, + 0.004588490817695856, + 0.004728222731500864, + -0.015045718289911747, + 0.013625741004943848, + 0.02867146022617817, + -0.017115259543061256, + 0.011155886575579643, + 0.004327910020947456, + -0.051421310752630234, + -0.02432089112699032, + -0.00781742949038744, + 0.064714714884758, + 0.011306948028504848, + 0.008111998438835144, + -0.009743462316691875, + -0.027462968602776527, + 0.03945724666118622, + 0.01602761819958687, + 0.0044638654217123985, + -0.03016696684062481, + 0.0010026702657341957, + -0.009962501004338264, + 0.00486040161922574, + -0.010309942997992039, + -0.0424482636153698, + -0.025665337219834328, + -0.01799141615629196, + 0.030091436579823494, + -0.005143641494214535, + -0.07837066799402237, + 0.009501763619482517, + -0.02003074623644352, + 0.0037954184226691723, + 0.015846343711018562, + 0.0010602624388411641, + 0.07142184674739838, + -0.021692421287298203, + -0.07522859424352646, + -0.022311773151159286, + -0.001380323781631887, + -0.004562055226415396, + -0.027493180707097054, + 0.012122679501771927, + -0.00946399848908186, + 0.045227792114019394, + 0.014048713259398937, + 0.003578267525881529, + 0.00894283689558506, + -0.02158667892217636, + 0.004781094379723072, + -0.05299235135316849, + 0.010173987597227097, + 0.001458686892874539, + -0.029154855757951736, + 0.029789313673973083, + 0.022462835535407066, + -0.020302657037973404, + 0.0346837043762207, + -0.014970188029110432, + 0.04954814910888672, + -0.012273740954697132, + 0.05830971151590347, + 0.004475194960832596, + 0.01101237814873457, + 0.045288216322660446, + 0.022311773151159286, + -0.05788674205541611, + 0.016314635053277016, + 0.04776562377810478, + 0.025786185637116432, + -0.06229773536324501, + 0.04867199435830116, + 0.008300825953483582, + -0.001127295894548297, + -0.019048847258090973, + -0.001308569684624672, + -0.04704052954912186, + 0.03549943491816521, + 0.014992847107350826, + 0.015529114753007889, + 0.045832037925720215, + 0.01101237814873457, + 0.025453850626945496, + 0.014449025504291058, + 0.017719505354762077, + -0.04779583588242531, + -0.005404222756624222, + -0.031602051109075546, + 0.020514141768217087, + -0.08102934807538986, + 0.0032855861354619265, + 0.008806881494820118, + -0.01208491437137127, + 0.01888267882168293, + -0.0027776421047747135, + 0.032387569546699524, + -0.03208544850349426, + 0.010166434571146965, + -0.017613762989640236, + 0.019804153591394424, + 0.024532375857234, + 0.01848991960287094, + -0.0035914855543524027, + -0.00859539583325386, + -0.05504678562283516, + -0.0161786787211895, + -0.02347494661808014, + -0.004320356994867325, + -0.010883975774049759, + 0.029049113392829895, + 0.02581639774143696, + -0.007099887356162071, + -0.0023678878787904978, + -0.00989452376961708, + -0.03785599395632744, + 0.005128535442054272, + -0.027840621769428253, + 0.014584980905056, + 0.013746590353548527, + 0.0270248893648386, + 0.0006575892912223935, + -0.05698037147521973, + 0.015770813450217247, + -0.07831024378538132, + 0.022417515516281128, + 0.020650098100304604, + -0.02533300220966339, + -0.055167634040117264, + -0.029547614976763725, + 0.022870700806379318, + 0.016601651906967163, + -0.02537832036614418, + 0.031209291890263557, + -0.011986724101006985, + 0.03571092337369919, + 0.013791908510029316, + -0.014041160233318806, + -0.048581354320049286, + 0.02661702409386635, + 0.03401903435587883, + 0.025136621668934822, + 0.03492540121078491, + 0.025242365896701813, + -0.04404951259493828, + 0.030287817120552063, + -0.022447729483246803, + 0.04401930049061775, + -0.010022926144301891, + 0.0037765358574688435, + -0.00583097105845809, + -0.03395861014723778, + -0.02137519232928753, + 0.01983436569571495, + 0.0055326251313090324, + -0.015249651856720448, + -0.012417249381542206, + 0.030756106600165367, + 0.024804286658763885, + 0.013731484301388264, + -0.03682877868413925, + -0.027991682291030884, + -0.017810143530368805, + 0.053475745022296906, + -0.0072509488090872765, + -0.06072669476270676, + -0.025846611708402634, + 0.0176288690418005, + 0.032840754836797714, + 0.05755440518260002, + -0.023490052670240402, + -0.003221384948119521, + 0.009947394952178001, + 0.00989452376961708, + -0.02447195164859295, + -0.013452020473778248, + 0.006759998854249716, + 0.030242498964071274, + 0.020665204152464867, + -0.0382789671421051, + 0.012069808319211006, + -0.04489545896649361, + 0.016057830303907394, + 0.0661044791340828, + 0.018958209082484245, + 0.028354231268167496, + -0.028006788343191147, + 0.03441179543733597, + -0.007983596995472908, + 0.005521295126527548, + -0.017704399302601814, + 0.02663213014602661, + -4.767876453115605e-05, + 0.026601918041706085, + -0.01717568375170231, + 0.020060958340764046, + 0.04549970477819443, + 0.022100286558270454, + 0.00658250181004405, + -0.12447462230920792, + 0.024638120085000992, + -0.09891502559185028, + 0.00520784268155694, + -0.004973697476089001, + -0.015385606326162815, + 0.010000267066061497, + -0.011556199751794338, + 0.043143145740032196, + -0.055167634040117264, + -0.007107440382242203, + 0.02797657623887062, + 0.02403387427330017, + 0.01719079166650772, + 0.037040263414382935, + 0.015468690544366837, + 0.005245608277618885, + -0.028006788343191147, + 0.002432089066132903, + 0.04290144518017769, + -0.007254725322127342, + -0.00520784268155694, + -0.006608937401324511, + -0.03117907978594303, + 0.00859539583325386, + 0.03157183900475502, + 0.007945830933749676, + 0.02481939271092415, + -0.0172814279794693, + -0.00765503803268075, + -0.024653226137161255, + -0.002855061087757349, + 0.008142211474478245, + -0.0018901561852544546, + -0.05344553291797638, + 0.02787083387374878, + -0.0012415361125022173, + 0.027342118322849274, + 0.009547082707285881, + -0.018943103030323982, + 0.03498582914471626, + 0.025151727721095085, + 0.008912624791264534, + -0.008844646625220776, + -0.01574060134589672, + -0.0316624753177166, + 0.04951793700456619, + 0.00011701360199367628, + -0.010151328518986702, + 0.025650231167674065, + -0.009373362176120281, + -0.04562055319547653, + 0.007409563288092613, + 0.002520837588235736, + -0.02132987417280674, + 0.021344980224967003, + 0.03426073119044304, + 0.010498769581317902, + 0.01957756094634533, + 0.0016191897448152304, + 0.026964465156197548, + -0.012779797427356243, + -0.009501763619482517, + 0.005978255998343229, + -0.04885326698422432, + -0.013912757858633995, + -0.005037898663431406, + 0.005026569124311209, + -0.011926299892365932, + 0.041390832513570786, + -0.034744128584861755, + 0.014509450644254684, + 0.07299288362264633, + 0.01303660124540329, + 0.009796333499252796, + -0.016012512147426605, + -0.005445764400064945, + -0.026798298582434654, + 0.014018501155078411, + -0.012470121495425701, + 0.02028755098581314, + 0.051028549671173096, + -0.02403387427330017, + 0.0005830026930198073, + 0.03679856285452843, + -0.046526920050382614, + -0.009599953889846802, + 0.012077361345291138, + 0.016918880864977837, + 0.01838417537510395, + 0.0489439032971859, + 0.010951953940093517, + -0.009486657567322254, + -0.004630032926797867, + -0.018656086176633835, + 0.006510747596621513, + 0.02093711495399475, + -0.009229853749275208, + -0.02817295677959919, + 0.03250842168927193, + 0.027644241228699684, + -0.013074366375803947, + 0.025317896157503128, + -0.030892062932252884, + -0.01593698002398014, + 0.06302282959222794, + 0.013550210744142532, + -0.00988697074353695, + -0.027689559385180473, + 0.01139003224670887, + -0.014584980905056, + 0.06423132121562958, + -0.08604459464550018, + 0.00898815505206585, + 0.013912757858633995, + 0.0042561558075249195, + 0.04075637459754944, + 0.009645272046327591, + 0.028339125216007233, + -0.005521295126527548, + -0.04788647219538689, + -0.013807014562189579, + 0.018807148560881615, + 0.03891342505812645, + -0.027311906218528748, + 0.01563485898077488, + 0.06695042550563812, + 0.023203035816550255, + -0.04634564742445946, + 0.03725174814462662, + -0.0256351251155138, + -0.04380781576037407, + -0.026586811989545822, + -0.029305918142199516, + -0.00040102089405991137, + -0.012945964932441711, + 0.0007109328871592879, + -0.057614829391241074, + -0.02562001906335354, + 0.015272310934960842, + 0.013467126525938511, + 0.0284750796854496, + 0.02117881178855896, + 0.0028191839810460806, + -0.016949092969298363, + -0.03362627327442169, + 0.03136035427451134, + 0.03250842168927193, + 0.038581088185310364, + -0.0071980771608650684, + -0.030635258182883263, + -0.02726658806204796, + 0.00015448391786776483, + -0.035741135478019714, + -0.018746724352240562, + -0.008278165943920612, + 0.016511013731360435, + 0.008821987546980381, + -0.01788567379117012, + -0.07347627729177475, + 0.019502030685544014, + -0.0016588433645665646, + -0.02858082205057144, + 0.0019449159735813737, + -0.008897517807781696, + 0.014683171175420284, + -0.004275038372725248, + 0.013142344541847706, + -0.04936687648296356, + -0.02858082205057144, + 0.005842301063239574, + 0.00205443543381989, + -0.008829540573060513, + 0.018006522208452225, + 0.0008978713885881007, + -0.0010715919779613614, + -0.002056323690339923, + -0.026360219344496727, + -0.054925937205553055, + -0.04142104461789131, + -0.03220629692077637, + -0.003234602976590395, + -0.04649670794606209, + 0.007892959751188755, + -0.025212151929736137, + -0.002458524890244007, + -0.005124758929014206, + -0.009486657567322254, + 0.014970188029110432, + -0.02202475629746914, + 0.02492513693869114, + -0.017251215875148773, + -0.10930804908275604, + -0.034049246460199356, + 0.038097694516181946, + -0.037281960248947144, + 0.009275171905755997, + 0.03821854293346405, + 0.008036468178033829, + -0.0439588762819767, + -0.011760132387280464, + -0.03332415223121643, + 0.045137155801057816, + -0.01053653471171856, + -0.0015795361250638962, + 0.036738138645887375, + -0.04580182582139969, + -0.0067486693151295185, + 0.015589539892971516, + 0.05006175860762596, + -0.019154589623212814, + 0.003923820797353983, + 0.04710095375776291, + -0.005041675176471472, + -0.019502030685544014, + -0.002913597272709012, + -0.005423105321824551, + -0.037433020770549774, + 0.025045985355973244, + -0.012432355433702469, + -0.007447328418493271, + 0.03341478854417801, + -0.014509450644254684, + -0.005479753483086824, + 0.04867199435830116, + -0.006355909630656242, + -0.02518193982541561, + 0.013980735093355179, + 0.07226778566837311, + -0.0011707261437550187, + 0.01703972928225994, + 0.019698411226272583, + 0.07486604154109955, + 0.03175311163067818, + 0.022221136838197708, + 0.007779663894325495, + -0.012349272146821022, + 0.09299341589212418, + -0.03066547028720379, + 0.043838027864694595, + -0.07414095103740692, + 0.02022712491452694, + -0.037886206060647964, + 0.011299395002424717, + 0.04169295355677605, + 0.00976612139493227, + 0.04160231724381447, + 0.013580422848463058, + -0.021103281527757645, + 0.020242230966687202, + -0.0133387241512537, + 0.014267751947045326, + -0.0764370858669281, + 0.02642064355313778, + -0.026662342250347137, + -0.044683970510959625, + -0.03855087608098984, + 0.032991815358400345, + 0.024003662168979645, + 0.024849604815244675, + 0.0316624753177166, + 0.017462700605392456, + -0.028112532570958138, + -0.04474439471960068, + 0.012840221635997295, + -0.028157850727438927, + 0.04595288634300232, + 0.06652745604515076, + -0.018369069322943687, + 0.023067081347107887, + 0.047282226383686066, + 0.046677980571985245, + -0.018640980124473572, + -0.0010640389518812299, + 0.03142077848315239, + -0.016511013731360435, + -0.013489785604178905, + 0.018958209082484245, + 0.017598656937479973, + 0.009917182847857475, + 0.011714814230799675, + -0.015340288169682026, + 0.0061670830473303795, + 0.02423025295138359, + 0.008308378979563713, + -0.08719265460968018, + -0.006673138588666916, + -0.009607506915926933, + 0.03022739291191101, + 0.01842949539422989, + 0.04181380569934845, + -0.00946399848908186, + 0.05160258337855339, + -0.02003074623644352, + 0.026209158822894096, + -0.02288580685853958, + 0.023263460025191307, + 0.020468823611736298, + 0.029562722891569138, + 0.008648267015814781, + 0.009260065853595734, + 0.03102801740169525, + -0.0043958877213299274, + 0.018822254613041878, + 0.05145152285695076, + -0.008353697136044502, + 0.010075797326862812, + 0.0065447366796433926, + -0.0019637986551970243, + 0.018701404333114624, + 0.002409429755061865, + -0.007435998879373074, + 0.007269831374287605, + 0.011858322657644749, + -0.01428285799920559, + 0.030242498964071274, + -0.023505158722400665, + 0.01429041102528572, + -0.002298021921887994, + 0.05024303123354912, + 0.011971618048846722, + -0.004543172661215067, + 0.01213778555393219, + -0.0005126647301949561, + 0.013942969962954521, + -0.046829044818878174, + 0.025317896157503128, + 0.016873562708497047, + -0.02871677838265896, + 0.017553338780999184, + 0.026450855657458305, + 0.01732674613595009, + -0.023248353973031044, + 0.031994812190532684, + 0.015461137518286705, + 0.030484197661280632, + 0.007454881444573402, + -0.002607697853818536, + -0.025997672230005264, + -0.031541626900434494, + -0.026209158822894096, + 0.009411127306520939, + -0.021118387579917908, + 0.03133014217019081, + 0.014804020524024963, + 0.007772110402584076, + -0.026390431448817253, + -0.040544889867305756, + 0.004592267330735922, + 0.0017768600955605507, + 0.009199640713632107, + 0.006982814520597458, + 0.0058196415193378925, + -0.01613336056470871, + -0.0172814279794693, + -0.024018768221139908, + -0.014569874852895737, + 0.06272070854902267, + -0.02503087930381298, + 0.005513742100447416, + -0.029789313673973083, + 0.017115259543061256, + -0.007983596995472908, + 0.053173623979091644, + -0.012032043188810349, + 0.017462700605392456, + -0.01738717034459114, + 0.02661702409386635, + 0.0555603951215744, + 0.005929161328822374, + -0.05015239492058754, + 0.027039995416998863, + 0.04951793700456619, + 0.00765503803268075, + 0.02232687920331955, + -0.011352266184985638, + 0.02726658806204796, + -0.006552289705723524, + 0.032840754836797714, + 0.020151594653725624, + 0.018323751166462898, + -0.0482490211725235, + -0.015423372387886047, + 0.0720260888338089, + -0.032387569546699524, + 0.030333135277032852, + 0.03157183900475502, + -0.04664776846766472, + 0.011858322657644749, + -0.029789313673973083, + -0.03716111183166504, + 0.02817295677959919, + 0.046738408505916595, + -0.007024356629699469, + 0.000802513852249831, + 0.08380888402462006, + -8.851255552144721e-05, + 0.000924779218621552, + -0.024200040847063065, + -0.02492513693869114, + -0.023958342149853706, + -0.0045658317394554615, + -0.00911655742675066, + -0.020861582830548286, + 0.05281107500195503, + -0.007809875998646021, + -0.004482747986912727, + -0.005540178157389164, + 0.032145872712135315, + 0.032296933233737946, + -0.03401903435587883, + -0.04876263067126274, + 0.005211619194597006, + -0.026601918041706085, + 0.0011782791698351502, + -0.020952221006155014, + 0.02652638778090477, + -0.03549943491816521, + -0.008436781354248524, + 0.002339563798159361, + -0.012054702267050743, + -0.03471391648054123, + 0.05855141207575798, + -0.0027512062806636095, + -0.030846744775772095, + -0.00993984192609787, + 0.016918880864977837, + 0.007809875998646021, + -0.048430293798446655, + 0.02507619746029377, + -0.05429147928953171, + -0.006140646990388632, + 0.04849071800708771, + -0.0008582177688367665, + -0.019607773050665855, + 0.09595422446727753, + -0.05468423664569855, + 0.01703972928225994, + -0.014985294081270695, + -0.016359953209757805, + 0.061240304261446, + 0.02661702409386635, + -0.005910278297960758, + 0.016752712428569794, + 0.02483449876308441, + -0.02728169411420822, + 0.005460870917886496, + 0.03003101237118244, + 0.0012991282856091857, + 0.053626809269189835, + 0.004811306484043598, + 0.01987968385219574, + 0.004849072080105543, + 0.008202635683119297, + -0.033203303813934326, + 0.010740467347204685, + 0.02308218739926815, + -0.013799461536109447, + 0.02972888946533203, + 0.019517136737704277, + -0.017855461686849594, + -0.022840488702058792, + -0.003317686729133129, + -0.018505025655031204, + 0.03640580549836159, + -0.0317833237349987, + 0.04945751279592514, + -0.003587709041312337, + 0.02048392966389656, + -0.0008138434495776892, + 0.004380781669169664, + -0.05664803832769394, + -0.01743248850107193, + 0.02093711495399475, + 0.0016786701744422317, + -0.041995078325271606, + -0.0019232007907703519, + 0.018912890926003456, + 0.03755387291312218, + -0.011178545653820038, + 0.04205550253391266, + -0.008882411755621433, + 0.09287256747484207, + -0.002492513507604599, + -0.06087775528430939, + 0.014018501155078411, + 0.038641512393951416, + -0.021571572870016098, + -0.020770946517586708, + -0.022190924733877182, + 0.08115020394325256, + 0.02542363852262497, + 0.018157584592700005, + 0.0005900837131775916, + -0.05151194706559181, + -0.0012660835636779666, + 0.0048906137235462666, + 0.02587682381272316, + 0.017659081146121025, + 0.0011131339706480503, + -0.013044154271483421, + -0.05163279548287392, + 0.013482232578098774, + -0.028248487040400505, + -0.029049113392829895, + 0.02897358313202858, + 0.004120200406759977, + -0.0009818993275985122, + 0.012522992677986622, + 0.01311213243752718, + 0.011820556595921516, + -0.004799976944923401, + -0.014902209863066673, + 0.007938277907669544, + 0.05269022658467293, + 0.011284288950264454, + -0.02258368395268917, + 0.030741000548005104, + -0.023595795035362244, + 0.016662076115608215, + -0.023187929764389992, + -0.021103281527757645, + 0.025589806959033012, + 0.060424573719501495, + 0.008534970693290234, + -0.04577161371707916, + 0.054321691393852234, + 0.024245359003543854, + 0.03420030698180199, + -0.0131650036200881, + -0.005015239585191011, + -0.012447461485862732, + -0.0346837043762207, + -0.027402544394135475, + -0.002122413134202361, + -0.0015880332794040442, + -0.0003125083458144218, + -0.025786185637116432, + 0.005755440331995487, + 0.006087775807827711, + -0.021496040746569633, + 0.001679614302702248, + -0.002014781814068556, + 0.02342962846159935, + 0.009297830983996391, + -8.312804311572108e-06, + 0.0019326421897858381, + 0.022493047639727592, + 0.07692047953605652, + -0.006272825878113508, + -0.029502296820282936, + 0.034442007541656494, + 0.0017069941386580467, + -0.010657384060323238, + -0.0010999160585924983, + -0.036949627101421356, + 0.008376356214284897, + -0.020544353872537613, + -0.01833885721862316, + 0.05259959027171135, + -0.012666501104831696, + 0.00827061291784048, + -0.015574433840811253, + 0.04849071800708771, + 0.08096892386674881, + -0.011495774611830711, + 0.004546949174255133, + 0.017115259543061256, + -0.025937248021364212, + -0.02007606439292431, + 0.028052108362317085, + 0.007300043478608131, + 0.03957809507846832, + -0.039487458765506744, + -0.02836933732032776, + 0.013134791515767574, + -0.00717919459566474, + -0.055076997727155685, + 0.00042981698061339557, + 0.023248353973031044, + 0.011382479220628738, + -0.017900779843330383, + 0.03265948221087456, + 0.01808205246925354, + -0.01747780665755272, + 0.01018909364938736, + 0.01238703727722168, + 0.0038596196100115776, + -0.003646245226264, + -0.009932288900017738, + 0.03471391648054123, + -0.0022885806392878294, + 0.00021172204287722707, + -0.021450722590088844, + -0.08809902518987656, + 0.03220629692077637, + -0.03265948221087456, + -0.032840754836797714, + -0.020000534132122993, + -0.026450855657458305, + -0.016903774812817574, + -0.02648106962442398, + 0.020121382549405098, + 0.0060462336987257, + 0.031692687422037125, + 0.04495588317513466, + 0.016223996877670288, + -0.011284288950264454, + 0.0036235861480236053, + -0.02542363852262497, + 0.07885406911373138, + -0.009109004400670528, + -0.013784355483949184, + 0.012115126475691795, + -0.00829327292740345, + -0.012575863860547543, + -0.04625501111149788, + 0.031450990587472916, + 0.04296186938881874, + 0.03972915560007095, + 0.0031080888584256172, + -0.028701672330498695, + 0.04172316566109657, + 0.04275038465857506, + 0.028052108362317085, + 0.03586198389530182, + 0.025061091408133507, + 0.06296240538358688, + -0.01028728298842907, + -0.031148867681622505, + -0.022810276597738266, + -0.02483449876308441, + -0.07033420354127884, + 0.028490185737609863, + -0.013874992728233337, + 0.00646920595318079, + 0.027100421488285065, + 0.0, + 0.03957809507846832, + 0.013399149291217327, + 0.004278814885765314, + 0.023067081347107887, + 0.0012330389581620693, + -0.03087695688009262, + -0.038037266582250595, + -0.008285719901323318, + 0.0021167483646422625, + -0.06235815957188606, + 0.003432871075347066, + 0.00827061291784048, + -0.027236375957727432, + -0.005324915517121553, + -0.03223650902509689, + 0.06519811600446701, + 0.016359953209757805, + 0.022417515516281128, + -0.010022926144301891, + -0.019456712529063225, + -0.02886783890426159, + -0.021148599684238434, + -0.025997672230005264, + -0.009547082707285881, + 0.022190924733877182, + -0.016254210844635963, + 0.055771879851818085, + -0.010249517858028412, + -0.05537911877036095, + 0.0248798169195652, + 0.0359526202082634, + -0.005060557741671801, + -0.04087722301483154, + -0.1198219284415245, + 0.024910029023885727, + 0.007983596995472908, + 0.029985694214701653, + -0.028233380988240242, + -0.0013831562828272581, + -0.0176288690418005, + -0.07208651304244995, + 0.012877986766397953, + -0.012251081876456738, + 0.030786318704485893, + -0.04335463047027588, + -0.00899570807814598, + -0.07468476891517639, + -0.004180625081062317, + 0.05643654987215996, + 0.023051973432302475, + -0.01083865761756897, + -0.03462328016757965, + -0.022568577900528908, + 0.03915512189269066, + 0.008504758588969707, + 0.01555932778865099, + 0.024109404534101486, + -0.0035121783148497343, + -0.03102801740169525, + 0.020408399403095245, + 0.004969920963048935, + -0.11130206286907196, + 0.02352026477456093, + -0.015453584492206573, + 0.03323351591825485, + 0.06084754317998886, + -0.0007723015733063221, + 0.010853763669729233, + -0.021994544193148613, + 0.06713169813156128, + -0.040695950388908386, + -0.00619351863861084, + 0.005468423943966627, + 0.02258368395268917, + -0.0032723683398216963, + -0.026737872511148453, + 0.04281080886721611, + 0.05803780257701874, + -0.0013227316085249186 + ], + "result": "--- 结果 1 (相似度: 1.000) ---\n文件路径: C:\\Steam\\steamapps\\common\\RimWorld\\Data\\dll1.6\\Verse\\ThingOwner.txt\n\npublic class ThingOwner : ThingOwner, IList, ICollection, IEnumerable, IEnumerable where T : Thing\n{\n\tprivate List innerList = new List();\n\n\tpublic List InnerListForReading => innerList;\n\n\tpublic new T this[int index] => innerList[index];\n\n\tpublic override int Count => innerList.Count;\n\n\tT IList.this[int index]\n\t{\n\t\tget\n\t\t{\n\t\t\treturn innerList[index];\n\t\t}\n\t\tset\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow setting individual elements.\");\n\t\t}\n\t}\n\n\tbool ICollection.IsReadOnly => true;\n\n\tpublic ThingOwner()\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner)\n\t{\n\t}\n\n\tpublic ThingOwner(IThingHolder owner, bool oneStackOnly, LookMode contentsLookMode = LookMode.Deep, bool removeContentsIfDestroyed = true)\n\t\t: base(owner, oneStackOnly, contentsLookMode, removeContentsIfDestroyed)\n\t{\n\t}\n\n\tpublic override void ExposeData()\n\t{\n\t\tbase.ExposeData();\n\t\tScribe_Collections.Look(ref innerList, \"innerList\", true, contentsLookMode);\n\t\tif (Scribe.mode == LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\tint num = innerList.RemoveAll((T x) => x == null || (x is MinifiedThing minifiedThing && minifiedThing.InnerThing == null));\n\t\t\tif (num > 0)\n\t\t\t{\n\t\t\t\tLog.Warning($\"ThingOwner removed {num} invalid entries during PostLoadInit.\");\n\t\t\t}\n\t\t}\n\t\tif (Scribe.mode != LoadSaveMode.LoadingVars && Scribe.mode != LoadSaveMode.PostLoadInit)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] != null)\n\t\t\t{\n\t\t\t\tinnerList[i].holdingOwner = this;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic List.Enumerator GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tpublic override int GetCountCanAccept(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (!(item is T))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn base.GetCountCanAccept(item, canMergeWithExistingStacks);\n\t}\n\n\tpublic override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (count <= 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item?.ToString() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + count + \" of \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\tint stackCount = item.stackCount;\n\t\tint num = Mathf.Min(stackCount, count);\n\t\tThing thing = item.SplitOff(num);\n\t\tif (!TryAdd((T)thing, canMergeWithExistingStacks))\n\t\t{\n\t\t\tif (thing != item)\n\t\t\t{\n\t\t\t\tint result = stackCount - item.stackCount - thing.stackCount;\n\t\t\t\titem.TryAbsorbStack(thing, respectStackLimit: false);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn stackCount - item.stackCount;\n\t\t}\n\t\tCompPushable compPushable = item.TryGetComp();\n\t\tif (compPushable != null && owner is Pawn pawn)\n\t\t{\n\t\t\tcompPushable.OnStartedCarrying(pawn);\n\t\t}\n\t\treturn num;\n\t}\n\n\tpublic override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true)\n\t{\n\t\tif (item == null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add null item to ThingOwner.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (Contains(item))\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this item is already here.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner != null)\n\t\t{\n\t\t\tLog.Warning(\"Tried to add \" + item.ToStringSafe() + \" to ThingOwner but this thing is already in another container. owner=\" + owner.ToStringSafe() + \", current container owner=\" + item.holdingOwner.Owner.ToStringSafe() + \". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!CanAcceptAnyOf(item, canMergeWithExistingStacks))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (canMergeWithExistingStacks)\n\t\t{\n\t\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t\t{\n\t\t\t\tT val = innerList[i];\n\t\t\t\tif (!val.CanStackWith(item))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tint num = Mathf.Min(item.stackCount, val.def.stackLimit - val.stackCount);\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tThing other = item.SplitOff(num);\n\t\t\t\t\tint stackCount = val.stackCount;\n\t\t\t\t\tval.TryAbsorbStack(other, respectStackLimit: true);\n\t\t\t\t\tif (val.stackCount > stackCount)\n\t\t\t\t\t{\n\t\t\t\t\t\tNotifyAddedAndMergedWith(val, val.stackCount - stackCount);\n\t\t\t\t\t}\n\t\t\t\t\tif (item.Destroyed || item.stackCount == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Count >= maxStacks)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\titem.holdingOwner = this;\n\t\tinnerList.Add(item2);\n\t\tNotifyAdded(item2);\n\t\treturn true;\n\t}\n\n\tprotected override void NotifyAdded(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemAdded(item as T);\n\t\t}\n\t\tbase.NotifyAdded(item);\n\t}\n\n\tprotected override void NotifyRemoved(Thing item)\n\t{\n\t\tif (owner is IThingHolderEvents thingHolderEvents)\n\t\t{\n\t\t\tthingHolderEvents.Notify_ItemRemoved(item as T);\n\t\t}\n\t\tbase.NotifyRemoved(item);\n\t}\n\n\tpublic void TryAddRangeOrTransfer(IEnumerable things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false)\n\t{\n\t\tif (things == this)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif (things is ThingOwner thingOwner)\n\t\t{\n\t\t\tthingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks);\n\t\t\tif (destroyLeftover)\n\t\t\t{\n\t\t\t\tthingOwner.ClearAndDestroyContents();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (things is IList list)\n\t\t{\n\t\t\tfor (int i = 0; i < list.Count; i++)\n\t\t\t{\n\t\t\t\tif (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t\t{\n\t\t\t\t\tlist[i].Destroy();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tforeach (T thing in things)\n\t\t{\n\t\t\tif (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover)\n\t\t\t{\n\t\t\t\tthing.Destroy();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int IndexOf(Thing item)\n\t{\n\t\tif (!(item is T item2))\n\t\t{\n\t\t\treturn -1;\n\t\t}\n\t\treturn innerList.IndexOf(item2);\n\t}\n\n\tpublic override bool Remove(Thing item)\n\t{\n\t\tif (!Contains(item))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (item.holdingOwner == this)\n\t\t{\n\t\t\titem.holdingOwner = null;\n\t\t}\n\t\tint index = innerList.LastIndexOf((T)item);\n\t\tinnerList.RemoveAt(index);\n\t\tNotifyRemoved(item);\n\t\treturn true;\n\t}\n\n\tpublic int RemoveAll(Predicate predicate)\n\t{\n\t\tint num = 0;\n\t\tfor (int num2 = innerList.Count - 1; num2 >= 0; num2--)\n\t\t{\n\t\t\tif (predicate(innerList[num2]))\n\t\t\t{\n\t\t\t\tRemove(innerList[num2]);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t\treturn num;\n\t}\n\n\tprotected override Thing GetAt(int index)\n\t{\n\t\treturn innerList[index];\n\t}\n\n\tpublic void GetThingsOfType(List list) where J : Thing\n\t{\n\t\tfor (int i = 0; i < innerList.Count; i++)\n\t\t{\n\t\t\tif (innerList[i] is J item)\n\t\t\t{\n\t\t\t\tlist.Add(item);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true)\n\t{\n\t\tThing resultingTransferredItem2;\n\t\tint result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks);\n\t\tresultingTransferredItem = (T)resultingTransferredItem2;\n\t\treturn result;\n\t}\n\n\tpublic new T Take(Thing thing, int count)\n\t{\n\t\treturn (T)base.Take(thing, count);\n\t}\n\n\tpublic new T Take(Thing thing)\n\t{\n\t\treturn (T)base.Take(thing);\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out T resultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing resultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, count, out resultingThing2, placedAction2, nearPlaceValidator);\n\t\tresultingThing = (T)resultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, mode, out lastResultingThing2, placedAction2, nearPlaceValidator);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tpublic bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out T lastResultingThing, Action placedAction = null, Predicate nearPlaceValidator = null)\n\t{\n\t\tAction placedAction2 = null;\n\t\tif (placedAction != null)\n\t\t{\n\t\t\tplacedAction2 = delegate(Thing t, int c)\n\t\t\t{\n\t\t\t\tplacedAction((T)t, c);\n\t\t\t};\n\t\t}\n\t\tThing lastResultingThing2;\n\t\tbool result = TryDrop(thing, dropLoc, map, mode, out lastResultingThing2, placedAction2, nearPlaceValidator, playDropSound: true);\n\t\tlastResultingThing = (T)lastResultingThing2;\n\t\treturn result;\n\t}\n\n\tint IList.IndexOf(T item)\n\t{\n\t\treturn innerList.IndexOf(item);\n\t}\n\n\tvoid IList.Insert(int index, T item)\n\t{\n\t\tthrow new InvalidOperationException(\"ThingOwner doesn't allow inserting individual elements at any position.\");\n\t}\n\n\tvoid ICollection.Add(T item)\n\t{\n\t\tTryAdd(item);\n\t}\n\n\tvoid ICollection.CopyTo(T[] array, int arrayIndex)\n\t{\n\t\tinnerList.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection.Contains(T item)\n\t{\n\t\treturn innerList.Contains(item);\n\t}\n\n\tbool ICollection.Remove(T item)\n\t{\n\t\treturn Remove(item);\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn innerList.GetEnumerator();\n\t}\n}\n\n", + "timestamp": "2025-08-24 20:56:53,480" } } \ No newline at end of file diff --git a/MCP/web_api_server.py b/MCP/web_api_server.py new file mode 100644 index 00000000..5a29b922 --- /dev/null +++ b/MCP/web_api_server.py @@ -0,0 +1,249 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +RimWorld知识库Web API服务器 +提供HTTP接口,可以通过浏览器或HTTP客户端访问 +""" +import os +import sys +import json +from http.server import HTTPServer, BaseHTTPRequestHandler +from urllib.parse import urlparse, parse_qs +import threading +import webbrowser + +# 添加MCP路径 +MCP_DIR = os.path.dirname(os.path.abspath(__file__)) +SDK_PATH = os.path.join(MCP_DIR, 'python-sdk', 'src') +if SDK_PATH not in sys.path: + sys.path.insert(0, SDK_PATH) + +class RimWorldAPIHandler(BaseHTTPRequestHandler): + """HTTP请求处理器""" + + def do_GET(self): + """处理GET请求""" + parsed_url = urlparse(self.path) + + if parsed_url.path == '/': + self.serve_web_interface() + elif parsed_url.path == '/query': + self.handle_query_get(parsed_url) + elif parsed_url.path == '/api/query': + self.handle_api_query_get(parsed_url) + else: + self.send_error(404, "Not Found") + + def do_POST(self): + """处理POST请求""" + if self.path == '/api/query': + self.handle_api_query_post() + else: + self.send_error(404, "Not Found") + + def serve_web_interface(self): + """提供Web界面""" + html = """ + + + + + + RimWorld 知识库 + + + +
    +

    🎮 RimWorld 知识库

    +

    直接查询RimWorld游戏的C#源码和XML定义

    +
    + +
    + + +
    + +
    +

    💡 查询示例:

    +
    • ThingDef的定义和用法
    +
    • 如何创建Building
    +
    • Pawn类的主要方法
    +
    • CompPower的使用
    +
    + + + + + + + """ + + self.send_response(200) + self.send_header('Content-Type', 'text/html; charset=utf-8') + self.end_headers() + self.wfile.write(html.encode('utf-8')) + + def handle_query_get(self, parsed_url): + """处理GET查询请求""" + params = parse_qs(parsed_url.query) + question = params.get('q', [''])[0] + + if not question: + self.send_error(400, "Missing 'q' parameter") + return + + try: + from mcpserver_stdio import get_context + result = get_context(question) + + self.send_response(200) + self.send_header('Content-Type', 'text/plain; charset=utf-8') + self.end_headers() + self.wfile.write(result.encode('utf-8')) + except Exception as e: + self.send_error(500, f"Query failed: {e}") + + def handle_api_query_get(self, parsed_url): + """处理API GET查询""" + params = parse_qs(parsed_url.query) + question = params.get('q', [''])[0] + + if not question: + response = {"success": False, "error": "Missing 'q' parameter"} + else: + try: + from mcpserver_stdio import get_context + result = get_context(question) + response = {"success": True, "result": result} + except Exception as e: + response = {"success": False, "error": str(e)} + + self.send_response(200) + self.send_header('Content-Type', 'application/json; charset=utf-8') + self.end_headers() + self.wfile.write(json.dumps(response, ensure_ascii=False).encode('utf-8')) + + def handle_api_query_post(self): + """处理API POST查询""" + content_length = int(self.headers['Content-Length']) + post_data = self.rfile.read(content_length) + + try: + data = json.loads(post_data.decode('utf-8')) + question = data.get('question', '') + + if not question: + response = {"success": False, "error": "Missing 'question' field"} + else: + from mcpserver_stdio import get_context + result = get_context(question) + response = {"success": True, "result": result} + except Exception as e: + response = {"success": False, "error": str(e)} + + self.send_response(200) + self.send_header('Content-Type', 'application/json; charset=utf-8') + self.send_header('Access-Control-Allow-Origin', '*') + self.end_headers() + self.wfile.write(json.dumps(response, ensure_ascii=False).encode('utf-8')) + + def log_message(self, format, *args): + """自定义日志输出""" + print(f"[{self.address_string()}] {format % args}") + +def start_server(port=8080, open_browser=True): + """启动Web服务器""" + server_address = ('', port) + httpd = HTTPServer(server_address, RimWorldAPIHandler) + + print(f"🌐 RimWorld知识库Web服务器启动") + print(f"📍 服务地址: http://localhost:{port}") + print(f"🔍 查询API: http://localhost:{port}/api/query?q=您的问题") + print(f"💻 Web界面: http://localhost:{port}") + print("按 Ctrl+C 停止服务器") + + if open_browser: + # 延迟打开浏览器 + def open_browser_delayed(): + import time + time.sleep(1) + webbrowser.open(f'http://localhost:{port}') + + thread = threading.Thread(target=open_browser_delayed) + thread.daemon = True + thread.start() + + try: + httpd.serve_forever() + except KeyboardInterrupt: + print("\n🛑 服务器已停止") + httpd.shutdown() + +if __name__ == "__main__": + import argparse + + parser = argparse.ArgumentParser(description='RimWorld知识库Web API服务器') + parser.add_argument('--port', '-p', type=int, default=8080, help='服务器端口 (默认: 8080)') + parser.add_argument('--no-browser', action='store_true', help='不自动打开浏览器') + + args = parser.parse_args() + + start_server(args.port, not args.no_browser) \ No newline at end of file diff --git a/MCP/使用指南.md b/MCP/使用指南.md new file mode 100644 index 00000000..9fd0dcb5 --- /dev/null +++ b/MCP/使用指南.md @@ -0,0 +1,102 @@ +# RimWorld 知识库 - 绕过 Qoder IDE 使用指南 + +由于 Qoder IDE 中的 MCP 连接可能存在问题,我们提供了多种直接访问 RimWorld 知识库的方法。 + +## 🚀 方法 1:直接 Python 调用 + +最简单直接的方法: + +```bash +# 直接查询 +python direct_mcp_client.py -q "ThingDef是什么" + +# 交互模式 +python direct_mcp_client.py -i + +# 查看帮助 +python direct_mcp_client.py -h +``` + +### 优点: +- ✅ 最快速,无需额外依赖 +- ✅ 支持交互模式 +- ✅ 直接在命令行使用 + +## 🛠️ 方法 2:命令行工具 + +专业的命令行查询工具: + +```bash +# 基本查询 +python rimworld_query.py "ThingDef的定义" + +# 保存结果到文件 +python rimworld_query.py "Building类的方法" --output building_info.txt + +# 显示原始结果(不格式化) +python rimworld_query.py "Pawn类" --raw + +# 查看示例 +python rimworld_query.py --list-examples +``` + +### 优点: +- ✅ 结果可保存到文件 +- ✅ 支持原始输出格式 +- ✅ 内置查询示例 + +## 📝 常用查询示例 + +```bash +# 查询类定义 +"ThingDef的定义和用法" +"Building类有哪些方法" +"Pawn类的构造函数" + +# 查询特定方法 +"GenConstruct.CanPlaceBlueprintAt 方法" +"Building_Door 的开关逻辑" +"CompPower 的电力管理" + +# 查询XML相关 +"XML中的defName规则" +"如何定义新的ThingDef" +"建筑物的XML结构" +``` + +## 🔧 故障排除 + +### 如果出现导入错误: +```bash +# 确保在正确的目录 +cd "C:\Steam\steamapps\common\RimWorld\Mods\3516260226\MCP" + +# 检查 Python 环境 +python -c "import mcp; print('MCP SDK 正常')" +``` + +### 如果查询结果为空: +- 尝试使用更具体的关键词 +- 检查关键词拼写 +- 使用英文类名或方法名 + +### 如果 Web 服务器无法启动: +- 检查端口是否被占用 +- 尝试使用不同的端口号 +- 确保没有其他程序占用该端口 + +## 💡 推荐使用场景 + +- **快速查询**: 使用方法 1 (direct_mcp_client.py) +- **批量处理**: 使用方法 2 (rimworld_query.py) +- **团队共享**: 使用方法 3 (web_api_server.py) +- **集成开发**: 使用 Web API 接口 + +## 🎯 性能优化 + +所有方法都已经过优化: +- 向量化处理限制在 10 个文件以内 +- API 调用超时设置为 12-15 秒 +- 支持本地缓存加速重复查询 + +现在您可以完全绕过 Qoder IDE,直接使用 RimWorld 知识库了! \ No newline at end of file diff --git a/Source/WulaFallenEmpire/3516260226.code-workspace b/Source/WulaFallenEmpire/3516260226.code-workspace index b9f86d60..2d26aeb1 100644 --- a/Source/WulaFallenEmpire/3516260226.code-workspace +++ b/Source/WulaFallenEmpire/3516260226.code-workspace @@ -5,14 +5,7 @@ "path": "../.." }, { - "name": "Data", - "path": "../../../../Data" - }, - { - "path": "../../../../../../workshop/content/294100/3534748687" - }, - { - "path": "../../../../../../workshop/content/294100/3550544871" + "path": "../../../../../../workshop/content/294100/3551234893/1.6/Assemblies/ShelterShuttle" } ], "settings": {} diff --git a/Source/WulaFallenEmpire/WULA_Shuttle/Building_ArmedShuttleWithPocket.cs b/Source/WulaFallenEmpire/WULA_Shuttle/Building_ArmedShuttleWithPocket.cs new file mode 100644 index 00000000..6bc8298b --- /dev/null +++ b/Source/WulaFallenEmpire/WULA_Shuttle/Building_ArmedShuttleWithPocket.cs @@ -0,0 +1,1206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using RimWorld.Planet; +using UnityEngine; +using Verse; +using Verse.AI; +using Verse.Sound; + +namespace WulaFallenEmpire +{ + /// + /// 内置空间武装穿梭机 - 基于原版MapPortal机制的口袋空间实现 + /// 结合了武装防御能力和口袋空间技术的复合型载具 + /// + [StaticConstructorOnStartup] + public class Building_ArmedShuttleWithPocket : Building_ArmedShuttle, IThingHolder + { + #region 静态图标定义(使用原版MapPortal的图标) + + /// 查看口袋地图图标 + private static readonly Texture2D ViewPocketMapTex = ContentFinder.Get("UI/Commands/ViewCave"); + + /// 取消进入图标 + private static readonly Texture2D CancelEnterTex = ContentFinder.Get("UI/Designators/Cancel"); + + /// 默认进入图标 + private static readonly Texture2D DefaultEnterTex = ContentFinder.Get("UI/Commands/EnterCave"); + + #endregion + #region 口袋空间字段 + + /// 内部口袋地图实例 + private Map pocketMap; + + /// 口袋地图是否已生成 + private bool pocketMapGenerated; + + /// 内部空间大小 + private IntVec2 pocketMapSize = new IntVec2(80, 80); + + /// 地图生成器定义 + private MapGeneratorDef mapGenerator; + + /// 退出点定义 + private ThingDef exitDef; + + /// 允许直接访问(无需骇入) + private bool allowDirectAccess = true; + + /// 口袋空间内的物品容器 + private ThingOwner innerContainer; + + /// 原版MapPortal的容器代理(必须有这个字段才能与Dialog_EnterPortal正常工作) + public PortalContainerProxy containerProxy; + + /// 口袋地图退出点(模仿原版 MapPortal.exit) + public Building_PocketMapExit exit; + + /// 是否已经进入过(模仿原版 MapPortal.beenEntered) + protected bool beenEntered; + + /// 待加载物品列表(模仿原版 MapPortal.leftToLoad) + public List leftToLoad; + + /// 是否已通知无法加载更多(模仿原版 MapPortal.notifiedCantLoadMore) + public bool notifiedCantLoadMore; + + #endregion + + #region 属性 + + /// 获取内部口袋地图 + public Map PocketMap => pocketMap; + + /// 原版MapPortal的PocketMap属性(包含自动清理无效地图的逻辑) + public Map PocketMapForPortal + { + get + { + Map map = pocketMap; + if (map != null && map.Parent?.HasMap == false) + { + pocketMap = null; + } + return pocketMap; + } + } + + /// 口袋地图是否存在 + public bool PocketMapExists => PocketMapForPortal != null; + + /// 口袋地图是否已生成 + public bool PocketMapGenerated => pocketMapGenerated; + + /// 是否允许直接访问口袋空间 + public bool AllowDirectAccess => allowDirectAccess; + + /// 内部容器 + public ThingOwner InnerContainer => innerContainer; + + /// + /// 获取进入按钮的图标 + /// + protected virtual Texture2D EnterTex => DefaultEnterTex; + + // 人员传送相关属性已删除 - 不再使用Dialog_EnterPortal + + /// 加载是否正在进行(模仿原版 MapPortal.LoadInProgress) + public bool LoadInProgress + { + get + { + if (leftToLoad != null) + { + return leftToLoad.Any(); + } + return false; + } + } + + /// 是否有Pawn可以加载任何东西(模仿原版 MapPortal.AnyPawnCanLoadAnythingNow) + public bool AnyPawnCanLoadAnythingNow + { + get + { + if (!LoadInProgress) + { + return false; + } + if (!Spawned) + { + return false; + } + // 简化版本,只检查基本条件 + return Map.mapPawns.AllPawnsSpawned.Any(p => p.IsColonist && p.CanReach(this, PathEndMode.Touch, Danger.Deadly)); + } + } + + #endregion + + #region 构造函数 + + public Building_ArmedShuttleWithPocket() + { + innerContainer = new ThingOwner(this, oneStackOnly: false); + } + + #endregion + + #region 基础重写方法 + + + + public override void PostMake() + { + base.PostMake(); + if (innerContainer == null) + { + innerContainer = new ThingOwner(this, oneStackOnly: false); + } + } + + public override void ExposeData() + { + base.ExposeData(); + + // 模仿原版MapPortal.ExposeData的逻辑 + Map map = pocketMap; + if (map != null && map.Parent?.HasMap == false) + { + pocketMap = null; + } + + Scribe_Deep.Look(ref pocketMap, "pocketMap"); + Scribe_Values.Look(ref pocketMapGenerated, "pocketMapGenerated", false); + Scribe_Values.Look(ref pocketMapSize, "pocketMapSize", new IntVec2(80, 80)); + Scribe_Defs.Look(ref mapGenerator, "mapGenerator"); + Scribe_Defs.Look(ref exitDef, "exitDef"); + Scribe_Values.Look(ref allowDirectAccess, "allowDirectAccess", true); + Scribe_Deep.Look(ref innerContainer, "innerContainer", this); + + // 模仿原版MapPortal,持久化leftToLoad和exit + Scribe_References.Look(ref exit, "exit"); + Scribe_Values.Look(ref beenEntered, "beenEntered", defaultValue: false); + Scribe_Collections.Look(ref leftToLoad, "leftToLoad", LookMode.Deep); + Scribe_Values.Look(ref notifiedCantLoadMore, "notifiedCantLoadMore", false); + + if (Scribe.mode == LoadSaveMode.PostLoadInit) + { + if (innerContainer == null) + { + innerContainer = new ThingOwner(this, oneStackOnly: false); + } + // 模仿原版MapPortal,清理无效的leftToLoad条目 + leftToLoad?.RemoveAll((TransferableOneWay x) => x.AnyThing == null); + } + } + + public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) + { + // 清理口袋地图 + if (pocketMap != null && pocketMapGenerated) + { + try + { + // 将口袋空间中的物品和人员转移到主地图 + TransferAllFromPocketToMainMap(); + + // 销毁口袋地图 + PocketMapUtility.DestroyPocketMap(pocketMap); + } + catch (Exception ex) + { + Log.Error($"[WULA] Error cleaning up pocket map: {ex}"); + } + } + base.DeSpawn(mode); + } + + /// + /// 模仿原版MapPortal.Tick方法,处理加载进度通知和穿梭机状态变化 + /// + protected override void Tick() + { + base.Tick(); + + // 模仿原版MapPortal的Tick逻辑:处理加载进度通知 + if (this.IsHashIntervalTick(60) && Spawned && LoadInProgress && !notifiedCantLoadMore && !AnyPawnCanLoadAnythingNow && leftToLoad?[0]?.AnyThing != null) + { + notifiedCantLoadMore = true; + Messages.Message("MessageCantLoadMoreIntoPortal".Translate(Label, Faction.OfPlayer.def.pawnsPlural, leftToLoad[0].AnyThing), this, MessageTypeDefOf.CautionInput); + } + + // 每隔一段时间检查退出点目标是否需要更新(处理穿梭机移动的情况) + if (this.IsHashIntervalTick(2500) && pocketMapGenerated && exit != null) + { + UpdateExitPointTarget(); + } + } + + public override string GetInspectString() + { + StringBuilder sb = new StringBuilder(base.GetInspectString()); + + if (pocketMapGenerated) + { + sb.AppendLine("WULA.PocketSpace.Status".Translate() + ": " + "WULA.PocketSpace.Ready".Translate()); + if (innerContainer.Count > 0) + { + sb.AppendLine("WULA.PocketSpace.ItemCount".Translate(innerContainer.Count)); + } + + // 显示口袋空间中的人员数量 + if (pocketMap != null) + { + int pawnCount = pocketMap.mapPawns.AllPawnsSpawned.Where(p => p.IsColonist).Count(); + if (pawnCount > 0) + { + sb.AppendLine("WULA.PocketSpace.PawnCount".Translate(pawnCount)); + } + } + } + else + { + sb.AppendLine("WULA.PocketSpace.Status".Translate() + ": " + "WULA.PocketSpace.NotGenerated".Translate()); + } + + return sb.ToString().TrimEndNewlines(); + } + + #endregion + + #region 口袋空间核心方法 + + // 人员传送方法已删除 - 不再使用Dialog_EnterPortal进行人员传送 + + /// + /// 切换到口袋空间视角 + /// + public void SwitchToPocketSpace() + { + if (pocketMap == null) + { + if (!pocketMapGenerated) + { + CreatePocketMap(); + } + + if (pocketMap == null) + { + Messages.Message("WULA.PocketSpace.CreationFailed".Translate(), this, MessageTypeDefOf.RejectInput); + return; + } + } + + Current.Game.CurrentMap = pocketMap; + Find.CameraDriver.JumpToCurrentMapLoc(pocketMap.Center); + } + + /// + /// 创建口袋地图 - 使用原版PocketMapUtility(模仿 MapPortal.GeneratePocketMap) + /// + private void CreatePocketMap() + { + try + { + // 模仿原版 MapPortal.GeneratePocketMap 的实现 + // 注意:我们不是MapPortal,所以设为null + PocketMapUtility.currentlyGeneratingPortal = null; + pocketMap = GeneratePocketMapInt(); + PocketMapUtility.currentlyGeneratingPortal = null; + + if (pocketMap != null) + { + pocketMapGenerated = true; + + // 在口袋地图中心放置退出点 + PlaceExitInPocketMap(); + + Log.Message($"[WULA] Pocket map created successfully with size {pocketMap.Size}"); + } + else + { + Log.Error("[WULA] Failed to create pocket map"); + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error creating pocket map: {ex}"); + PocketMapUtility.currentlyGeneratingPortal = null; // 确保清理 + } + } + + /// + /// 模仿原版MapPortal.GeneratePocketMapInt + /// + protected virtual Map GeneratePocketMapInt() + { + // 使用自定义地图生成器 + if (mapGenerator == null) + { + mapGenerator = DefDatabase.GetNamed("WULA_PocketSpace_Small", false) + ?? DefDatabase.GetNamed("AncientStockpile", false) + ?? MapGeneratorDefOf.Base_Player; + } + + // 使用自定义尺寸 + IntVec3 mapSize = new IntVec3(pocketMapSize.x, 1, pocketMapSize.z); + + return PocketMapUtility.GeneratePocketMap(mapSize, mapGenerator, GetExtraGenSteps(), this.Map); + } + + /// + /// 模仿原版MapPortal.GetExtraGenSteps + /// + protected virtual IEnumerable GetExtraGenSteps() + { + return Enumerable.Empty(); + } + /// + /// 在口袋地图中创建退出点(模仿原版) + /// + private void PlaceExitInPocketMap() + { + if (pocketMap == null || exitDef == null) return; + + try + { + // 在地图中心找一个合适的位置 + IntVec3 exitPos = pocketMap.Center; + + // 寻找可建造的位置 + if (!exitPos.Standable(pocketMap) || exitPos.GetThingList(pocketMap).Any(t => t.def.category == ThingCategory.Building)) + { + exitPos = CellFinder.RandomClosewalkCellNear(pocketMap.Center, pocketMap, 5, + p => p.Standable(pocketMap) && !p.GetThingList(pocketMap).Any(t => t.def.category == ThingCategory.Building)); + } + + if (exitPos.IsValid) + { + // 创建退出点建筑 + Thing exitBuilding = ThingMaker.MakeThing(exitDef); + if (exitBuilding is Building_PocketMapExit exitPortal) + { + exitPortal.targetMap = this.Map; + exitPortal.targetPos = this.Position; + exitPortal.parentShuttle = this; + exit = exitPortal; // 设置 exit 引用,模仿原版 MapPortal + } + + GenPlace.TryPlaceThing(exitBuilding, exitPos, pocketMap, ThingPlaceMode.Direct); + Log.Message($"[WULA] Created exit point at {exitPos} in pocket map"); + } + else + { + Log.Warning("[WULA] Could not find valid position for exit point in pocket map"); + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error creating exit point: {ex}"); + } + } + + // TransferPawnToPocketSpace方法已删除 - 不再使用单个人员传送 + + /// + /// 将所有物品和人员从口袋空间转移到主地图 + /// + private void TransferAllFromPocketToMainMap() + { + if (pocketMap == null || !Spawned) return; + + try + { + // 转移所有殖民者 + List pawnsToTransfer = pocketMap.mapPawns.AllPawnsSpawned + .Where(p => p.IsColonist).ToList(); + + foreach (Pawn pawn in pawnsToTransfer) + { + IntVec3 spawnPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 5, + p => p.Standable(this.Map) && !p.GetThingList(this.Map).Any(t => t is Pawn)); + + if (spawnPos.IsValid) + { + pawn.DeSpawn(); + GenPlace.TryPlaceThing(pawn, spawnPos, this.Map, ThingPlaceMode.Near); + } + } + + // 转移所有物品到内部容器 + List itemsToTransfer = pocketMap.listerThings.AllThings + .Where(t => t.def.category == ThingCategory.Item && t.def.EverHaulable).ToList(); + + foreach (Thing item in itemsToTransfer) + { + if (item.Spawned) + { + item.DeSpawn(); + if (!innerContainer.TryAdd(item)) + { + // 如果容器满了,丢到穿梭机附近 + IntVec3 dropPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 3); + if (dropPos.IsValid) + { + GenPlace.TryPlaceThing(item, dropPos, this.Map, ThingPlaceMode.Near); + } + } + } + } + + Log.Message($"[WULA] Transferred {pawnsToTransfer.Count} pawns and {itemsToTransfer.Count} items from pocket space"); + } + catch (Exception ex) + { + Log.Error($"[WULA] Error transferring from pocket map: {ex}"); + } + } + + #endregion + + #region Gizmo方法 + + public override IEnumerable GetGizmos() + { + foreach (Gizmo gizmo in base.GetGizmos()) + { + yield return gizmo; + } + + if (allowDirectAccess) + { + if (pocketMap == null) + { + // 创建口袋空间按钮 + Command_Action createCommand = new Command_Action(); + createCommand.action = delegate + { + try + { + Log.Message("[WULA] Creating pocket map..."); + CreatePocketMap(); + + if (pocketMap != null) + { + Messages.Message("WULA.PocketSpace.CreationSuccess".Translate(), this, MessageTypeDefOf.PositiveEvent); + } + else + { + Messages.Message("WULA.PocketSpace.CreationFailed".Translate(), this, MessageTypeDefOf.RejectInput); + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error creating pocket map: {ex}"); + Messages.Message("WULA.PocketSpace.CreationFailed".Translate(), this, MessageTypeDefOf.RejectInput); + } + }; + createCommand.icon = EnterTex; + createCommand.defaultLabel = "WULA.PocketSpace.CreateMap".Translate(); + createCommand.defaultDesc = "WULA.PocketSpace.CreateMapDesc".Translate(); + + // 检查是否可以创建 + string reason; + createCommand.Disabled = !IsEnterable(out reason); + createCommand.disabledReason = reason; + yield return createCommand; + } + // 进入口袋空间按钮已删除 - 按钮无法正常工作 + + // 查看口袋地图按钮(模仿原版MapPortal) + if (pocketMap != null) + { + yield return new Command_Action + { + defaultLabel = "WULA.PocketSpace.ViewMap".Translate(), + defaultDesc = "WULA.PocketSpace.ViewMapDesc".Translate(), + icon = ViewPocketMapTex, + action = delegate + { + // 模仿原版,跳转到口袋地图并选中退出点 + if (exit != null) + { + CameraJumper.TryJumpAndSelect(exit); + } + else + { + SwitchToPocketSpace(); + } + } + }; + } + } + } + + + + #endregion + + #region IThingHolder接口实现 + + public ThingOwner GetDirectlyHeldThings() + { + // 仅在第一次调用时记录日志 + if (containerProxy != null) + { + return containerProxy; + } + else + { + Log.Warning("[WULA] containerProxy is null! Creating new one..."); + containerProxy = new PortalContainerProxy { portal = this }; + Log.Message($"[WULA] Created new containerProxy - portal set: {containerProxy.portal != null}"); + return containerProxy; + } + } + + public void GetChildHolders(List outChildren) + { + ThingOwnerUtility.AppendThingHoldersFromThings(outChildren, GetDirectlyHeldThings()); + } + + #endregion + + #region MapPortal兼容接口(用于物品传送和地图管理) + + /// + /// 检查是否可以进入(模仿原版MapPortal.IsEnterable) + /// + public virtual bool IsEnterable(out string reason) + { + if (!allowDirectAccess) + { + reason = "WULA.PocketSpace.AccessDenied".Translate(); + return false; + } + + if (!Spawned) + { + reason = "WULA.PocketSpace.NotSpawned".Translate(); + return false; + } + + reason = ""; + return true; + } + + /// + /// 获取目标地图(模仿原版MapPortal.GetOtherMap) + /// + public virtual Map GetOtherMap() + { + if (pocketMap == null) + { + CreatePocketMap(); + } + return pocketMap; + } + + /// + /// 获取目标位置(模仿原版MapPortal.GetDestinationLocation) + /// + public virtual IntVec3 GetDestinationLocation() + { + if (exit != null) + { + return exit.Position; + } + return pocketMap?.Center ?? IntVec3.Invalid; + } + + // OnEntered方法已删除 - 不再使用Dialog_EnterPortal机制 + + #endregion + + #region 原版MapPortal的物品传送方法 + + /// + /// 通知有物品被添加(模仿原版 MapPortal.Notify_ThingAdded) + /// + public void Notify_ThingAdded(Thing t) + { + // 检查是否为Pawn类型 + if (t is Pawn pawn) + { + Log.Message($"[WULA] Notify_ThingAdded called for PAWN: {pawn.LabelShort} ({pawn.def.defName})"); + // 对于Pawn,我们不需要更新leftToLoad列表,因为原版也不这样做 + // 只需要通知CompTransporter + } + else + { + Log.Message($"[WULA] Notify_ThingAdded called for ITEM: {t?.def?.defName} x{t?.stackCount}"); + Log.Message($"[WULA] leftToLoad count before: {leftToLoad?.Count ?? 0}"); + + int removedCount = SubtractFromToLoadList(t, t.stackCount); + + Log.Message($"[WULA] Removed {removedCount} items from leftToLoad list"); + Log.Message($"[WULA] leftToLoad count after: {leftToLoad?.Count ?? 0}"); + } + + // 同时通知CompTransporter组件,确保原版装载系统也得到通知 + var compTransporter = this.GetComp(); + if (compTransporter != null) + { + Log.Message($"[WULA] Notifying CompTransporter about thing added: {t?.def?.defName}"); + try + { + // 调用CompTransporter的Notify_ThingAdded方法(如果存在) + var method = compTransporter.GetType().GetMethod("Notify_ThingAdded", new[] { typeof(Thing) }); + if (method != null) + { + method.Invoke(compTransporter, new object[] { t }); + Log.Message("[WULA] Successfully called CompTransporter.Notify_ThingAdded"); + } + else + { + Log.Message("[WULA] CompTransporter.Notify_ThingAdded method not found"); + } + } + catch (Exception ex) + { + Log.Warning($"[WULA] Failed to notify CompTransporter: {ex.Message}"); + } + } + else + { + Log.Message("[WULA] No CompTransporter found on this building"); + } + } + + /// + /// 添加到加载列表(模仿原版 MapPortal.AddToTheToLoadList) + /// + public void AddToTheToLoadList(TransferableOneWay t, int count) + { + if (!t.HasAnyThing || count <= 0) + { + return; + } + if (leftToLoad == null) + { + leftToLoad = new List(); + } + TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching(t.AnyThing, leftToLoad, TransferAsOneMode.PodsOrCaravanPacking); + if (transferableOneWay != null) + { + for (int i = 0; i < t.things.Count; i++) + { + if (!transferableOneWay.things.Contains(t.things[i])) + { + transferableOneWay.things.Add(t.things[i]); + } + } + if (transferableOneWay.CanAdjustBy(count).Accepted) + { + transferableOneWay.AdjustBy(count); + } + } + else + { + TransferableOneWay transferableOneWay2 = new TransferableOneWay(); + leftToLoad.Add(transferableOneWay2); + transferableOneWay2.things.AddRange(t.things); + transferableOneWay2.AdjustTo(count); + } + } + + /// + /// 从加载列表中减去(模仿原版 MapPortal.SubtractFromToLoadList) + /// + public int SubtractFromToLoadList(Thing t, int count) + { + Log.Message($"[WULA] SubtractFromToLoadList called for: {t?.def?.defName} x{count}"); + + if (leftToLoad == null) + { + Log.Message("[WULA] leftToLoad is null, returning 0"); + return 0; + } + + Log.Message($"[WULA] Searching in leftToLoad list with {leftToLoad.Count} entries"); + TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatchingDesperate(t, leftToLoad, TransferAsOneMode.PodsOrCaravanPacking); + + if (transferableOneWay == null) + { + Log.Message($"[WULA] No matching transferable found for {t?.def?.defName}"); + return 0; + } + + Log.Message($"[WULA] Found matching transferable with CountToTransfer: {transferableOneWay.CountToTransfer}"); + + if (transferableOneWay.CountToTransfer <= 0) + { + Log.Message("[WULA] CountToTransfer <= 0, returning 0"); + return 0; + } + + int num = Mathf.Min(count, transferableOneWay.CountToTransfer); + Log.Message($"[WULA] Adjusting transferable by: -{num}"); + + transferableOneWay.AdjustBy(-num); + transferableOneWay.things.Remove(t); + + Log.Message($"[WULA] After adjustment - CountToTransfer: {transferableOneWay.CountToTransfer}, things.Count: {transferableOneWay.things.Count}"); + + if (transferableOneWay.CountToTransfer <= 0) + { + Log.Message("[WULA] Removing transferable from leftToLoad list"); + leftToLoad.Remove(transferableOneWay); + } + + Log.Message($"[WULA] leftToLoad list now has {leftToLoad.Count} entries"); + return num; + } + + /// + /// 取消加载(模仿原版 MapPortal.CancelLoad) + /// + public void CancelLoad(MapPortal portal = null) + { + // 简化版本:只清理leftToLoad列表 + // 原版需要查找MapPortal相关的Lord,但我们不是MapPortal类型 + if (leftToLoad != null) + { + leftToLoad.Clear(); + } + } + + + + #endregion + + #region 穿梭机状态变化处理 + + /// + /// 更新口袋空间中退出点的目标位置(处理穿梭机位置变化) + /// + public void UpdateExitPointTarget() + { + if (pocketMap == null || exit == null) return; + + try + { + // 如果退出点是我们的Building_PocketMapExit类型,更新其目标位置 + if (exit is Building_PocketMapExit pocketExit) + { + // 更新目标地图和位置 + if (this.Spawned) + { + // 穿梭机在地图上,更新目标位置 + if (pocketExit.targetMap != this.Map || pocketExit.targetPos != this.Position) + { + pocketExit.targetMap = this.Map; + pocketExit.targetPos = this.Position; + pocketExit.parentShuttle = this; + Log.Message($"[WULA] Updated pocket map exit target to shuttle location: {this.Map?.uniqueID} at {this.Position}"); + } + } + else + { + // 穿梭机不在地图上(可能在飞行中),记录警告但保持原有目标 + Log.Warning($"[WULA] Shuttle not spawned, pocket map exit target may be outdated. Current target: {pocketExit.targetMap?.uniqueID} at {pocketExit.targetPos}"); + } + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error updating exit point target: {ex}"); + } + } + + + + /// + /// 重写 SpawnSetup,确保位置变化时更新退出点 + /// + public override void SpawnSetup(Map map, bool respawningAfterLoad) + { + // 保存旧位置信息 + Map oldMap = this.Map; + IntVec3 oldPos = this.Position; + + base.SpawnSetup(map, respawningAfterLoad); + + if (innerContainer == null) + { + innerContainer = new ThingOwner(this, oneStackOnly: false); + } + + // 初始化containerProxy(模仿原版MapPortal) + containerProxy = new PortalContainerProxy + { + portal = this + }; + + // 关键:替换CompTransporter的innerContainer字段,确保一切添加操作都经过我们的代理 + var compTransporter = this.GetComp(); + if (compTransporter != null) + { + try { + var field = typeof(CompTransporter).GetField("innerContainer", + System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + if (field != null) + { + field.SetValue(compTransporter, containerProxy); + } + else + { + Log.Error("[WULA] Failed to find innerContainer field in CompTransporter"); + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error replacing CompTransporter.innerContainer: {ex}"); + } + } + + // 更新退出点目标(处理穿梭机重新部署的情况) + UpdateExitPointTarget(); + + // 从 ThingDef 中读取 portal 配置 + if (def.HasModExtension()) + { + var portalProps = def.GetModExtension(); + if (portalProps.pocketMapGenerator != null) + { + mapGenerator = portalProps.pocketMapGenerator; + } + if (portalProps.exitDef != null) + { + exitDef = portalProps.exitDef; + } + if (portalProps.pocketMapSize != IntVec2.Zero) + { + pocketMapSize = portalProps.pocketMapSize; + } + allowDirectAccess = portalProps.allowDirectAccess; + } + + // 初始化地图生成器和退出点定义(如果 XML 中没有配置) + if (mapGenerator == null) + { + mapGenerator = DefDatabase.GetNamed("AncientStockpile", false) + ?? DefDatabase.GetNamed("Base_Player", false) + ?? MapGeneratorDefOf.Base_Player; + } + + if (exitDef == null) + { + exitDef = DefDatabase.GetNamed("WULA_PocketMapExit", false) + ?? ThingDefOf.Door; + } + + // 如果位置发生了变化,记录日志 + if (oldMap != null && (oldMap != map || oldPos != this.Position)) + { + Log.Message($"[WULA] Shuttle moved from {oldMap?.uniqueID}:{oldPos} to {map?.uniqueID}:{this.Position}, updating pocket map exit target"); + } + } + + #endregion + } + + /// + /// 口袋空间属性配置类 + /// + public class PocketMapProperties : DefModExtension + { + /// 口袋地图生成器 + public MapGeneratorDef pocketMapGenerator; + + /// 退出点定义 + public ThingDef exitDef; + + /// 口袋地图大小 + public IntVec2 pocketMapSize = new IntVec2(13, 13); + + /// 允许直接访问 + public bool allowDirectAccess = true; + } + + // MapPortalAdapter类已删除 - 不再使用Dialog_EnterPortal进行人员传送 + + /// + /// 专为Building_ArmedShuttleWithPocket设计的PortalContainerProxy适配器 + /// 模仿原版PortalContainerProxy的行为,但适配非-MapPortal类型 + /// 这个类拦截所有向容器添加物品和人员的操作 + /// + public class PortalContainerProxy : ThingOwner + { + public Building_ArmedShuttleWithPocket portal; + + public override int Count + { + get + { + // 不记录日志,避免日志刷屏 + return 0; + } + } + + public override int TryAdd(Thing item, int count, bool canMergeWithExistingStacks = true) + { + if (TryAdd(item, canMergeWithExistingStacks)) + { + return count; + } + return 0; + } + + public override bool TryAdd(Thing item, bool canMergeWithExistingStacks = true) + { + return ProcessItemOrPawn(item, canMergeWithExistingStacks); + } + + /// + /// 统一的物品和人员处理方法 + /// 动物当作物品处理,只有殖民者才当作Pawn处理 + /// + private bool ProcessItemOrPawn(Thing item, bool canMergeWithExistingStacks = true) + { + if (portal == null) + { + Log.Error("[WULA] PortalContainerProxy.ProcessItemOrPawn: portal is null!"); + return false; + } + + Log.Message($"[WULA] PortalContainerProxy.ProcessItemOrPawn called for: {item?.def?.defName} ({item?.GetType()?.Name}) x{item?.stackCount}"); + + // 只有殖民者才当作Pawn处理,动物当作物品处理 + if (item is Pawn pawn && pawn.IsColonist) + { + Log.Message($"[WULA] INTERCEPTING COLONIST PAWN: {pawn.LabelShort} ({pawn.def.defName}) - Type: {pawn.GetType().Name}"); + + bool result = TransferPawnToPocketSpace(pawn); + Log.Message($"[WULA] Colonist transfer result: {result}"); + return result; + } + + // 动物和其他所有物品都当作物品处理 + Map otherMap = portal.GetOtherMap(); + IntVec3 destinationLocation = portal.GetDestinationLocation(); + + if (otherMap == null || !destinationLocation.IsValid) + { + Log.Warning("[WULA] PortalContainerProxy: Invalid target map or location, using inner container"); + // 如果目标地图或位置无效,将物品放入内部容器 + return portal.InnerContainer.TryAdd(item, canMergeWithExistingStacks); + } + + // 关键:严格按照原版顺序 - 先通知,再传送 + // 这样能确保leftToLoad列表在物品被传送前就得到更新 + Log.Message($"[WULA] Calling portal.Notify_ThingAdded for: {item?.def?.defName} x{item?.stackCount}"); + portal.Notify_ThingAdded(item); + + // 传送物品(包括动物)到目标地图 + Log.Message($"[WULA] Transporting item/animal to pocket map: {item?.def?.defName}"); + GenDrop.TryDropSpawn(item, destinationLocation, otherMap, ThingPlaceMode.Near, out var _); + + Log.Message($"[WULA] Item/animal transport completed successfully"); + return true; + } + + public override int IndexOf(Thing item) + { + return -1; + } + + public override bool Remove(Thing item) + { + return false; + } + + protected override Thing GetAt(int index) + { + return null; + } + + /// + /// 传送单个Pawn到口袋空间(使用直接传送机制) + /// + private bool TransferPawnToPocketSpace(Pawn pawn) + { + if (pawn == null) + { + Log.Warning("[WULA] TransferPawnToPocketSpace: Pawn is null"); + return false; + } + + if (portal == null) + { + Log.Warning("[WULA] TransferPawnToPocketSpace: Portal is null"); + return false; + } + + if (!pawn.Spawned && pawn.holdingOwner == null) + { + Log.Warning($"[WULA] TransferPawnToPocketSpace: Pawn {pawn.LabelShort} is not spawned and not in a container"); + + // 即使武装没有spawned或不在容器中,仍然尝试传送 + // 记录原始状态并继续 + Log.Message($"[WULA] Attempting to transfer pawn anyway: {pawn.LabelShort}"); + } + + // 创建口袋地图(如果需要) + Map targetMap = portal.GetOtherMap(); + if (targetMap == null) + { + Log.Warning("[WULA] TransferPawnToPocketSpace: Failed to get or create pocket map"); + return false; + } + + IntVec3 destinationLocation = portal.GetDestinationLocation(); + if (!destinationLocation.IsValid) + { + Log.Warning("[WULA] TransferPawnToPocketSpace: Invalid destination location"); + return false; + } + + try + { + // 保存重要状态 + bool wasDrafted = pawn.Drafted; + Map sourceMap = pawn.Map; // 可能为null如果pawn在容器中 + IntVec3 sourcePos = pawn.Position; + ThingOwner owner = pawn.holdingOwner; + + Log.Message($"[WULA] Starting transfer of pawn {pawn.LabelShort} to pocket space"); + + // 通知系统人员被添加,更新装载状态 + portal.Notify_ThingAdded(pawn); + + // 寻找安全的生成位置 + IntVec3 spawnPos = CellFinder.StandableCellNear(destinationLocation, targetMap, 5, + p => p.Standable(targetMap) && !p.GetThingList(targetMap).Any(t => t is Pawn)); + + if (!spawnPos.IsValid) + { + Log.Warning("[WULA] Could not find valid spawn position in pocket map, using center"); + spawnPos = CellFinder.RandomClosewalkCellNear(targetMap.Center, targetMap, 10, + p => p.Standable(targetMap)); + + if (!spawnPos.IsValid) + { + Log.Error("[WULA] All spawn position attempts failed, using map center"); + spawnPos = targetMap.Center; + } + } + + // 关键情况记录 + Log.Message($"[WULA] Found valid spawn position: {spawnPos}"); + Log.Message($"[WULA] Pawn state - Spawned: {pawn.Spawned}, In container: {owner != null}"); + + // 从Pawn当前位置安全移除 + if (owner != null) + { + Log.Message($"[WULA] Removing pawn from container"); + if (!owner.Remove(pawn)) + { + Log.Error($"[WULA] Failed to remove pawn from container!"); + return false; + } + } + else if (pawn.Spawned) + { + Log.Message($"[WULA] Despawning pawn from map {pawn.Map?.uniqueID ?? -1}"); + pawn.DeSpawn(DestroyMode.Vanish); + } + else + { + // Pawn既不在地图上也不在容器中,可能被CompTransporter直接持有 + Log.Message($"[WULA] Pawn in special state - ParentHolder: {pawn.ParentHolder?.ToString() ?? "None"}"); + + // 尝试从CompTransporter中直接提取 + if (pawn.ParentHolder != null) + { + Log.Message($"[WULA] Attempting to extract pawn from ParentHolder: {pawn.ParentHolder}"); + + // 检查是否在特殊容器中 + var parentHolder = pawn.ParentHolder; + if (parentHolder is ThingOwner thingOwner) + { + Log.Message($"[WULA] ParentHolder is a ThingOwner, attempting to remove pawn"); + if (thingOwner.Contains(pawn)) + { + bool removed = thingOwner.Remove(pawn); + Log.Message($"[WULA] Removed from ThingOwner: {removed}"); + } + } + else if (parentHolder.ToString().Contains("CompTransporter")) + { + // 尝试使用反射从CompTransporter中移除 + Log.Message($"[WULA] Attempting to extract from CompTransporter"); + var compTransporter = portal.GetComp(); + if (compTransporter != null) + { + var innerContainerField = typeof(CompTransporter).GetField("innerContainer", + System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + + if (innerContainerField != null) + { + var transporterContainer = innerContainerField.GetValue(compTransporter) as ThingOwner; + if (transporterContainer != null && transporterContainer.Contains(pawn)) + { + bool removed = transporterContainer.Remove(pawn); + Log.Message($"[WULA] Removed from CompTransporter: {removed}"); + } + } + } + } + } + } + + // 确认是否已从原位置移除 + if (pawn.Spawned) + { + Log.Error($"[WULA] Failed to despawn pawn! Still spawned after despawn attempt"); + return false; + } + + // 生成到目标位置 + Log.Message($"[WULA] Spawning pawn at {spawnPos} in map {targetMap.uniqueID}"); + GenSpawn.Spawn(pawn, spawnPos, targetMap); + + // 验证是否成功生成 + if (!pawn.Spawned || pawn.Map != targetMap) + { + Log.Error($"[WULA] Pawn failed to spawn correctly! Spawned: {pawn.Spawned}, Map: {pawn.Map?.uniqueID ?? -1}"); + + // 尝试恢复到原始位置 + if (sourceMap != null && sourceMap.IsPlayerHome) + { + Log.Message($"[WULA] Attempting emergency recovery to original position"); + GenSpawn.Spawn(pawn, sourcePos, sourceMap); + + if (!pawn.Spawned) + { + Log.Error($"[WULA] Emergency recovery failed! Pawn is lost"); + } + } + return false; + } + + // 恢复状态 + if (wasDrafted && pawn.drafter != null) + { + pawn.drafter.Drafted = true; + } + + Log.Message($"[WULA] Pawn {pawn.LabelShort} successfully transferred to pocket space"); + return true; + } + catch (Exception ex) + { + Log.Error($"[WULA] Exception during pawn transfer: {ex}"); + return false; + } + } + } + + +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WULA_Shuttle/Building_PocketMapExit.cs b/Source/WulaFallenEmpire/WULA_Shuttle/Building_PocketMapExit.cs new file mode 100644 index 00000000..0a8235fd --- /dev/null +++ b/Source/WulaFallenEmpire/WULA_Shuttle/Building_PocketMapExit.cs @@ -0,0 +1,146 @@ +using RimWorld; +using Verse; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace WulaFallenEmpire +{ + /// + /// 口袋空间退出点建筑 - 继承自MapPortal以获得完整的双向传送功能 + /// + public class Building_PocketMapExit : MapPortal + { + /// 目标地图 + public Map targetMap; + + /// 目标位置 + public IntVec3 targetPos; + + /// 父穿梭机 + public Building_ArmedShuttleWithPocket parentShuttle; + + public override void ExposeData() + { + base.ExposeData(); + Scribe_References.Look(ref targetMap, "targetMap"); + Scribe_Values.Look(ref targetPos, "targetPos"); + Scribe_References.Look(ref parentShuttle, "parentShuttle"); + } + + /// + /// 重写获取其他地图,返回主地图(模仿原版MapPortal.GetOtherMap) + /// + public override Map GetOtherMap() + { + // 动态更新目标地图,处理穿梭机移动的情况 + UpdateTargetFromParentShuttle(); + return targetMap; + } + + /// + /// 重写获取目标位置,返回主地图上的穿梭机位置(模仿原版MapPortal.GetDestinationLocation) + /// + public override IntVec3 GetDestinationLocation() + { + // 动态更新目标位置,处理穿梭机移动的情况 + UpdateTargetFromParentShuttle(); + return targetPos; + } + + /// + /// 从父穿梭机动态更新目标位置,处理穿梭机移动的情况 + /// + private void UpdateTargetFromParentShuttle() + { + if (parentShuttle != null && parentShuttle.Spawned) + { + // 如果穿梭机还在地图上,更新目标位置 + if (targetMap != parentShuttle.Map || targetPos != parentShuttle.Position) + { + targetMap = parentShuttle.Map; + targetPos = parentShuttle.Position; + Log.Message($"[WULA] Updated exit target to shuttle location: {targetMap?.uniqueID} at {targetPos}"); + } + } + else if (parentShuttle != null && !parentShuttle.Spawned) + { + // 穿梭机不在地图上(可能在飞行中) + // 保持原有目标,但记录警告 + if (this.IsHashIntervalTick(2500)) // 每隔一段时间检查一次 + { + Log.Warning($"[WULA] Parent shuttle is not spawned, exit target may be outdated. Last known: {targetMap?.uniqueID} at {targetPos}"); + } + } + } + + /// + /// 重写是否可进入,检查目标地图是否存在(模仿原版MapPortal.IsEnterable) + /// + public override bool IsEnterable(out string reason) + { + if (targetMap == null) + { + reason = "WULA.PocketSpace.NoTargetMap".Translate(); + return false; + } + reason = ""; + return true; + } + + /// + /// 重写进入事件,处理从口袋空间退出到主地图(模仿原版MapPortal.OnEntered) + /// + public override void OnEntered(Pawn pawn) + { + // 不调用 base.OnEntered,因为我们不需要原版的通知机制 + // 直接处理退出逻辑 + if (targetMap != null && pawn.Spawned) + { + ExitPocketSpace(pawn); + } + } + + /// + /// 重写进入按钮文本 + /// + public override string EnterString => "WULA.PocketSpace.ExitToMainMap".Translate(); + + /// + /// 重写进入按钮图标,使用原版的ViewCave图标 + /// + protected override Texture2D EnterTex => ContentFinder.Get("UI/Commands/ViewCave"); + + /// + /// 单个人员退出口袋空间(简化版本,利用MapPortal功能) + /// + private void ExitPocketSpace(Pawn pawn) + { + if (targetMap == null || !pawn.Spawned) return; + + try + { + // 在目标地图找一个安全位置 + IntVec3 exitPos = CellFinder.RandomClosewalkCellNear(targetPos, targetMap, 3, p => p.Standable(targetMap)); + + // 传送人员 + pawn.DeSpawn(); + GenPlace.TryPlaceThing(pawn, exitPos, targetMap, ThingPlaceMode.Near); + + // 切换到主地图 + if (pawn.IsColonistPlayerControlled) + { + Current.Game.CurrentMap = targetMap; + Find.CameraDriver.JumpToCurrentMapLoc(exitPos); + } + + Messages.Message("WULA.PocketSpace.ExitSuccess".Translate(pawn.LabelShort), MessageTypeDefOf.PositiveEvent); + } + catch (System.Exception ex) + { + Log.Error($"[WULA] Error exiting pocket space: {ex}"); + } + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WULA_Shuttle/GenStep_WulaPocketSpaceSmall.cs b/Source/WulaFallenEmpire/WULA_Shuttle/GenStep_WulaPocketSpaceSmall.cs new file mode 100644 index 00000000..d2c2702b --- /dev/null +++ b/Source/WulaFallenEmpire/WULA_Shuttle/GenStep_WulaPocketSpaceSmall.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using RimWorld; +using Verse; + +namespace WulaFallenEmpire +{ + /// + /// 13x13小型口袋空间生成器 + /// 创建一个简单的13x13空间,边缘是墙,中间是空地,适合作为穿梭机内部空间 + /// + public class GenStep_WulaPocketSpaceSmall : GenStep + { + public override int SeedPart => 928735; // 不同于AncientStockpile的种子 + + public override void Generate(Map map, GenStepParams parms) + { + try + { + Log.Message($"[WULA] Generating WULA pocket space, map size: {map.Size}"); + + // 获取地图边界 + IntVec3 mapSize = map.Size; + + // 生成外围岩石墙壁 + GenerateWalls(map); + + // 生成内部地板 + GenerateFloor(map); + + // 生成一些基础设施(照明等) + GenerateBasicInfrastructure(map); + + Log.Message("[WULA] WULA pocket space generation completed"); + } + catch (Exception ex) + { + Log.Error($"[WULA] Error generating WULA pocket space: {ex}"); + } + } + + /// + /// 生成外围墙壁 + /// + private void GenerateWalls(Map map) + { + IntVec3 mapSize = map.Size; + + // 获取地形和物品定义 + TerrainDef roughTerrain = DefDatabase.GetNamed("Granite_Rough", false) ?? + DefDatabase.GetNamed("Granite_Smooth", false) ?? + DefDatabase.GetNamed("Sandstone_Rough", false); + + ThingDef rockWallDef = DefDatabase.GetNamed("Wall_Rock", false) ?? + DefDatabase.GetNamed("Wall", false); + + // 遍历地图边缘,放置WulaWall + for (int x = 0; x < mapSize.x; x++) + { + for (int z = 0; z < mapSize.z; z++) + { + // 如果是边缘位置,放置WulaWall + if (x == 0 || x == mapSize.x - 1 || z == 0 || z == mapSize.z - 1) + { + IntVec3 pos = new IntVec3(x, 0, z); + + // 设置地形为岩石基础 + if (roughTerrain != null) + { + map.terrainGrid.SetTerrain(pos, roughTerrain); + } + + // 放置WulaWall + ThingDef wallDef = DefDatabase.GetNamed("WulaWall", false); + if (wallDef != null) + { + Thing wall = ThingMaker.MakeThing(wallDef); + wall.SetFaction(null); + GenPlace.TryPlaceThing(wall, pos, map, ThingPlaceMode.Direct); + } + else if (rockWallDef != null) + { + // 如果WulaWall不存在,使用原版岩石墙作为备选 + Thing wall = ThingMaker.MakeThing(rockWallDef); + wall.SetFaction(null); + GenPlace.TryPlaceThing(wall, pos, map, ThingPlaceMode.Direct); + Log.Warning("[WULA] WulaWall not found, using fallback wall"); + } + } + } + } + } + + /// + /// 生成内部地板 + /// + private void GenerateFloor(Map map) + { + IntVec3 mapSize = map.Size; + + // 为内部区域设置WulaFloor + TerrainDef floorDef = DefDatabase.GetNamed("WulaFloor", false); + TerrainDef fallbackFloor = floorDef ?? + DefDatabase.GetNamed("Steel", false) ?? + DefDatabase.GetNamed("MetalTile", false) ?? + DefDatabase.GetNamed("Concrete", false); + + if (floorDef == null) + { + Log.Warning("[WULA] WulaFloor not found, using fallback floor"); + } + + // 清理内部区域并设置正确的地板 + for (int x = 1; x < mapSize.x - 1; x++) + { + for (int z = 1; z < mapSize.z - 1; z++) + { + IntVec3 pos = new IntVec3(x, 0, z); + + // 清理该位置的所有岩石和阻挡物 + ClearCellAndSetFloor(map, pos, fallbackFloor); + } + } + + Log.Message($"[WULA] Set floor for internal area ({mapSize.x-2}x{mapSize.z-2}) to {(floorDef?.defName ?? fallbackFloor?.defName)}"); + } + + /// + /// 清理单元格并设置地板 + /// + private void ClearCellAndSetFloor(Map map, IntVec3 pos, TerrainDef floorDef) + { + if (!pos.InBounds(map)) return; + + try + { + // 获取该位置的所有物品 + List thingsAtPos = pos.GetThingList(map).ToList(); // 创建副本避免修改时出错 + + // 清理所有建筑物和岩石(强力清理,确保地板可以放置) + foreach (Thing thing in thingsAtPos) + { + bool shouldRemove = false; + + // 检查是否为建筑物 + if (thing.def.category == ThingCategory.Building) + { + // 如果是自然岩石 + if (thing.def.building?.isNaturalRock == true) + { + shouldRemove = true; + } + // 或者是岩石相关的建筑 + else if (thing.def.defName.Contains("Rock") || + thing.def.defName.Contains("Slate") || + thing.def.defName.Contains("Granite") || + thing.def.defName.Contains("Sandstone") || + thing.def.defName.Contains("Limestone") || + thing.def.defName.Contains("Marble") || + thing.def.defName.Contains("Quartzite") || + thing.def.defName.Contains("Jade")) + { + shouldRemove = true; + } + // 或者是其他阻挡的建筑物(除了我们的乌拉墙) + else if (!thing.def.defName.Contains("Wula") && thing.def.Fillage == FillCategory.Full) + { + shouldRemove = true; + } + } + + if (shouldRemove) + { + if (Prefs.DevMode) // 只在开发模式下输出详细日志 + { + Log.Message($"[WULA] Removing {thing.def.defName} at {pos} to make space for floor"); + } + thing.Destroy(DestroyMode.Vanish); + } + } + + // 在清理后稍微延迟,再检查一次(确保彻底清理) + thingsAtPos = pos.GetThingList(map).ToList(); + foreach (Thing thing in thingsAtPos) + { + if (thing.def.category == ThingCategory.Building && thing.def.Fillage == FillCategory.Full) + { + Log.Warning($"[WULA] Force removing remaining building {thing.def.defName} at {pos}"); + thing.Destroy(DestroyMode.Vanish); + } + } + + // 设置地板地形 + if (floorDef != null) + { + map.terrainGrid.SetTerrain(pos, floorDef); + if (Prefs.DevMode) + { + Log.Message($"[WULA] Set terrain at {pos} to {floorDef.defName}"); + } + } + } + catch (Exception ex) + { + Log.Error($"[WULA] Error clearing cell at {pos}: {ex}"); + } + } + + /// + /// 生成基础设施 + /// + private void GenerateBasicInfrastructure(Map map) + { + IntVec3 mapSize = map.Size; + IntVec3 center = map.Center; + + // 获取灯具定义 + ThingDef lampDef = DefDatabase.GetNamed("StandingLamp", false) ?? + DefDatabase.GetNamed("TorchLamp", false) ?? + DefDatabase.GetNamed("Campfire", false); + + if (lampDef == null) + { + Log.Warning("[WULA] No lamp definition found, skipping lighting generation"); + return; + } + + // 在四个角落放置照明设备 + var lightPositions = new List + { + new IntVec3(2, 0, 2), // 左下角 + new IntVec3(mapSize.x - 3, 0, 2), // 右下角 + new IntVec3(2, 0, mapSize.z - 3), // 左上角 + new IntVec3(mapSize.x - 3, 0, mapSize.z - 3) // 右上角 + }; + + foreach (IntVec3 pos in lightPositions) + { + if (pos.InBounds(map) && pos.Standable(map)) + { + // 放置立式灯 + Thing lamp = ThingMaker.MakeThing(lampDef); + lamp.SetFaction(null); + GenPlace.TryPlaceThing(lamp, pos, map, ThingPlaceMode.Direct); + } + } + + // 在中心区域留出空间,这里将放置退出点 + // 不在这里放置退出点,因为这会由Building_ArmedShuttleWithPocket来处理 + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index 90b1d75a..ebb33551 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -169,6 +169,9 @@ + + +