Beispiel #1
0
 public static bool IsGoodStoreCell(IntVec3 c, Map map, Thing t, Pawn carrier, Faction faction)
 {
     if (carrier != null && c.IsForbidden(carrier))
     {
         return(false);
     }
     if (!StoreUtility.NoStorageBlockersIn(c, map, t))
     {
         return(false);
     }
     if (carrier != null)
     {
         if (!carrier.CanReserveNew(c))
         {
             return(false);
         }
     }
     else if (faction != null && map.reservationManager.IsReservedByAnyoneOf(c, faction))
     {
         return(false);
     }
     if (c.ContainsStaticFire(map))
     {
         return(false);
     }
     if (carrier != null && !carrier.Map.reachability.CanReach((!t.SpawnedOrAnyParentSpawned) ? carrier.PositionHeld : t.PositionHeld, c, PathEndMode.ClosestTouch, TraverseParms.For(carrier, Danger.Deadly, TraverseMode.ByPawn, false)))
     {
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        public static List <Thing> GetItemsIfValidItemSpot(Map map, IntVec3 cell)
        {
            //references used for this function (referenced during Rimworld 0.19):
            // Designation_ZoneAddStockpile.CanDesignateCell
            // StoreUtility.IsGoodStoreCell
            var result = new List <Thing>();

            if (!cell.InBounds(map) ||
                cell.Fogged(map) ||
                cell.InNoZoneEdgeArea(map) ||
                cell.GetTerrain(map).passability == Traversability.Impassable ||
                cell.ContainsStaticFire(map))
            {
                return(null);
            }
            List <Thing> things = map.thingGrid.ThingsListAt(cell);

            foreach (Thing thing in things)
            {
                if (!thing.def.CanOverlapZones ||
                    (thing.def.entityDefToBuild != null &&
                     thing.def.entityDefToBuild.passability != Traversability.Standable) ||
                    (thing.def.surfaceType == SurfaceType.None &&
                     thing.def.passability != Traversability.Standable))
                {
                    return(null);
                }
                if (thing.def.EverStorable(false))
                {
                    result.Add(thing);
                }
            }
            return(result);
        }
        private static bool HaulablePlaceValidator(Thing haulable, Pawn worker, IntVec3 c)
        {
            bool result;

            if (!worker.CanReserveAndReach(c, PathEndMode.OnCell, worker.NormalMaxDanger(), 1, -1, null, false))
            {
                result = false;
            }
            else if (GenPlace.HaulPlaceBlockerIn(haulable, c, worker.Map, true) != null)
            {
                result = false;
            }
            else if (!c.Standable(worker.Map))
            {
                result = false;
            }
            else if (c == haulable.Position && haulable.Spawned)
            {
                result = false;
            }
            else if (c.ContainsStaticFire(worker.Map))
            {
                result = false;
            }
            else
            {
                if (haulable != null && haulable.def.BlockPlanting)
                {
                    Zone zone = worker.Map.zoneManager.ZoneAt(c);
                    if (zone is Zone_Growing)
                    {
                        return(false);
                    }
                }
                if (haulable.def.passability != Traversability.Standable)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + GenAdj.AdjacentCells[i];
                        if (worker.Map.designationManager.DesignationAt(c2, DesignationDefOf.Mine) != null)
                        {
                            return(false);
                        }
                    }
                }
                Building edifice = c.GetEdifice(worker.Map);
                if (edifice != null)
                {
                    Building_Trap building_Trap = edifice as Building_Trap;
                    if (building_Trap != null)
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
        // returning string text assigning false reason to AcceptanceReport
        public override AcceptanceReport CanDesignateCell(IntVec3 cell)
        {
            if (!cell.InBounds() || cell.Fogged() || cell.ContainsStaticFire())
            {
                return false;
            }

            var firstItem = cell.GetFirstItem();
            if (firstItem != null && CanDesignateThing(firstItem).Accepted)
            {
                return true;
            }

            return false;
        }
Beispiel #5
0
        // returning string text assigning false reason to AcceptanceReport
        public override AcceptanceReport CanDesignateCell(IntVec3 cell)
        {
            if (!cell.InBounds(Map) || cell.Fogged(Map) || cell.ContainsStaticFire(Map))
            {
                return(false);
            }

            Thing firstItem = cell.GetFirstItem(this.Map);

            if (firstItem != null && this.CanDesignateThing(firstItem).Accepted)
            {
                return(true);
            }

            this.numOfContents = this.SlotsBackpackComp.slots.Count;

            int designationsTotalStackCount = 0;

            foreach (Thing designation in this.SlotsBackpackComp.designatedThings)
            {
                designationsTotalStackCount += designation.stackCount;
            }

            // No Item space or no stack space
            if (this.SlotsBackpackComp.designatedThings.Count + this.numOfContents >= this.MaxItem ||
                designationsTotalStackCount + this.SlotsBackpackComp.slots.TotalStackCount >= this.SlotsBackpackComp.MaxStack)
            {
                return(new AcceptanceReport("BackpackIsFull".Translate()));
            }


            foreach (Thing designation in this.SlotsBackpackComp.designatedThings)
            {
                if (designation.def.category == ThingCategory.Item && !designation.Map.reservationManager.IsReserved(designation, Faction.OfPlayer))
                {
                    return(true);
                }
            }

            return(new AcceptanceReport("InvalidPutInTarget".Translate()));

            // Thing firstItem = cell.GetFirstItem();
            // if (firstItem != null && CanDesignateThing(firstItem).Accepted)
            // {
            // return true;
            // }
            // return false;
        }
        public static bool IsGoodStoreCell(IntVec3 c, Map map, Thing t, Pawn carrier, Faction faction)
        {
            if (carrier != null && c.IsForbidden(carrier))
            {
                return(false);
            }

            if (!(bool)_noStorageBlockersInMethod.Invoke(null, new object[] { c, map, t }))
            {
                Log.Error("Storage blockers found at " + c + " for " + t);
                return(false);
            }
            if (carrier != null)
            {
                if (!carrier.CanReserveNew(c))
                {
                    Log.Error("Carrier " + carrier + " can't reserve new at " + c);
                    return(false);
                }
            }
            else if (faction != null)
            {
                var pawn = GetReservationClaimant(map.reservationManager, c, faction);
                if (pawn != null)
                {
                    // Pawn Drone, ProjectRimFactory.Drones.Pawn_Drone, PRFDrone, Dorks
                    Log.Error("Pawn " + pawn + ", " + pawn.def.thingClass.FullName + ", " + pawn.def.defName + ", " + pawn.Faction + " already reserved " + c);
                    return(false);
                }
            }
            if (c.ContainsStaticFire(map))
            {
                Log.Message("Fire at " + c);
                return(false);
            }
            List <Thing> thingList = c.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (thingList[i] is IConstructible && GenConstruct.BlocksConstruction(thingList[i], t))
                {
                    Log.Error("BlocksConstruction at " + c);
                    return(false);
                }
            }
            return(carrier == null || carrier.Map.reachability.CanReach(t.SpawnedOrAnyParentSpawned ? t.PositionHeld : carrier.PositionHeld, c, PathEndMode.ClosestTouch, TraverseParms.For(carrier, Danger.Deadly, TraverseMode.ByPawn, false, false, false)));
        }
        private static bool HaulablePlaceValidator(Thing haulable, Pawn worker, IntVec3 c)
        {
            if (!worker.CanReserveAndReach(c, PathEndMode.OnCell, worker.NormalMaxDanger()))
            {
                return(false);
            }
            if (GenPlace.HaulPlaceBlockerIn(haulable, c, worker.Map, checkBlueprintsAndFrames: true) != null)
            {
                return(false);
            }
            if (!c.Standable(worker.Map))
            {
                return(false);
            }
            if (c == haulable.Position && haulable.Spawned)
            {
                return(false);
            }
            if (c.ContainsStaticFire(worker.Map))
            {
                return(false);
            }
            if (haulable != null && haulable.def.BlocksPlanting() && worker.Map.zoneManager.ZoneAt(c) is Zone_Growing)
            {
                return(false);
            }
            if (haulable.def.passability != 0)
            {
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = c + GenAdj.AdjacentCells[i];
                    if (worker.Map.designationManager.DesignationAt(c2, DesignationDefOf.Mine) != null)
                    {
                        return(false);
                    }
                }
            }
            Building edifice = c.GetEdifice(worker.Map);

            if (edifice != null && edifice is Building_Trap)
            {
                return(false);
            }
            return(true);
        }
Beispiel #8
0
 public static bool ShouldTrashPlant(Pawn pawn, Plant p)
 {
     if (!p.sown || p.def.plant.IsTree || !p.FlammableNow || !TrashUtility.CanTrash(pawn, p))
     {
         return(false);
     }
     CellRect.CellRectIterator iterator = CellRect.CenteredOn(p.Position, 2).ClipInsideMap(p.Map).GetIterator();
     while (!iterator.Done())
     {
         IntVec3 current = iterator.Current;
         if (current.InBounds(p.Map) && current.ContainsStaticFire(p.Map))
         {
             return(false);
         }
         iterator.MoveNext();
     }
     return(p.Position.Roofed(p.Map) || p.Map.weatherManager.RainRate <= 0.25f);
 }
        public static bool IsGoodStoreCell(IntVec3 c, Map map, Thing t, Pawn carrier, Faction faction)
        {
            bool result;

            if (carrier != null && c.IsForbidden(carrier))
            {
                result = false;
            }
            else if (!StoreUtility.NoStorageBlockersIn(c, map, t))
            {
                result = false;
            }
            else
            {
                if (carrier != null)
                {
                    if (!carrier.CanReserveNew(c))
                    {
                        return(false);
                    }
                }
                else if (faction != null && map.reservationManager.IsReservedByAnyoneOf(c, faction))
                {
                    return(false);
                }
                if (c.ContainsStaticFire(map))
                {
                    result = false;
                }
                else
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        if (thingList[i] is IConstructible && GenConstruct.BlocksConstruction(thingList[i], t))
                        {
                            return(false);
                        }
                    }
                    result = (carrier == null || carrier.Map.reachability.CanReach((!t.SpawnedOrAnyParentSpawned) ? carrier.PositionHeld : t.PositionHeld, c, PathEndMode.ClosestTouch, TraverseParms.For(carrier, Danger.Deadly, TraverseMode.ByPawn, false)));
                }
            }
            return(result);
        }
Beispiel #10
0
        private static bool HaulablePlaceValidator(Thing haulable, Pawn worker, IntVec3 c, out string debugText)
        {
            if (!worker.CanReserveAndReach(c, PathEndMode.OnCell, worker.NormalMaxDanger()))
            {
                debugText = "Could not reserve or reach";
                return(false);
            }
            if (GenPlace.HaulPlaceBlockerIn(haulable, c, worker.Map, true) != null)
            {
                debugText = "Place was blocked";
                return(false);
            }
            var thisIsAPile = c.GetSlotGroup(worker.Map);

            if (thisIsAPile != null)
            {
                if (!thisIsAPile.Settings.AllowedToAccept(haulable))
                {
                    debugText = "Stockpile does not accept";
                    return(false);
                }
            }

            if (!c.Standable(worker.Map))
            {
                debugText = "Cell not standable";
                return(false);
            }
            if (c == haulable.Position && haulable.Spawned)
            {
                debugText = "Current position of thing to be hauled";
                return(false);
            }
            if (c.ContainsStaticFire(worker.Map))
            {
                debugText = "Cell has fire";
                return(false);
            }
            if (haulable != null && haulable.def.BlockPlanting)
            {
                Zone zone = worker.Map.zoneManager.ZoneAt(c);
                if (zone is Zone_Growing)
                {
                    debugText = "Growing zone here";
                    return(false);
                }
            }
            if (haulable.def.passability != Traversability.Standable)
            {
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 adjCell = c + GenAdj.AdjacentCells[i];

                    if (!adjCell.InBounds(worker.Map))
                    {
                        continue;
                    }

                    if (worker.Map.designationManager.DesignationAt(adjCell, DesignationDefOf.Mine) != null)
                    {
                        debugText = "Mining designated nearby";
                        return(false);
                    }
                }
            }

            bool validPositionExists = false;

            var crossGrid = GenAdj.CardinalDirectionsAndInside;

            for (int a = 0; a < crossGrid.CountAllowNull(); a++)
            {
                IntVec3 adjCell = c + crossGrid[a];

                if (!adjCell.InBounds(worker.Map))
                {
                    continue;
                }

                Building restrictedBuildingAdj = adjCell.GetEdifice(worker.Map);
                if (restrictedBuildingAdj != null)
                {
                    if (restrictedBuildingAdj is Building_Door)
                    {
                        break;
                    }
                    if (restrictedBuildingAdj is Building_WorkTable)
                    {
                        thisIsAPile = adjCell.GetSlotGroup(worker.Map);

                        if (thisIsAPile != null)
                        {
                            if (thisIsAPile.Settings.AllowedToAccept(haulable))
                            {
                                validPositionExists = true;
                            }
                        }
                    }
                }
                else
                {
                    validPositionExists = true;
                }
            }

            if (!validPositionExists)
            {
                debugText = "No valid position could be found.";
                return(false);
            }

            Building edifice = c.GetEdifice(worker.Map);

            if (edifice != null)
            {
                if (edifice is Building_Trap)
                {
                    debugText = "It's a trap.";
                    return(false);
                }

                if (edifice is Building_WorkTable)
                {
                    debugText = "Worktable here.";
                    return(false);
                }
            }

            debugText = "OK";
            return(true);
        }
        // duplicated to make changes
        public static bool TryFindBestBetterStoreCellFor(Thing haulable, Pawn carrier, StoragePriority currentPriority, Faction faction, out IntVec3 foundCell, bool needAccurateResult = true)
        {
            List <SlotGroup> allGroupsListInPriorityOrder = Find.SlotGroupManager.AllGroupsListInPriorityOrder;

            if (allGroupsListInPriorityOrder.Count == 0)
            {
                foundCell = IntVec3.Invalid;
                return(false);
            }
            ReservationManager reservations    = Find.Reservations;
            IntVec3            positionHeld    = haulable.PositionHeld;
            StoragePriority    storagePriority = currentPriority;
            float   num    = 2.14748365E+09f;
            IntVec3 intVec = default(IntVec3);
            bool    flag   = false;
            int     count  = allGroupsListInPriorityOrder.Count;

            for (int i = 0; i < count; i++)
            {
                SlotGroup       slotGroup = allGroupsListInPriorityOrder[i];
                StoragePriority priority  = slotGroup.Settings.Priority;
                if (priority < storagePriority || priority <= currentPriority)
                {
                    break;
                }
                if (slotGroup.Settings.AllowedToAccept(haulable))
                {
                    List <IntVec3> cellsList = slotGroup.CellsList;
                    int            count2    = cellsList.Count;
                    int            num2;
                    if (needAccurateResult)
                    {
                        num2 = Mathf.FloorToInt((float)count2 * Rand.Range(0.005f, 0.018f));
                    }
                    else
                    {
                        num2 = 0;
                    }
                    for (int j = 0; j < count2; j++)
                    {
                        IntVec3 intVec2 = cellsList[j];
                        float   lengthHorizontalSquared = (positionHeld - intVec2).LengthHorizontalSquared;
                        if (lengthHorizontalSquared <= num)
                        {
                            if (carrier == null || !intVec2.IsForbidden(carrier))
                            {
                                // call duplicated to make changes
                                if (NoStorageBlockersIn(intVec2, haulable))
                                {
                                    if (!reservations.IsReserved(intVec2, faction))
                                    {
                                        if (!intVec2.ContainsStaticFire())
                                        {
                                            if (carrier == null || haulable.Position.CanReach(slotGroup.CellsList[0], PathEndMode.ClosestTouch, TraverseParms.For(carrier, Danger.Deadly, TraverseMode.ByPawn, false)))
                                            {
                                                flag            = true;
                                                intVec          = intVec2;
                                                num             = lengthHorizontalSquared;
                                                storagePriority = priority;
                                                if (j >= num2)
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (!flag)
            {
                foundCell = IntVec3.Invalid;
                return(false);
            }
            foundCell = intVec;
            return(true);
        }
        private static float GetCellCoverRatingForPawn(Pawn pawn, IntVec3 cell, IntVec3 shooterPos)
        {
            // Check for invalid locations
            if (!cell.IsValid || !cell.Standable(pawn.Map) || !pawn.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.Deadly) || cell.ContainsStaticFire(pawn.Map))
            {
                return(-1);
            }

            float cellRating = 0;

            if (!GenSight.LineOfSight(shooterPos, cell, pawn.Map))
            {
                cellRating += 2f;
            }
            else
            {
                //Check if cell has cover in desired direction
                Vector3 coverVec  = (shooterPos - cell).ToVector3().normalized;
                IntVec3 coverCell = (cell.ToVector3Shifted() + coverVec).ToIntVec3();
                Thing   cover     = coverCell.GetCover(pawn.Map);
                cellRating += GetCoverRating(cover);
            }

            //Check time to path to that location
            if (!pawn.Position.Equals(cell))
            {
                // float pathCost = pawn.Map.pathFinder.FindPath(pawn.Position, cell, TraverseMode.NoPassClosedDoors).TotalCost;
                float pathCost = (pawn.Position - cell).LengthHorizontal;
                if (!GenSight.LineOfSight(pawn.Position, cell, pawn.Map))
                {
                    pathCost *= 5;
                }
                cellRating = cellRating / pathCost;
            }
            return(cellRating);
        }
 private bool Validator(Pawn pawn, IntVec3 vec0, IntVec3 vec1)
 {
     return(vec0.ContainsStaticFire(pawn.Map) && !pawn.IsBurning());
 }
Beispiel #14
0
        // Token: 0x06000008 RID: 8 RVA: 0x0000233C File Offset: 0x0000053C
        private static bool HaulablePlaceValidator(Thing haulable, Pawn worker, IntVec3 c, out string debugText)
        {
            bool result;

            if (!worker.CanReserveAndReach(c, PathEndMode.OnCell, worker.NormalMaxDanger()))
            {
                debugText = "Could not reserve or reach";
                result    = false;
            }
            else
            {
                if (GenPlace.HaulPlaceBlockerIn(haulable, c, worker.Map, true) != null)
                {
                    debugText = "Place was blocked";
                    result    = false;
                }
                else
                {
                    var slotGroup = c.GetSlotGroup(worker.Map);
                    if (slotGroup != null)
                    {
                        if (!slotGroup.Settings.AllowedToAccept(haulable))
                        {
                            debugText = "Stockpile does not accept";
                            return(false);
                        }
                    }

                    if (!c.Standable(worker.Map))
                    {
                        debugText = "Cell not standable";
                        result    = false;
                    }
                    else
                    {
                        if (c == haulable.Position && haulable.Spawned)
                        {
                            debugText = "Current position of thing to be hauled";
                            result    = false;
                        }
                        else
                        {
                            if (c.ContainsStaticFire(worker.Map))
                            {
                                debugText = "Cell has fire";
                                result    = false;
                            }
                            else
                            {
                                if (haulable.def.BlocksPlanting())
                                {
                                    var zone = worker.Map.zoneManager.ZoneAt(c);
                                    if (zone is Zone_Growing)
                                    {
                                        debugText = "Growing zone here";
                                        return(false);
                                    }
                                }

                                if (haulable.def.passability > Traversability.Standable)
                                {
                                    for (var i = 0; i < 8; i++)
                                    {
                                        var c2 = c + GenAdj.AdjacentCells[i];
                                        if (!c2.InBounds(worker.Map))
                                        {
                                            continue;
                                        }

                                        if (worker.Map.designationManager.DesignationAt(c2,
                                                                                        DesignationDefOf.Mine) == null)
                                        {
                                            continue;
                                        }

                                        debugText = "Mining designated nearby";
                                        return(false);
                                    }
                                }

                                var b = false;
                                var cardinalDirectionsAndInside = GenAdj.CardinalDirectionsAndInside;
                                for (var j = 0; j < cardinalDirectionsAndInside.CountAllowNull(); j++)
                                {
                                    var c3 = c + cardinalDirectionsAndInside[j];
                                    if (!c3.InBounds(worker.Map))
                                    {
                                        continue;
                                    }

                                    var edifice = c3.GetEdifice(worker.Map);
                                    if (edifice != null)
                                    {
                                        if (edifice is Building_Door)
                                        {
                                            break;
                                        }

                                        if (edifice is not Building_WorkTable)
                                        {
                                            continue;
                                        }

                                        slotGroup = c3.GetSlotGroup(worker.Map);
                                        if (slotGroup == null)
                                        {
                                            continue;
                                        }

                                        if (slotGroup.Settings.AllowedToAccept(haulable))
                                        {
                                            b = true;
                                        }
                                    }
                                    else
                                    {
                                        b = true;
                                    }
                                }

                                if (!b)
                                {
                                    debugText = "No valid position could be found.";
                                    result    = false;
                                }
                                else
                                {
                                    var edifice2 = c.GetEdifice(worker.Map);
                                    if (edifice2 != null)
                                    {
                                        if (edifice2 is Building_Trap)
                                        {
                                            debugText = "It's a trap.";
                                            return(false);
                                        }

                                        if (edifice2 is Building_WorkTable)
                                        {
                                            debugText = "It's not a trap, but we still can't put something here.";
                                            return(false);
                                        }
                                    }

                                    debugText = "OK";
                                    result    = true;
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #15
0
        // Token: 0x060005DA RID: 1498 RVA: 0x000393CC File Offset: 0x000377CC
        private static bool HaulablePlaceValidator(Thing haulable, Pawn worker, IntVec3 c, IntVec3 center, int radius)
        {
            if (!worker.CanReserveAndReach(c, PathEndMode.OnCell, worker.NormalMaxDanger(), 1, -1, null, false))
            {
                return(false);
            }
            if (GenPlace.HaulPlaceBlockerIn(haulable, c, worker.Map, true) != null)
            {
                return(false);
            }
            if (!c.Standable(worker.Map))
            {
                return(false);
            }
            if (c == haulable.Position && haulable.Spawned)
            {
                return(false);
            }
            if (c.ContainsStaticFire(worker.Map))
            {
                return(false);
            }
            if (XenomorphUtil.DistanceBetween(c, center) <= radius)
            {
                return(false);
            }

            /*
             * if (XenomorphUtil.DistanceBetween(c, center) > radius*2)
             * {
             *  return false;
             * }
             */
            /*
             * if (c.AdjacentTo8Way(center))
             * {
             *  return false;
             * }
             */
            if (haulable != null && haulable.def.BlockPlanting)
            {
                Zone zone = worker.Map.zoneManager.ZoneAt(c);
                if (zone is Zone_Growing)
                {
                    return(false);
                }
            }
            if (haulable.def.passability != Traversability.Standable)
            {
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = c + GenAdj.AdjacentCells[i];
                    if (worker.Map.designationManager.DesignationAt(c2, DesignationDefOf.Mine) != null)
                    {
                        return(false);
                    }
                }
            }
            Building edifice = c.GetEdifice(worker.Map);

            if (edifice != null)
            {
                Building_Trap building_Trap = edifice as Building_Trap;
                if (building_Trap != null)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #16
0
        private static bool CanWanderToCell(IntVec3 c, Pawn pawn, IntVec3 root, Func <Pawn, IntVec3, IntVec3, bool> validator, int tryIndex, Danger maxDanger)
        {
            bool flag = false;

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