コード例 #1
0
        public static IntVec3 RandomSpawnCellForPawnNear(IntVec3 root, Map map, int firstTryWithRadius = 4)
        {
            MapExtension mapE = MapExtensionUtility.GetExtensionToMap(map);

            if (GenGridShips.Standable(root, map, mapE) && root.GetFirstPawn(map) is null)
            {
                return(root);
            }
            IntVec3 result;
            int     num = firstTryWithRadius;

            for (int i = 0; i < 3; i++)
            {
                if (CellFinderExtended.TryFindRandomReachableCellNear(root, map, (float)num, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c)
                                                                      => GenGridShips.Standable(c, map, mapE) && (root.Fogged(map) || !c.Fogged(map)) && c.GetFirstPawn(map) is null, out result, null, 999999))
                {
                    return(result);
                }
                num *= 2;
            }
            num = firstTryWithRadius + 1;

            while (!CellFinderExtended.TryRandomClosewalkCellNear(root, map, num, out result, null))
            {
                if (num > map.Size.x / 2 && num > map.Size.z / 2)
                {
                    return(root);
                }
                num *= 2;
            }
            return(result);
        }
コード例 #2
0
 public static IntVec3 RandomClosewalkCellNear(IntVec3 root, Map map, int radius, Predicate <IntVec3> validator = null)
 {
     if (CellFinderExtended.TryRandomClosewalkCellNear(root, map, radius, out IntVec3 result, validator))
     {
         return(result);
     }
     return(root);
 }