diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 86d134a..95b125e 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index 70224f4..36a0e15 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -88,6 +88,7 @@ + diff --git a/Source/ArachnaeSwarm/Patch_QualityUtility.cs b/Source/ArachnaeSwarm/Patch_QualityUtility.cs new file mode 100644 index 0000000..dfa742e --- /dev/null +++ b/Source/ArachnaeSwarm/Patch_QualityUtility.cs @@ -0,0 +1,62 @@ +using HarmonyLib; +using RimWorld; +using Verse; +using System.Reflection; // For MethodInfo + +namespace ArachnaeSwarm +{ + [StaticConstructorOnStartup] + public static class QualityUtilityPatch + { + static QualityUtilityPatch() + { + var harmony = new Harmony("com.yourname.qualityutilitypatch"); + harmony.Patch( + original: AccessTools.Method(typeof(QualityUtility), nameof(QualityUtility.GenerateQualityCreatedByPawn), new[] { typeof(Pawn), typeof(SkillDef), typeof(bool) }), + prefix: new HarmonyMethod(typeof(QualityUtilityPatch), nameof(GenerateQualityCreatedByPawn_Prefix)) + ); + } + + public static bool GenerateQualityCreatedByPawn_Prefix(Pawn pawn, SkillDef relevantSkill, bool consumeInspiration, ref QualityCategory __result) + { + // 检查当前 Pawn 是否是我们的自定义动物(通过检查其 ThingDef 是否拥有 CompProperties_WorkForNonMechs) + if (pawn != null && pawn.def.comps != null && ShouldEnableWorkSystem(pawn)) + { + // 如果是,强制使用 mechFixedSkillLevel + int relevantSkillLevel = pawn.RaceProps.mechFixedSkillLevel; + bool inspired = consumeInspiration && pawn.InspirationDef == InspirationDefOf.Inspired_Creativity; + + // 调用 QualityUtility.GenerateQualityCreatedByPawn 的 int 重载 + __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); + + // 消耗灵感(如果适用) + if (inspired) + { + pawn.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Creativity); + } + + // 返回 false,跳过原版方法执行 + return false; + } + + // 返回 true,执行原版方法 + return true; + } + + private static bool ShouldEnableWorkSystem(Pawn pawn) + { + // 检查 ThingDef 中是否有 CompProperties_WorkForNonMechs 配置 + if (pawn.def.comps != null) + { + foreach (var compProperties in pawn.def.comps) + { + if (compProperties is CompProperties_WorkForNonMechs) + { + return true; + } + } + } + return false; + } + } +} \ No newline at end of file