Esempio n. 1
0
        public bool PlanLegalityCheck()
        {
            for (int p = 0; p < numberOfPoints; p++)
            {
                this[p].illegal = false;
            }
            bool output = false;

            for (int indexAA = 0; indexAA < numberOfPoints; indexAA++)
            {
                Vector2Int p0      = _points[indexAA].position;
                int        indexAB = (indexAA + 1) % numberOfPoints;
                Vector2Int p1      = _points[indexAB].position;
                for (int indexBA = 0; indexBA < numberOfPoints; indexBA++)
                {
                    if (indexAA == indexBA)
                    {
                        continue;                                        //skip testing wall on itself
                    }
                    int indexBB = (indexBA + 1) % numberOfPoints;
                    if (indexAA == indexBB)
                    {
                        continue;                                        //skip testing wall on itself
                    }
                    Vector2Int p2 = _points[indexBA].position;
                    Vector2Int p3 = _points[indexBB].position;


                    if (BuildrUtils.PointOnLine(p0, p2, p3))
                    {
                        _points[indexAA].illegal = true;
                        _points[indexBA].illegal = true;
                        output = true;
                        continue;
                    }

                    if (indexAA == indexBB || indexAB == indexBA || indexAB == indexBB)
                    {
                        continue;                                                                                    //don't test lines that connect
                    }
                    //                    if (p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3) continue;//don't test lines that connect

                    if (BuildrUtils.FastLineIntersection(p0, p1, p2, p3))
                    {
                        _points[indexAA].illegal = true;
                        _points[indexBA].illegal = true;
                        output = true;
                    }
                }
            }
            return(output);
        }