Exemplo n.º 1
0
        private static SpriteBatch privSortedAdd(int priority)
        {
            DLink       pLink;
            SpriteBatch pCur;
            SpriteBatch pTmp;
            SpriteBatch pNode;

            //SpriteBatchMan pMan = SpriteBatchMan.privGetInstance();
            SpriteBatchMan pMan = SpriteBatchMan.pActiveSBMan;

            Debug.Assert(pMan != null);

            SpriteBatch pSpriteBatch = (SpriteBatch)pMan.baseGetActive();

            if (pSpriteBatch == null || pSpriteBatch.priority >= priority)
            {
                pNode = (SpriteBatch)pMan.baseAdd();
                Debug.Assert(pNode != null);
            }
            else
            {
                pNode = (SpriteBatch)pMan.pullNodeFromReserve();
                Debug.Assert(pNode != null);

                pCur = pSpriteBatch;

                while (pCur.pNext != null)
                {
                    pTmp = (SpriteBatch)pCur.pNext;

                    if (pTmp.priority < priority)
                    {
                        pCur = (SpriteBatch)pCur.pNext;
                        break;
                    }
                }

                pLink = (DLink)pCur;
                pNode = (SpriteBatch)pMan.baseAddAfter(ref pLink, pNode);
                Debug.Assert(pNode != null);
            }

            return(pNode);
        }