Skip to content

Commit 1cfbc5c

Browse files
committed
fix for v1.5 UnnaturalCorpse event
1 parent 67d1537 commit 1cfbc5c

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

Source/Client/Patches/Determinism.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,34 @@ static void Postfix(ref FloodUnfogResult __result)
123123
__result.allOnScreen = false;
124124
}
125125
}
126-
126+
127+
[HarmonyPatch]
128+
static class UnnaturalCorpsePatch // v1.5
129+
{
130+
static IEnumerable<MethodBase> TargetMethods()
131+
{
132+
yield return AccessTools.DeclaredMethod(typeof(AnomalyUtility), nameof(AnomalyUtility.IsValidUnseenCell));
133+
yield return AccessTools.DeclaredMethod(typeof(UnnaturalCorpse), nameof(UnnaturalCorpse.IsOutsideView));
134+
}
135+
136+
static MethodInfo CellRectContains = AccessTools.Method(typeof(CellRect), nameof(CellRect.Contains));
137+
138+
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> insts)
139+
{
140+
foreach (var inst in insts)
141+
{
142+
yield return inst;
143+
144+
// consider it always outside view (not contained in CurrentViewRect)
145+
if (inst.operand == CellRectContains)
146+
{
147+
yield return new CodeInstruction(OpCodes.Ldc_I4_0);
148+
yield return new CodeInstruction(OpCodes.And);
149+
}
150+
}
151+
}
152+
}
153+
127154
[HarmonyPatch(typeof(Pawn), nameof(Pawn.ProcessPostTickVisuals))]
128155
static class DrawTrackerTickPatch
129156
{

0 commit comments

Comments
 (0)