/// <summary> /// Adds the new LootItemEntry to the global container. /// Keeps the set of entries sorted by rarity. /// </summary> public static void AddEntry(Asda2LootItemEntry entry) { List <Asda2LootItemEntry>[] lootEntry = Asda2LootMgr.LootEntries[(uint)entry.LootType]; if (entry.LootType == Asda2LootEntryType.None) { LogUtil.WarnException( string.Format("Bad drop template in db [MonstrId{0},itemID{1},guid{2}] cause type NONE", (object)entry.MonstrId, (object)entry.ItemId, (object)entry.Guid), new object[0]); } else { if ((long)entry.MonstrId >= (long)lootEntry.Length) { ArrayUtil.EnsureSize <List <Asda2LootItemEntry> >(ref lootEntry, (int)((double)entry.MonstrId * 1.5) + 1); Asda2LootMgr.LootEntries[(uint)entry.LootType] = lootEntry; } List <Asda2LootItemEntry> asda2LootItemEntryList = lootEntry[entry.MonstrId]; if (asda2LootItemEntryList == null) { lootEntry[entry.MonstrId] = asda2LootItemEntryList = new List <Asda2LootItemEntry>(); } bool flag = false; for (int index = 0; index < asda2LootItemEntryList.Count; ++index) { if ((double)asda2LootItemEntryList[index].DropChance > (double)entry.DropChance) { flag = true; asda2LootItemEntryList.Insert(index, entry); break; } } if (flag) { return; } asda2LootItemEntryList.Add(entry); } }
/// <summary> /// Adds the new LootItemEntry to the global container. /// Keeps the set of entries sorted by rarity. /// </summary> public static void AddEntry(Asda2LootItemEntry entry) { var entries = LootEntries[(uint)entry.LootType]; if (entry.LootType == Asda2LootEntryType.None) { LogUtil.WarnException(string.Format("Bad drop template in db [MonstrId{0},itemID{1},guid{2}] cause type NONE", entry.MonstrId, entry.ItemId, entry.Guid)); return; } if (entry.MonstrId >= entries.Length) { ArrayUtil.EnsureSize(ref entries, (int)(entry.MonstrId * ArrayUtil.LoadConstant) + 1); LootEntries[(uint)entry.LootType] = entries; } var list = entries[entry.MonstrId]; if (list == null) { entries[entry.MonstrId] = list = new List <Asda2LootItemEntry>(); } // add entry sorted var added = false; for (var i = 0; i < list.Count; i++) { var ent = list[i]; if (ent.DropChance > entry.DropChance) { added = true; list.Insert(i, entry); break; } } if (!added) { list.Add(entry); } }