Fix InvalidCastException in CageTradeDealPatch

Hard cast (Pawn)t failed for non-pawn tradeables in InSellablePosition.
Use pattern match instead to safely skip non-pawn things.
This commit is contained in:
Canon
2026-03-31 09:59:53 +08:00
parent 7e878c82b7
commit e7ea13c045
2 changed files with 1 additions and 2 deletions
Binary file not shown.
@@ -115,8 +115,7 @@ public static class CageTradeDealPatch
private static void Postfix(ref bool __result, TradeDeal __instance, Thing t, out string reason)
{
//Log.Message(t.ParentHolder);
if (!__result && !t.Spawned && t.holdingOwner != null && ((Pawn)t).health.capacities.CanBeAwake && !((Pawn)t).DeadOrDowned)
if (!__result && !t.Spawned && t is Pawn pawn && t.holdingOwner != null && pawn.health.capacities.CanBeAwake && !pawn.DeadOrDowned)
{
__result = true;
}