Example #1
0
        /// <summary>
        /// (Cross-Game compatible) Return this with all Items of type TCast removed
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TCast">The Type of the Items that you want to remove</typeparam>
        /// <param name="lockList"></param>
        /// <returns></returns>
        public static LockList <TSource> RemoveItemsOfType <TSource, TCast>(this LockList <TSource> lockList)
            where TSource : Il2CppSystem.Object
            where TCast : Il2CppSystem.Object
        {
            if (!HasItemsOfType <TSource, TCast>(lockList))
            {
                return(lockList);
            }

            int            numRemoved = 0;
            List <TSource> arrayList  = lockList.ToList();

            for (int i = 0; i < lockList.Count; i++)
            {
                TSource item = lockList[i];
                if (item is null || !item.IsType <TCast>())
                {
                    continue;
                }

                arrayList.RemoveAt(i - numRemoved);
                numRemoved++;
            }

            return(arrayList.ToLockList());
        }
Example #2
0
        /// <summary>
        /// (Cross-Game compatible) Return this with the first Item of type TCast removed
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TCast">The Type of the Item you want to remove</typeparam>
        /// <param name="lockList"></param>
        /// <param name="itemToRemove">The specific Item to remove</param>
        /// <returns></returns>
        public static LockList <TSource> RemoveItem <TSource, TCast>(this LockList <TSource> lockList, TCast itemToRemove)
            where TSource : Il2CppSystem.Object where TCast : Il2CppSystem.Object
        {
            if (!HasItemsOfType <TSource, TCast>(lockList))
            {
                return(lockList);
            }

            List <TSource> arrayList = lockList.ToList();

            for (int i = 0; i < lockList.Count; i++)
            {
                TSource item = lockList[i];
                if (item is null || !item.Equals(itemToRemove.TryCast <TCast>()))
                {
                    continue;
                }

                arrayList.RemoveAt(i);
                break;
            }

            return(arrayList.ToLockList());
        }