using HarmonyLib; using RimWorld; using System.Collections.Generic; using Verse; using Verse.AI; namespace ArachnaeSwarm { [HarmonyPatch(typeof(ThingWithComps), "GetFloatMenuOptions")] public static class Harmony_ThingWithComps_GetFloatMenuOptions { [HarmonyPostfix] public static IEnumerable Postfix(IEnumerable values, ThingWithComps __instance, Pawn selPawn) { // First, return all original options foreach (var value in values) { yield return value; } // --- DEBUG LOGGING --- // Use a more specific check to avoid log spam if (__instance.def.defName != null && __instance.def.defName.StartsWith("ARA_")) { Log.Message($"[PA_Debug] GetFloatMenuOptions Postfix triggered for: {__instance.def.defName}"); } // Check if the thing is our power armor building var comp = __instance.GetComp(); if (comp == null && __instance.def.defName != null && __instance.def.defName.StartsWith("ARA_")) { Log.Message($"[PA_Debug] CompPowerArmorStation is NULL for {__instance.def.defName}"); } if (comp != null) { Log.Message($"[PA_Debug] CompPowerArmorStation FOUND for {__instance.def.defName}. Checking reachability."); // Check if the pawn can interact if (!selPawn.CanReserveAndReach(__instance, PathEndMode.InteractionCell, Danger.Deadly)) { yield return new FloatMenuOption("CannotEnterPowerArmor".Translate() + ": " + "CannotReach".Translate(), null); } else { // Action to give the job void enterAction() { Job job = JobMaker.MakeJob(DefDatabase.GetNamed("ARA_EnterPowerArmor"), __instance); selPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); } yield return new FloatMenuOption("EnterPowerArmor".Translate(__instance.Label), enterAction); } } } } }