Пример #1
0
        public static bool TryFindRandomSpawnCellForPawnNear(IntVec3 root, Map map, out IntVec3 result, int firstTryWithRadius = 4)
        {
            if (root.Standable(map) && root.GetFirstPawn(map) == null)
            {
                result = root;
                return(true);
            }
            bool rootFogged = root.Fogged(map);
            int  num        = firstTryWithRadius;

            for (int i = 0; i < 3; i++)
            {
                if (CellFinder.TryFindRandomReachableCellNear(root, map, (float)num, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => c.Standable(map) && (rootFogged || !c.Fogged(map)) && c.GetFirstPawn(map) == null, null, out result, 999999))
                {
                    return(true);
                }
                num *= 2;
            }
            num = firstTryWithRadius + 1;
            while (!CellFinder.TryRandomClosewalkCellNear(root, map, num, out result, null))
            {
                if (num > map.Size.x / 2 && num > map.Size.z / 2)
                {
                    result = root;
                    return(false);
                }
                num *= 2;
            }
            return(true);
        }
Пример #2
0
        public static IntVec3 RandomClosewalkCellNear(IntVec3 root, Map map, int radius, Predicate <IntVec3> extraValidator = null)
        {
            IntVec3 result;

            if (CellFinder.TryRandomClosewalkCellNear(root, map, radius, out result, extraValidator))
            {
                return(result);
            }
            return(root);
        }