Exemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="ActionDisplay"/> in this collection.
        /// </summary>
        /// <returns>The new <see cref="ActionDisplay"/>.</returns>
        public ActionDisplay CreateAction()
        {
            var id   = _items.NextFreeIndex();
            var item = new ActionDisplay(new ActionDisplayID(id));

            _items.Insert(id, item);
            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds the next free <see cref="GrhIndex"/>.
        /// </summary>
        /// <returns>The next free <see cref="GrhIndex"/>.</returns>
        public static GrhIndex NextFreeIndex()
        {
            if (_grhDatas.TrackFree)
            {
                return(new GrhIndex(_grhDatas.NextFreeIndex()));
            }

            // Start at the first index
            var i = GrhIndex.MinValue;

            // Just loop through the indicies until we find one thats not in use or
            // passes the length of the GrhDatas array (which means its obviously not in use)
            while (_grhDatas.CanGet(i) && _grhDatas[i] != null)
            {
                i++;
            }

            Debug.Assert(i != GrhIndex.Invalid);

            return(new GrhIndex(i));
        }