This commit is contained in:
2026-01-19 17:35:33 +08:00
parent a1d412dffc
commit edf1e163fa
3 changed files with 27 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
using HarmonyLib; using System;
using HarmonyLib;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -10,17 +11,14 @@ namespace WulaFallenEmpire
[HarmonyPrefix] [HarmonyPrefix]
public static bool Prefix(Pawn __instance, ref DamageInfo dinfo) public static bool Prefix(Pawn __instance, ref DamageInfo dinfo)
{ {
// 检查Pawn是否有伤害拦截组件
var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>(); var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>();
if (interceptorComp != null) if (interceptorComp != null)
{ {
WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 即将受到 {dinfo.Amount} 点伤害,拦截组件激活"); WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 即将受到 {dinfo.Amount} 点伤害,拦截组件激活");
// 让拦截组件处理伤害
return interceptorComp.PreApplyDamage(ref dinfo); return interceptorComp.PreApplyDamage(ref dinfo);
} }
return true; // 继续正常处理伤害 return true;
} }
} }
@@ -30,11 +28,17 @@ namespace WulaFallenEmpire
[HarmonyPostfix] [HarmonyPostfix]
public static void Postfix(Pawn __instance, DamageInfo dinfo, float totalDamageDealt) public static void Postfix(Pawn __instance, DamageInfo dinfo, float totalDamageDealt)
{ {
// 记录实际承受的伤害 try
var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>();
if (interceptorComp != null && totalDamageDealt == 0f)
{ {
WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 成功拦截所有伤害实际承受0点伤害"); var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>();
if (interceptorComp != null && totalDamageDealt == 0f)
{
WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 成功拦截所有伤害实际承受0点伤害");
}
}
catch (Exception ex)
{
WulaLog.Debug($"[DamageInterceptor] Error in PostApplyDamage patch: {ex}");
} }
} }
} }

13
opencode.json Normal file
View File

@@ -0,0 +1,13 @@
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"rimworld-code-rag": {
"type": "local",
"command": [
"C:/Users/Kalo/miniconda3/python.exe",
"C:/Steam/steamapps/common/RimWorld/Mods/3516260226/MCP/mcpserver_stdio_complete.py"
],
"enabled": true
}
}
}