Ejemplo n.º 1
0
        private Vertices CreateSimplePolygon(TSVector2 entrance, TSVector2 last)
        {
            bool      flag      = false;
            bool      flag2     = false;
            Vertices  vertices  = new Vertices(32);
            Vertices  vertices2 = new Vertices(32);
            Vertices  vertices3 = new Vertices(32);
            TSVector2 tSVector  = TSVector2.zero;
            bool      flag3     = entrance == TSVector2.zero || !this.InBounds(ref entrance);

            if (flag3)
            {
                flag = this.SearchHullEntrance(out entrance);
                bool flag4 = flag;
                if (flag4)
                {
                    tSVector = new TSVector2(entrance.x - 1f, entrance.y);
                }
            }
            else
            {
                bool flag5 = this.IsSolid(ref entrance);
                if (flag5)
                {
                    bool flag6 = this.IsNearPixel(ref entrance, ref last);
                    if (flag6)
                    {
                        tSVector = last;
                        flag     = true;
                    }
                    else
                    {
                        TSVector2 tSVector2;
                        bool      flag7 = this.SearchNearPixels(false, ref entrance, out tSVector2);
                        if (flag7)
                        {
                            tSVector = tSVector2;
                            flag     = true;
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }
            bool flag8 = flag;

            if (flag8)
            {
                vertices.Add(entrance);
                vertices2.Add(entrance);
                TSVector2 tSVector3 = entrance;
                TSVector2 item;
                while (true)
                {
                    bool flag9 = this.SearchForOutstandingVertex(vertices2, out item);
                    if (flag9)
                    {
                        bool flag10 = flag2;
                        if (flag10)
                        {
                            break;
                        }
                        vertices.Add(item);
                        vertices2.RemoveRange(0, vertices2.IndexOf(item));
                    }
                    last     = tSVector;
                    tSVector = tSVector3;
                    bool nextHullPoint = this.GetNextHullPoint(ref last, ref tSVector, out tSVector3);
                    if (!nextHullPoint)
                    {
                        goto IL_161;
                    }
                    vertices2.Add(tSVector3);
                    bool flag11 = tSVector3 == entrance && !flag2;
                    if (flag11)
                    {
                        flag2 = true;
                        vertices3.AddRange(vertices2);
                        bool flag12 = vertices3.Contains(entrance);
                        if (flag12)
                        {
                            vertices3.Remove(entrance);
                        }
                    }
                }
                bool flag13 = vertices3.Contains(item);
                if (flag13)
                {
                    vertices.Add(item);
                }
                IL_161 :;
            }
            return(vertices);
        }