Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static IntVec3 RandomClosewalkCellNearNotForbidden(IntVec3 root, Map map, int radius, Pawn pawn)
        {
            IntVec3 result;

            if (!CellFinder.TryFindRandomReachableCellNear(root, map, (float)radius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => !c.IsForbidden(pawn) && c.Standable(map), null, out result, 999999))
            {
                return(CellFinder.RandomClosewalkCellNear(root, map, radius, null));
            }
            return(result);
        }
Exemplo n.º 3
0
 public static bool TryRandomClosewalkCellNear(IntVec3 root, Map map, int radius, out IntVec3 result, Predicate <IntVec3> extraValidator = null)
 {
     return(CellFinder.TryFindRandomReachableCellNear(root, map, (float)radius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => c.Standable(map) && (extraValidator == null || extraValidator(c)), null, out result, 999999));
 }