public static uint GetOrAllocIndexFromPoolHelper(CpuThreadState CpuThreadState, Type Type,
                                                  IHleUidPoolClass Item)
 {
     //Console.Error.WriteLine("AllocIndexFromPoolHelper");
     return((uint)CpuThreadState.CpuProcessor.InjectContext.GetInstance <HleUidPoolManager>()
            .GetOrAllocIndex(Type, Item));
 }
示例#2
0
            public int Alloc(IHleUidPoolClass Item)
            {
                if (Item.GetType() != this.Type)
                {
                    throw(new InvalidOperationException("Trying to insert invalid object type"));
                }
                int Index = -1;

                if (ReuseIds)
                {
                    //Console.Error.WriteLine("******************************************");
                    if (FreedIds.Count > 0)
                    {
                        Index = FreedIds.Min();
                        FreedIds.Remove(Index);
                    }
                }

                if (Index == -1)
                {
                    Index = LastId++;
                }

                Items[Index]   = Item;
                RevItems[Item] = Index;
                return(Index);
            }
示例#3
0
 public int GetIndex(IHleUidPoolClass Item)
 {
     if (!RevItems.ContainsKey(Item))
     {
         ThrowNotFound();
     }
     return(RevItems[Item]);
 }
示例#4
0
 public int GetOrAllocIndex(IHleUidPoolClass Item)
 {
     if (!RevItems.ContainsKey(Item))
     {
         return(Alloc(Item));
     }
     return(GetIndex(Item));
 }
示例#5
0
 //[MethodImpl(MethodImplOptions.Synchronized)]
 public void RemoveItem(IHleUidPoolClass Item)
 {
     Item.Dispose();
     if (ReuseIds)
     {
         FreedIds.Add(RevItems[Item]);
     }
     Items.Remove(RevItems[Item]);
     RevItems.Remove(Item);
 }
示例#6
0
 public static int GetUidIndex(this IHleUidPoolClass IHleUidPoolClass, InjectContext InjectContext)
 {
     return(InjectContext.GetInstance <HleUidPoolManager>()
            .GetOrAllocIndex(IHleUidPoolClass.GetType(), IHleUidPoolClass));
 }
示例#7
0
 public static void RemoveUid(this IHleUidPoolClass IHleUidPoolClass, InjectContext InjectContext)
 {
     InjectContext.GetInstance <HleUidPoolManager>().RemoveItem(IHleUidPoolClass.GetType(), IHleUidPoolClass);
 }
示例#8
0
 public int GetIndex(Type Type, IHleUidPoolClass Item)
 {
     return(_GetTypePool(Type).GetIndex(Item));
 }
示例#9
0
 public void RemoveItem(Type Type, IHleUidPoolClass Item)
 {
     _GetTypePool(Type).RemoveItem(Item);
 }
示例#10
0
 public int Alloc(Type Type, IHleUidPoolClass Item)
 {
     return(_GetTypePool(Type).Alloc(Item));
 }