예제 #1
0
        private IntVec3 FindRandomEdgeCellForTunnel(List <IntVec3> group, Map map)
        {
            MapGenFloatGrid caves = MapGenerator.Caves;

            IntVec3[] cardinalDirections = GenAdj.CardinalDirections;
            tmpCells.Clear();
            tmpGroupSet.Clear();
            tmpGroupSet.AddRange(group);
            for (int i = 0; i < group.Count; i++)
            {
                if (group[i].DistanceToEdge(map) < 3 || caves[group[i]] > 0f)
                {
                    continue;
                }
                for (int j = 0; j < 4; j++)
                {
                    IntVec3 item = group[i] + cardinalDirections[j];
                    if (!tmpGroupSet.Contains(item))
                    {
                        tmpCells.Add(group[i]);
                        break;
                    }
                }
            }
            if (!tmpCells.Any())
            {
                ZLogger.Warning("Could not find any valid edge cell.");
                return(group.RandomElement());
            }
            return(tmpCells.RandomElement());
        }