diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 4b34f1c..5bf14c4 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.pdb b/1.6/1.6/Assemblies/ArachnaeSwarm.pdb index 1d90cc5..a6a7fa4 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.pdb and b/1.6/1.6/Assemblies/ArachnaeSwarm.pdb differ diff --git a/Source/ArachnaeSwarm/Pawn_Comps/ARA_Flight/Pawn_FlightTrackerPatches.cs b/Source/ArachnaeSwarm/Pawn_Comps/ARA_Flight/Pawn_FlightTrackerPatches.cs index bd9b6d3..546f873 100644 --- a/Source/ArachnaeSwarm/Pawn_Comps/ARA_Flight/Pawn_FlightTrackerPatches.cs +++ b/Source/ArachnaeSwarm/Pawn_Comps/ARA_Flight/Pawn_FlightTrackerPatches.cs @@ -8,13 +8,13 @@ namespace ArachnaeSwarm [HarmonyPatch] public static class FlightHarmonyPatches { - // Corrected Patch 1: The method signature now correctly matches the static target method. + // Patch 1: Override fly animation selection for pawns with CompPawnFlight. [HarmonyPrefix] [HarmonyPatch(typeof(Pawn_FlightTracker), "GetBestFlyAnimation")] - public static bool GetBestFlyAnimation_Prefix(Pawn pawn, ref AnimationDef __result) // Correct parameters: Pawn pawn, not __instance and ___pawn + public static bool GetBestFlyAnimation_Prefix(Pawn pawn, ref AnimationDef __result) { var flightComp = pawn?.TryGetComp(); - if (flightComp == null) // No props check needed, as the crash was due to wrong signature + if (flightComp == null) { return true; } @@ -51,7 +51,8 @@ namespace ArachnaeSwarm return true; } - // Patch 2 remains correct as Notify_JobStarted is a non-static method. + // Patch 2: Override flight start logic — only decides WHEN TO START flying. + // Landing is handled by FlightTick_Postfix via posture check. [HarmonyPrefix] [HarmonyPatch(typeof(Pawn_FlightTracker), "Notify_JobStarted")] public static bool Notify_JobStarted_Prefix(Job job, Pawn_FlightTracker __instance, Pawn ___pawn) @@ -68,7 +69,7 @@ namespace ArachnaeSwarm { shouldBeFlying = true; } - else if (compProps.flightCondition == FlightCondition.DraftedAndMove && ___pawn.Drafted || ___pawn.pather.Moving) + else if (compProps.flightCondition == FlightCondition.DraftedAndMove && (___pawn.Drafted || ___pawn.pather.MovingNow)) { shouldBeFlying = true; } @@ -77,17 +78,33 @@ namespace ArachnaeSwarm shouldBeFlying = true; } - if (shouldBeFlying) + if (shouldBeFlying && !__instance.Flying) { - if (!__instance.Flying) __instance.StartFlying(); - job.flying = true; - } - else - { - if (__instance.Flying) __instance.ForceLand(); - job.flying = false; + __instance.StartFlying(); } + job.flying = shouldBeFlying; return false; } + + // Patch 3: Posture-based landing guard — only decides WHEN TO LAND. + // If the pawn is not standing (lying in bed, downed on ground, etc.), force land. + // This is a universal check that works with all vanilla and modded jobs + // without needing to maintain a job blacklist. + [HarmonyPostfix] + [HarmonyPatch(typeof(Pawn_FlightTracker), "FlightTick")] + public static void FlightTick_Postfix(Pawn_FlightTracker __instance, Pawn ___pawn) + { + if (!__instance.Flying) return; + + var flightComp = ___pawn?.TryGetComp(); + if (flightComp == null) return; + + if (___pawn.GetPosture() != PawnPosture.Standing) + { + __instance.ForceLand(); + if (___pawn.CurJob != null) + ___pawn.CurJob.flying = false; + } + } } } \ No newline at end of file