public override bool ActivateOn(Lord lord, TriggerSignal signal)
 {
     if ((signal.type == TriggerSignalType.Tick) &&
         (Find.TickManager.TicksGame % checkInterval == 0))
     {
         IntVec3 targetDestination = (lord.LordJob as LordJob_MiningCoBase).targetDestination;
         // Look for a reachable unreserved downed pawn.
         if (lord.ownedPawns.NullOrEmpty())
         {
             lord.Cleanup();
             return(false);
         }
         Pawn pawnToRescue = Util_DownedPawn.GetRandomReachableDownedPawn(lord.ownedPawns.RandomElement());
         if (pawnToRescue == null)
         {
             return(false);
         }
         // Check all lord pawns can reach downed pawn.
         foreach (Pawn pawn in lord.ownedPawns)
         {
             if (pawn.CanReserveAndReach(pawnToRescue, PathEndMode.OnCell, Danger.Some) == false)
             {
                 return(false);
             }
         }
         // Check all lord pawns can reach target destination.
         bool targetDestinationIsReachable = true;
         foreach (Pawn pawn in lord.ownedPawns)
         {
             if (pawn.CanReach(targetDestination, PathEndMode.OnCell, Danger.Some) == false)
             {
                 targetDestinationIsReachable = false;
                 break;
             }
         }
         if (targetDestinationIsReachable)
         {
             return(true);
         }
         // Try to find a new exit spot.
         IntVec3 exitSpot        = IntVec3.Invalid;
         bool    exitSpotIsValid = Expedition.TryFindRandomExitSpot(lord.Map, lord.ownedPawns.RandomElement().Position, out exitSpot);
         if (exitSpotIsValid)
         {
             targetDestinationIsReachable = true;
             foreach (Pawn pawn in lord.ownedPawns)
             {
                 if (pawn.CanReach(exitSpot, PathEndMode.OnCell, Danger.Some) == false)
                 {
                     targetDestinationIsReachable = false;
                     break;
                 }
             }
         }
         return(targetDestinationIsReachable);
     }
     return(false);
 }
 public static bool RemoveLord(LordManager __instance, Lord oldLord)
 {
     for (int j = 0; j < oldLord.ownedPawns.Count; j++)
     {
         lock (Lord_Patch.pawnsLord)
         {
             Lord_Patch.pawnsLord.SetOrAdd(oldLord.ownedPawns[j], null);
         }
     }
     __instance.lords.Remove(oldLord);
     Find.SignalManager.DeregisterReceiver(oldLord);
     oldLord.Cleanup();
     return(false);
 }