Пример #1
0
        public static IEnumerable <MillingLootItemEntry> GetAllDataHolders()
        {
            List <MillingLootItemEntry> all = new List <MillingLootItemEntry>(10000);

            LootItemEntry.AddItems <MillingLootItemEntry>(LootEntryType.Milling, all);
            return((IEnumerable <MillingLootItemEntry>)all);
        }
Пример #2
0
        public static IEnumerable <GOLootItemEntry> GetAllDataHolders()
        {
            List <GOLootItemEntry> all = new List <GOLootItemEntry>(20000);

            LootItemEntry.AddItems <GOLootItemEntry>(LootEntryType.GameObject, all);
            return((IEnumerable <GOLootItemEntry>)all);
        }
Пример #3
0
        public static IEnumerable <ReferenceLootItemEntry> GetAllDataHolders()
        {
            List <ReferenceLootItemEntry> all = new List <ReferenceLootItemEntry>(10000);

            LootItemEntry.AddItems <ReferenceLootItemEntry>(LootEntryType.Reference, all);
            return((IEnumerable <ReferenceLootItemEntry>)all);
        }
Пример #4
0
        public static IEnumerable <PickPocketLootItemEntry> GetAllDataHolders()
        {
            List <PickPocketLootItemEntry> all = new List <PickPocketLootItemEntry>(10000);

            LootItemEntry.AddItems <PickPocketLootItemEntry>(LootEntryType.PickPocketing, all);
            return((IEnumerable <PickPocketLootItemEntry>)all);
        }
Пример #5
0
        public static IEnumerable <NPCLootItemEntry> GetAllDataHolders()
        {
            List <NPCLootItemEntry> all = new List <NPCLootItemEntry>(500000);

            LootItemEntry.AddItems <NPCLootItemEntry>(LootEntryType.NPCCorpse, all);
            LootItemEntry.AddItems <NPCLootItemEntry>(LootEntryType.Skinning, all);
            LootItemEntry.AddItems <NPCLootItemEntry>(LootEntryType.PickPocketing, all);
            return((IEnumerable <NPCLootItemEntry>)all);
        }
Пример #6
0
        public static IEnumerable <ItemLootItemEntry> GetAllDataHolders()
        {
            List <ItemLootItemEntry> all = new List <ItemLootItemEntry>(20000);

            LootItemEntry.AddItems <ItemLootItemEntry>(LootEntryType.Item, all);
            LootItemEntry.AddItems <ItemLootItemEntry>(LootEntryType.Disenchanting, all);
            LootItemEntry.AddItems <ItemLootItemEntry>(LootEntryType.Prospecting, all);
            LootItemEntry.AddItems <ItemLootItemEntry>(LootEntryType.Milling, all);
            return((IEnumerable <ItemLootItemEntry>)all);
        }
Пример #7
0
        static void LookupRef(ResolvedLootItemList list, LootItemEntry entry)
        {
            // TODO: Loot groups (see http://udbwiki.no-ip.org/index.php/Gameobject_loot_template#groupid)

            var referencedEntries = GetEntries(LootEntryType.Reference, entry.ReferencedEntryId);

            if (referencedEntries != null)
            {
                if (referencedEntries.ResolveStatus < 1)
                {
                    // first step
                    referencedEntries.ResolveStatus = 1;
                    foreach (var refEntry in referencedEntries)
                    {
                        if (refEntry is LootItemEntry)
                        {
                            var itemEntry = (LootItemEntry)refEntry;
                            if (itemEntry.ReferencedEntryId > 0)
                            {
                                LookupRef(list, itemEntry);
                                continue;
                            }
                        }
                        AddRef(list, refEntry);
                    }
                    referencedEntries.ResolveStatus = 2;
                }
                else if (list.ResolveStatus == 1)
                {
                    // list is already being resolved
                    LogManager.GetCurrentClassLogger().Warn("Infinite loop in Loot references detected in: " + entry);
                }
                else
                {
                    // second step
                    foreach (var refEntry in referencedEntries)
                    {
                        AddRef(list, refEntry);
                    }
                }
            }
        }
Пример #8
0
        private static void LookupRef(ResolvedLootItemList list, LootItemEntry entry)
        {
            ResolvedLootItemList entries = LootMgr.GetEntries(LootEntryType.Reference, entry.ReferencedEntryId);

            if (entries == null)
            {
                return;
            }
            if (entries.ResolveStatus < (byte)1)
            {
                entries.ResolveStatus = (byte)1;
                foreach (LootEntity ent in (List <LootEntity>)entries)
                {
                    if (ent is LootItemEntry)
                    {
                        LootItemEntry entry1 = (LootItemEntry)ent;
                        if (entry1.ReferencedEntryId > 0U)
                        {
                            LootMgr.LookupRef(list, entry1);
                            continue;
                        }
                    }

                    LootMgr.AddRef(list, ent);
                }

                entries.ResolveStatus = (byte)2;
            }
            else if (list.ResolveStatus == (byte)1)
            {
                LogManager.GetCurrentClassLogger()
                .Warn("Infinite loop in Loot references detected in: " + (object)entry);
            }
            else
            {
                foreach (LootEntity ent in (List <LootEntity>)entries)
                {
                    LootMgr.AddRef(list, ent);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Adds the new LootItemEntry to the global container.
        /// Keeps the set of entries sorted by rarity.
        /// </summary>
        public static void AddEntry(LootItemEntry entry)
        {
            var entries = LootEntries[(uint)entry.LootType];

            if (entry.EntryId >= entries.Length)
            {
                ArrayUtil.EnsureSize(ref entries, (int)(entry.EntryId * ArrayUtil.LoadConstant) + 1);
                LootEntries[(uint)entry.LootType] = entries;
            }

            var list = entries[entry.EntryId];

            if (list == null)
            {
                entries[entry.EntryId] = list = new ResolvedLootItemList();
            }

            if (entry.ReferencedEntryId > 0 || entry.GroupId > 0)
            {
                ReferenceEntries.Add(new KeyValuePair <ResolvedLootItemList, LootItemEntry>(list, entry));
            }

            // 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);
            }
        }
Пример #10
0
        /// <summary>
        /// Adds the new LootItemEntry to the global container.
        /// Keeps the set of entries sorted by rarity.
        /// </summary>
        public static void AddEntry(LootItemEntry entry)
        {
            ResolvedLootItemList[] lootEntry = LootMgr.LootEntries[(uint)entry.LootType];
            if ((long)entry.EntryId >= (long)lootEntry.Length)
            {
                ArrayUtil.EnsureSize <ResolvedLootItemList>(ref lootEntry, (int)((double)entry.EntryId * 1.5) + 1);
                LootMgr.LootEntries[(uint)entry.LootType] = lootEntry;
            }

            ResolvedLootItemList key = lootEntry[entry.EntryId];

            if (key == null)
            {
                lootEntry[entry.EntryId] = key = new ResolvedLootItemList();
            }
            if (entry.ReferencedEntryId > 0U || entry.GroupId > 0U)
            {
                LootMgr.ReferenceEntries.Add(new KeyValuePair <ResolvedLootItemList, LootItemEntry>(key, entry));
            }
            bool flag = false;

            for (int index = 0; index < key.Count; ++index)
            {
                if ((double)key[index].DropChance > (double)entry.DropChance)
                {
                    flag = true;
                    key.Insert(index, (LootEntity)entry);
                    break;
                }
            }

            if (flag)
            {
                return;
            }
            key.Add((LootEntity)entry);
        }