public static void FindStartingCellsFor2Groups(Map map, out IntVec3 first, out IntVec3 second)
        {
            for (int i = 0; i < 10; i++)
            {
                if (MultipleCaravansCellFinder.TryFindOppositeSpots(map, 0.05f, out first, out second))
                {
                    return;
                }
            }
            for (int j = 0; j < 10; j++)
            {
                if (MultipleCaravansCellFinder.TryFindOppositeSpots(map, 0.15f, out first, out second))
                {
                    return;
                }
            }
            if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map), map, CellFinder.EdgeRoadChance_Neutral, out first))
            {
                Log.Error("Could not find any valid starting cell for a caravan.", false);
                first  = CellFinder.RandomCell(map);
                second = CellFinder.RandomCell(map);
                return;
            }
            IntVec3 localFirst             = first;
            float   tryMinDistBetweenSpots = (float)Mathf.Max(map.Size.x, map.Size.z) * 0.6f;

            if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && !x.InHorDistOf(localFirst, tryMinDistBetweenSpots), map, CellFinder.EdgeRoadChance_Neutral, out second) && !CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map), map, 0.5f, out second))
            {
                Log.Error("Could not find any valid starting cell for a caravan.", false);
                second = CellFinder.RandomCell(map);
                return;
            }
            first  = CellFinder.RandomClosewalkCellNear(first, map, 7, null);
            second = CellFinder.RandomClosewalkCellNear(second, map, 7, null);
        }
Пример #2
0
        public static void FindStartingCellsFor2Groups(Map map, out IntVec3 first, out IntVec3 second)
        {
            int num = 0;

            while (num < 10)
            {
                if (!MultipleCaravansCellFinder.TryFindOppositeSpots(map, 0.05f, out first, out second))
                {
                    num++;
                    continue;
                }
                return;
            }
            int num2 = 0;

            while (num2 < 10)
            {
                if (!MultipleCaravansCellFinder.TryFindOppositeSpots(map, 0.15f, out first, out second))
                {
                    num2++;
                    continue;
                }
                return;
            }
            if (!CellFinder.TryFindRandomEdgeCellWith((Predicate <IntVec3>)((IntVec3 x) => x.Standable(map) && !x.Fogged(map)), map, CellFinder.EdgeRoadChance_Neutral, out first))
            {
                Log.Error("Could not find any valid starting cell for a caravan.");
                first  = CellFinder.RandomCell(map);
                second = CellFinder.RandomCell(map);
            }
            else
            {
                IntVec3 localFirst             = first;
                IntVec3 size                   = map.Size;
                int     x2                     = size.x;
                IntVec3 size2                  = map.Size;
                float   tryMinDistBetweenSpots = (float)((float)Mathf.Max(x2, size2.z) * 0.60000002384185791);
                if (!CellFinder.TryFindRandomEdgeCellWith((Predicate <IntVec3>)((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && !x.InHorDistOf(localFirst, tryMinDistBetweenSpots)), map, CellFinder.EdgeRoadChance_Neutral, out second) && !CellFinder.TryFindRandomEdgeCellWith((Predicate <IntVec3>)((IntVec3 x) => x.Standable(map) && !x.Fogged(map)), map, 0.5f, out second))
                {
                    Log.Error("Could not find any valid starting cell for a caravan.");
                    second = CellFinder.RandomCell(map);
                }
                else
                {
                    first  = CellFinder.RandomClosewalkCellNear(first, map, 7, null);
                    second = CellFinder.RandomClosewalkCellNear(second, map, 7, null);
                }
            }
        }