Example #1
0
        public static bool DetectRingFrom(CellObjCtrl cctrl, ref List <CellObjCtrl> ringObjs)
        {
            bool bRing     = false;
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(cctrl);

            if (!bCtrlling)
            {
                return(false);
            }
            ringObjs.Add(cctrl);

            CellObjCtrl ctrlNxt = CellObjCtrlUtils.GetFwdCellObjCtrl(cctrl);

            ringObjs.Add(ctrlNxt);

            int  count   = 0;
            bool bReturn = false;



            while (CellObjCtrlUtils.IsControllingSameCampS(cctrl, ctrlNxt))
            {
                ctrlNxt = CellObjCtrlUtils.GetFwdCellObjCtrl(ctrlNxt);
                if (ctrlNxt == cctrl)
                {
                    bReturn = true;
                    break;
                }

                if (ringObjs.Contains(ctrlNxt))
                {
                    int id = ringObjs.IndexOf(ctrlNxt);
                    ringObjs.RemoveRange(0, id + 1);
                    ringObjs.Add(ctrlNxt);
                    bReturn = true;
                    break;
                }

                ringObjs.Add(ctrlNxt);
                count++;

                if (count > 100)
                {
                    break;
                }
            }

            if (bReturn && ringObjs.Count >= 3)
            {
                bRing = true;
            }

            return(bRing);
        }