public static bool TryFindGoodAdjacentSpotToTouch(Pawn toucher, Thing touchee, out IntVec3 result)
 {
     foreach (IntVec3 item in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (item.Standable(toucher.Map) && !RCellFinder.ContainsKnownTrap(item, toucher.Map, toucher))
         {
             result = item;
             return(true);
         }
     }
     foreach (IntVec3 item2 in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (item2.Walkable(toucher.Map))
         {
             result = item2;
             return(true);
         }
     }
     result = touchee.Position;
     return(false);
 }
Example #2
0
 public static bool TryFindGoodAdjacentSpotToTouch(Pawn toucher, Thing touchee, out IntVec3 result)
 {
     foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (current.Standable(toucher.Map) && !RCellFinder.ContainsKnownTrap(current, toucher.Map, toucher))
         {
             result = current;
             bool result2 = true;
             return(result2);
         }
     }
     foreach (IntVec3 current2 in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (current2.Walkable(toucher.Map))
         {
             result = current2;
             bool result2 = true;
             return(result2);
         }
     }
     result = touchee.Position;
     return(false);
 }
        private static bool CanWanderToCell(IntVec3 c, Pawn pawn, IntVec3 root, Func <Pawn, IntVec3, bool> validator, int tryIndex, Danger maxDanger)
        {
            bool flag = UnityData.isDebugBuild && DebugViewSettings.drawDestSearch;

            if (!c.Walkable(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0f, "walk", 50);
                }
                return(false);
            }
            if (c.IsForbidden(pawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.25f, "forbid", 50);
                }
                return(false);
            }
            if (tryIndex < 10 && !c.Standable(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.25f, "stand", 50);
                }
                return(false);
            }
            if (!pawn.CanReach(c, PathEndMode.OnCell, maxDanger, false, TraverseMode.ByPawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.6f, "reach", 50);
                }
                return(false);
            }
            if (RCellFinder.ContainsKnownTrap(c, pawn.Map, pawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.1f, "trap", 50);
                }
                return(false);
            }
            if (tryIndex < 10)
            {
                if (c.GetTerrain(pawn.Map).avoidWander)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.39f, "terr", 50);
                    }
                    return(false);
                }
                if (pawn.Map.pathGrid.PerceivedPathCostAt(c) > 20)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.4f, "pcost", 50);
                    }
                    return(false);
                }
                if ((int)c.GetDangerFor(pawn, pawn.Map) > 1)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.4f, "danger", 50);
                    }
                    return(false);
                }
            }
            else if (tryIndex < 15 && c.GetDangerFor(pawn, pawn.Map) == Danger.Deadly)
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.4f, "deadly", 50);
                }
                return(false);
            }
            if (!pawn.Map.pawnDestinationReservationManager.CanReserve(c, pawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.75f, "resvd", 50);
                }
                return(false);
            }
            if (validator != null && !validator(pawn, c))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.15f, "valid", 50);
                }
                return(false);
            }
            if (c.GetDoor(pawn.Map) != null)
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.32f, "door", 50);
                }
                return(false);
            }
            if (c.ContainsStaticFire(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.9f, "fire", 50);
                }
                return(false);
            }
            return(true);
        }