diff --git a/.kilocode/rules/rimworld.md b/.kilocode/rules/rimworld.md index 8262a414..11395210 100644 --- a/.kilocode/rules/rimworld.md +++ b/.kilocode/rules/rimworld.md @@ -22,42 +22,4 @@ Always remember these critical paths for your work: ## 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` 项目文件中的相应 `` 条目,否则会导致编译失败。 - -## 任务日志记录 (Task Logging) - -为了实现最低的 token 消耗和最高效的上下文理解,所有任务日志 **必须** 遵循以下 YAML-like Markdown 格式。 - -1. **日志文件:** 在每个新任务开始时,在 `.kilocode/logs/` 目录下创建一个以当前日期和任务名命名的 Markdown 文件 (例如 `2025-08-12-fix-cleave-weapon.md`)。 - -2. **日志格式:** - * **Front Matter:** 文件开头使用 YAML Front Matter 提供任务摘要。 - * **事件驱动:** 每个独立的操作(工具调用、命令执行、用户反馈等)都应记录为一个独立的“事件”。 - * **事件分隔符:** 使用 `---` 将每个事件分隔开。 - * **键值对:** 使用简短、标准化的英文 `key:` 标识信息。 - * **代码块:** 所有多行文本(代码、diff、命令输出)都必须包含在带语言标识的 ` ``` ` 代码块中。 - -3. **启动时读取:** 每次会话初始化时,必须检查并读取最新的日志文件,以了解上一个任务的最终状态和上下文。 - -4. **格式示例:** - ```markdown - --- - task: "任务的简短描述" - date: "YYYY-MM-DD" - status: "in-progress" # or "completed" - --- - - # EVENT: TOOL_CALL - tool: tool_name - params: - key: value - --- - - # EVENT: CMD_EXEC - cmd: command to execute - exit_code: 0 - output: | - ``` - ... - ``` --- - ``` \ No newline at end of file +- **同步项目文件:** 当重命名、移动或删除C#源文件时,**必须**同步更新 `.csproj` 项目文件中的相应 `` 条目,否则会导致编译失败。 \ No newline at end of file diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index ee4b5a97..b508b60a 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/HediffDefs/Hediffs_WULA_Maintenance.xml b/1.6/1.6/Defs/HediffDefs/Hediffs_WULA_Maintenance.xml index 2e0d9231..3e7e8cb8 100644 --- a/1.6/1.6/Defs/HediffDefs/Hediffs_WULA_Maintenance.xml +++ b/1.6/1.6/Defs/HediffDefs/Hediffs_WULA_Maintenance.xml @@ -20,7 +20,7 @@ 0.03333
  • - 0.01 + 0.005
  • diff --git a/Source/WulaFallenEmpire/CompMaintenancePod.cs b/Source/WulaFallenEmpire/CompMaintenancePod.cs index 8dcb272e..361c4f0e 100644 --- a/Source/WulaFallenEmpire/CompMaintenancePod.cs +++ b/Source/WulaFallenEmpire/CompMaintenancePod.cs @@ -87,6 +87,27 @@ namespace WulaFallenEmpire Scribe_Deep.Look(ref innerContainer, "innerContainer", this); } + public override void PostDestroy(DestroyMode mode, Map previousMap) + { + base.PostDestroy(mode, previousMap); + // If the pod is deconstructed or destroyed, eject the occupant to prevent deletion. + if (mode == DestroyMode.Deconstruct || mode == DestroyMode.KillFinalize) + { + Log.Warning($"[WulaPodDebug] Pod destroyed (mode: {mode}). Ejecting pawn."); + EjectPawn(); + } + } + + public override void PostDeSpawn(Map map, DestroyMode mode = DestroyMode.Vanish) + { + base.PostDeSpawn(map, mode); + // This handles cases like uninstalling where the pod is removed from the map + // without being "destroyed". We still need to eject the occupant. + Log.Warning($"[WulaPodDebug] Pod despawned. Ejecting pawn."); + EjectPawn(); + } + + // ===================== IThingHolder Implementation ===================== public void GetChildHolders(List outChildren) { @@ -205,16 +226,38 @@ namespace WulaFallenEmpire EjectPawn(); } - public void EjectPawn() + public void EjectPawn(bool interrupted = false) { Pawn occupant = Occupant; Log.Warning($"[WulaPodDebug] EjectPawn. Occupant: {(occupant == null ? "NULL" : occupant.LabelShortCap)}"); if (occupant != null) { - GenPlace.TryPlaceThing(occupant, parent.InteractionCell, parent.Map, ThingPlaceMode.Near); - if (Props.exitSound != null) + Map mapToUse = parent.Map ?? Find.CurrentMap; + if (mapToUse == null) { - SoundStarter.PlayOneShot(Props.exitSound, new TargetInfo(parent.Position, parent.Map)); + // Try to find the map from nearby things + mapToUse = GenClosest.ClosestThing_Global(occupant.Position, Gen.YieldSingle(parent), 99999f, (thing) => thing.Map != null)?.Map; + } + + if (mapToUse != null) + { + innerContainer.TryDropAll(parent.InteractionCell, mapToUse, ThingPlaceMode.Near); + if (Props.exitSound != null) + { + SoundStarter.PlayOneShot(Props.exitSound, new TargetInfo(parent.Position, mapToUse)); + } + } + else + { + Log.Warning($"[WulaPodDebug] EjectPawn aborted: No valid map found."); + return; + } + + // Additional logic to handle occupant if needed + if (interrupted) + { + occupant.needs?.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SoakingWet); + occupant.health?.AddHediff(HediffDefOf.BiosculptingSickness); } } innerContainer.Clear();