예제 #1
0
 private static bool TryFindPlaceSpotNear(IntVec3 center, Map map, Thing thing, bool allowStacking, out IntVec3 bestSpot, Predicate <IntVec3> extraValidator = null)
 {
     GenPlace.PlaceSpotQuality placeSpotQuality = GenPlace.PlaceSpotQuality.Unusable;
     bestSpot = center;
     for (int i = 0; i < 9; i++)
     {
         IntVec3 intVec = center + GenRadial.RadialPattern[i];
         GenPlace.PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking, extraValidator);
         if (placeSpotQuality2 > placeSpotQuality)
         {
             bestSpot         = intVec;
             placeSpotQuality = placeSpotQuality2;
         }
         if (placeSpotQuality == GenPlace.PlaceSpotQuality.Perfect)
         {
             break;
         }
     }
     if (placeSpotQuality >= GenPlace.PlaceSpotQuality.Okay)
     {
         return(true);
     }
     for (int j = 0; j < GenPlace.PlaceNearMiddleRadialCells; j++)
     {
         IntVec3 intVec = center + GenRadial.RadialPattern[j];
         GenPlace.PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking, extraValidator);
         if (placeSpotQuality2 > placeSpotQuality)
         {
             bestSpot         = intVec;
             placeSpotQuality = placeSpotQuality2;
         }
         if (placeSpotQuality == GenPlace.PlaceSpotQuality.Perfect)
         {
             break;
         }
     }
     if (placeSpotQuality >= GenPlace.PlaceSpotQuality.Okay)
     {
         return(true);
     }
     for (int k = 0; k < GenPlace.PlaceNearMaxRadialCells; k++)
     {
         IntVec3 intVec = center + GenRadial.RadialPattern[k];
         GenPlace.PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking, extraValidator);
         if (placeSpotQuality2 > placeSpotQuality)
         {
             bestSpot         = intVec;
             placeSpotQuality = placeSpotQuality2;
         }
         if (placeSpotQuality == GenPlace.PlaceSpotQuality.Perfect)
         {
             break;
         }
     }
     if (placeSpotQuality > GenPlace.PlaceSpotQuality.Unusable)
     {
         return(true);
     }
     bestSpot = center;
     return(false);
 }
예제 #2
0
        private static bool TryFindPlaceSpotNear(IntVec3 center, Map map, Thing thing, bool allowStacking, out IntVec3 bestSpot)
        {
            PlaceSpotQuality placeSpotQuality = PlaceSpotQuality.Unusable;

            bestSpot = center;
            int num = 0;

            while (num < 9)
            {
                IntVec3          intVec            = center + GenRadial.RadialPattern[num];
                PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking);
                if ((int)placeSpotQuality2 > (int)placeSpotQuality)
                {
                    bestSpot         = intVec;
                    placeSpotQuality = placeSpotQuality2;
                }
                if (placeSpotQuality != PlaceSpotQuality.Perfect)
                {
                    num++;
                    continue;
                }
                break;
            }
            if ((int)placeSpotQuality >= 3)
            {
                return(true);
            }
            int num2 = 0;

            while (num2 < GenPlace.PlaceNearMiddleRadialCells)
            {
                IntVec3          intVec            = center + GenRadial.RadialPattern[num2];
                PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking);
                if ((int)placeSpotQuality2 > (int)placeSpotQuality)
                {
                    bestSpot         = intVec;
                    placeSpotQuality = placeSpotQuality2;
                }
                if (placeSpotQuality != PlaceSpotQuality.Perfect)
                {
                    num2++;
                    continue;
                }
                break;
            }
            if ((int)placeSpotQuality >= 3)
            {
                return(true);
            }
            int num3 = 0;

            while (num3 < GenPlace.PlaceNearMaxRadialCells)
            {
                IntVec3          intVec            = center + GenRadial.RadialPattern[num3];
                PlaceSpotQuality placeSpotQuality2 = GenPlace.PlaceSpotQualityAt(intVec, map, thing, center, allowStacking);
                if ((int)placeSpotQuality2 > (int)placeSpotQuality)
                {
                    bestSpot         = intVec;
                    placeSpotQuality = placeSpotQuality2;
                }
                if (placeSpotQuality != PlaceSpotQuality.Perfect)
                {
                    num3++;
                    continue;
                }
                break;
            }
            if ((int)placeSpotQuality > 0)
            {
                return(true);
            }
            bestSpot = center;
            return(false);
        }