Beispiel #1
0
        static bool Prefix(Transition trans)
        {
            LordToil_Travel lordToil_Travel = (LordToil_Travel)trans.target;

            if (!lordToil_Travel.HasDestination())
            {
                Pawn pawn = lordToil_Travel.lord.ownedPawns.RandomElement();
                if (!CellFinderExtended.TryFindRandomPawnExitCell(pawn, out IntVec3 result))
                {
                    RCellFinderExtended.TryFindRandomPawnEntryCell(out result, pawn.Map, pawn.kindDef, 0f);
                }
                lordToil_Travel.SetDestination(result);
            }
            return(false);
        }
 public static bool TryFindStartAndEndCells(this IncidentWorker_HerdMigration hm, Map map, PawnKindDef kind, out IntVec3 start, out IntVec3 end)
 {
     if (!RCellFinderExtended.TryFindRandomPawnEntryCell(out start, map, kind, CellFinder.EdgeRoadChance_Animal))
     {
         end = IntVec3.Invalid;
         return(false);
     }
     end = IntVec3.Invalid;
     for (int i = 0; i < 8; i++)
     {
         IntVec3 startLocal = start;
         if (!CellFinderExtended.TryFindRandomEdgeCellWith((IntVec3 x) => map.reachability.CanReach(startLocal, x, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly), map, kind, CellFinder.EdgeRoadChance_Ignore, out IntVec3 result))
         {
             break;
         }
         if (!end.IsValid || result.DistanceToSquared(start) > end.DistanceToSquared(start))
         {
             end = result;
         }
     }
     return(end.IsValid);
 }