private Rendering.CachedSpriteInformation FindCachedSpriteInformation(uint spriteId)
        {
            int lastIndex = _cachedSpriteInformations.Length - 1;
            int index     = 0;

            while (index < lastIndex)
            {
                int tmpIndex = index + lastIndex >> 1;
                var cachedSpriteInformation = _cachedSpriteInformations.GetItemAt(tmpIndex);
                if (cachedSpriteInformation.SpriteId > spriteId)
                {
                    index = tmpIndex + 1;
                }
                else if (cachedSpriteInformation.SpriteId < spriteId)
                {
                    lastIndex = tmpIndex - 1;
                }
                else
                {
                    return(cachedSpriteInformation);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public int ExpireMessages(int ticks)
        {
            int totalExprired = 0;

            if (Visible)
            {
                int index = GetFirstNonHeaderIndex();
                while (_messages.Length > index)
                {
                    var message = _messages.GetItemAt(index);
                    if (message.VisibleSince < ticks && message.VisibleSince + message.TTL < ticks)
                    {
                        _messages.RemoveItemAt(index);
                        totalExprired++;
                        continue;
                    }
                    break;
                }
            }

            return(totalExprired);
        }
Exemplo n.º 3
0
        private Rendering.CachedSpriteInformation FindCachedSpriteInformation(uint spriteId)
        {
            int l = 0, r = _cachedSprites.Length - 1;

            while (l < r)
            {
                int index = l + r >> 1;
                var other = _cachedSprites.GetItemAt(index);
                if (other.SpriteId > spriteId)
                {
                    l = index + 1;
                }
                else if (other.SpriteId < spriteId)
                {
                    r = index - 1;
                }
                else
                {
                    return(other);
                }
            }

            return(null);
        }