public static void LoadAll() { if (ItemMgr.Loaded) { return; } ContentMgr.Load <ItemTemplate>(); ItemMgr.OnLoaded(); foreach (ItemTemplate template in ItemMgr.Templates) { if (template != null) { template.InitializeTemplate(); } } ItemMgr.TruncSets(); if (ArchetypeMgr.Loaded) { ArchetypeMgr.LoadItems(); } SpellHandler.InitTools(); ItemMgr.LoadItemCharRelations(); Singleton <AuctionMgr> .Instance.LoadItems(); if (QuestMgr.Loaded) { ItemMgr.EnsureItemQuestRelations(); } ServerApp <WCell.RealmServer.RealmServer> .InitMgr.SignalGlobalMgrReady(typeof(ItemMgr)); ItemMgr.Loaded = true; }
public ItemStackTemplate(Asda2ItemId id, int amount) { this = new ItemStackTemplate(ItemMgr.GetTemplate(id), amount); if (this.m_Template == null) { throw new ArgumentException("id " + (object)id + " is invalid."); } }
public ItemStackTemplate(Asda2ItemId id) : this(ItemMgr.GetTemplate(id), 1) { if (m_Template == null) { throw new ArgumentException("ItemId " + id + " is invalid."); } }
public ItemStackTemplate(ItemId id, int amount) : this(ItemMgr.GetTemplate(id), amount) { if (m_Template == null) { throw new ArgumentException("id " + id + " is invalid."); } }
public static void ForceInitialize() { ItemMgr.InitMisc(); if (ItemMgr.Loaded) { return; } ItemMgr.LoadAll(); }
/// <summary> /// Tries to add ONE new item with the given template to the given slot. /// Make sure the given targetSlot is valid before calling this method. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(ItemId id, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { var templ = ItemMgr.GetTemplate(id); if (templ != null) { return(TryAdd(templ, targetSlot, reception)); } return(InventoryError.Invalid); }
/// <summary> /// Tries to add an Item with the given template and amount ot the given slot. /// Make sure the given targetSlot is valid before calling this method. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(ItemId id, ref int amount, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { var templ = ItemMgr.GetTemplate(id); if (templ != null) { return(TryAdd(templ, ref amount, targetSlot, reception)); } return(InventoryError.ITEM_NOT_FOUND); }
/// <summary> /// Tries to add ONE new item with the given template to the given slot. /// Make sure the given targetSlot is valid before calling this method. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(Asda2ItemId id, InventorySlot targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { var templ = ItemMgr.GetTemplate(id); if (templ != null) { return(TryAdd(templ, (int)targetSlot, reception)); } return(InventoryError.ITEM_NOT_FOUND); }
public static ItemRandomSuffixEntry GetRandomSuffixEntry(uint id) { if (ItemMgr.RandomSuffixReader == null) { ItemMgr.LoadDBCs(); } ItemRandomSuffixEntry randomSuffixEntry; ItemMgr.RandomSuffixReader.Entries.TryGetValue((int)id, out randomSuffixEntry); return(randomSuffixEntry); }
/// <summary> /// Tries to add a new item with the given template and amount ot the given slot. /// Make sure the given targetSlot is valid before calling this method. /// If slot is occupied, method will find another unoccupied slot. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(Asda2ItemId id, ref int amount, InventorySlot targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { ItemTemplate template = ItemMgr.GetTemplate(id); if (template != null) { return(TryAdd(template, ref amount, (int)targetSlot, reception)); } return(InventoryError.Invalid); }
public static ScalingStatDistributionEntry GetScalingStatDistributionEntry(uint id) { if (ItemMgr.ScalingStatDistributionReader == null) { ItemMgr.LoadDBCs(); } ScalingStatDistributionEntry distributionEntry; ItemMgr.ScalingStatDistributionReader.Entries.TryGetValue((int)id, out distributionEntry); return(distributionEntry); }
public static ScalingStatValues GetScalingStatValue(uint id) { if (ItemMgr.ScalingStatValuesReader == null) { ItemMgr.LoadDBCs(); } ScalingStatValues scalingStatValues; ItemMgr.ScalingStatValuesReader.Entries.TryGetValue((int)id, out scalingStatValues); return(scalingStatValues); }
/// <summary> /// Tries to add an Item with the given template and amount ot the given slot. /// Make sure the given targetSlot is valid before calling this method. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(Asda2ItemId id, ref int amount, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { ItemTemplate template = ItemMgr.GetTemplate(id); if (template != null) { return(this.TryAdd(template, ref amount, targetSlot, reception)); } return(InventoryError.ITEM_NOT_FOUND); }
/// <summary> /// Tries to add ONE new item with the given template to the given slot. /// Make sure the given targetSlot is valid before calling this method. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(Asda2ItemId id, int targetSlot, ItemReceptionType reception = ItemReceptionType.Receive) { ItemTemplate template = ItemMgr.GetTemplate(id); if (template != null) { return(this.TryAdd(template, targetSlot, reception)); } return(InventoryError.Invalid); }
private static void OnLoaded() { foreach (Tuple <Asda2ItemId, Action <ItemTemplate> > loadHook in ItemMgr.loadHooks) { loadHook.Item2(ItemMgr.GetTemplateForced(loadHook.Item1)); } foreach (Tuple <ItemClass, Action <ItemTemplate> > itemClassLoadHook in ItemMgr.itemClassLoadHooks) { foreach (ItemTemplate template in ItemMgr.GetTemplates(itemClassLoadHook.Item1)) { itemClassLoadHook.Item2(template); } } }
public static void InitMisc() { if (ItemMgr.ContainerSlotsWithBank != null) { return; } LockEntry.Initialize(); ItemMgr.ContainerSlotsWithBank = new bool[118]; ItemMgr.ContainerSlotsWithBank.Fill <bool>(true, 19, 22); ItemMgr.ContainerSlotsWithBank.Fill <bool>(true, 67, 73); ItemMgr.ContainerSlotsWithoutBank = new bool[118]; ItemMgr.ContainerSlotsWithoutBank.Fill <bool>(true, 19, 22); ItemMgr.ContainerBankSlots = new bool[118]; ItemMgr.ContainerBankSlots.Fill <bool>(true, 67, 73); ItemMgr.InitItemSlotHandlers(); }
internal void InitializeTemplate() { if (Names == null) { Names = new string[8]; } if (Descriptions == null) { Descriptions = new string[8]; } if (DefaultDescription == null) { DefaultDescription = ""; } if (string.IsNullOrEmpty(DefaultName) || Id == 0U) { return; } ItemId = (Asda2ItemId)Id; RequiredSkill = SkillHandler.Get(RequiredSkillId); Set = ItemMgr.GetSet(SetId); Lock = LockEntry.Entries.Get(LockId); RequiredFaction = FactionMgr.Get(RequiredFactionId); RequiredProfession = SpellHandler.Get(RequiredProfessionId); SubClassMask = (ItemSubClassMask)(1 << (int)(SubClass & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown)) ); EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType); InventorySlotMask = (InventorySlotTypeMask)(1 << (int)(InventorySlotType & (InventorySlotType.WeaponRanged | InventorySlotType.Cloak))); IsAmmo = InventorySlotType == InventorySlotType.Ammo; IsKey = Class == ItemClass.Key; IsBag = InventorySlotType == InventorySlotType.Bag; IsContainer = Class == ItemClass.Container || Class == ItemClass.Quiver; IsStackable = MaxAmount > 1 && RandomSuffixId == 0U && RandomPropertiesId == 0U; IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon; SetIsWeapon(); if (ToolCategory != ToolCategory.None) { ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this; } if (GemPropertiesId != 0U) { GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId); if (GemProperties != null) { GemProperties.Enchantment.GemTemplate = this; } } if (Sockets == null) { Sockets = new SocketInfo[3]; } else if (Sockets.Contains( sock => sock.Color != SocketColor.None)) { HasSockets = true; } if (Damages == null) { Damages = DamageInfo.EmptyArray; } if (Resistances == null) { Resistances = new int[7]; } if (SocketBonusEnchantId != 0U) { SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId); } switch (Class) { case ItemClass.Weapon: ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass); break; case ItemClass.Armor: ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass); break; } int sheathType = (int)SheathType; if (Spells != null) { ArrayUtil.Prune(ref Spells); for (int index = 0; index < 5; ++index) { Spells[index].Index = (uint)index; Spells[index].FinalizeAfterLoad(); } } else { Spells = ItemSpell.EmptyArray; } UseSpell = Spells.Where( itemSpell => { if (itemSpell.Trigger == ItemSpellTrigger.Use) { return(itemSpell.Spell != null); } return(false); }).FirstOrDefault(); if (UseSpell != null) { UseSpell.Spell.RequiredTargetType = RequiredTargetType; UseSpell.Spell.RequiredTargetId = RequiredTargetId; } EquipSpells = Spells.Where(spell => { if (spell.Trigger == ItemSpellTrigger.Equip) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell).ToArray(); SoulstoneSpell = Spells.Where( spell => { if (spell.Trigger == ItemSpellTrigger.Soulstone) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell) .FirstOrDefault(); HitSpells = Spells.Where(spell => { if (spell.Trigger == ItemSpellTrigger.ChanceOnHit) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell).ToArray(); ConsumesAmount = (Class == ItemClass.Consumable || Spells.Contains( spell => spell.Trigger == ItemSpellTrigger.Consume)) && (UseSpell == null || !UseSpell.HasCharges); IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell; IsInventory = InventorySlotType != InventorySlotType.None && InventorySlotType != InventorySlotType.Bag && InventorySlotType != InventorySlotType.Quiver && InventorySlotType != InventorySlotType.Relic; if (SetId != ItemSetId.None) { ItemSet itemSet = ItemMgr.Sets.Get((uint)SetId); if (itemSet != null) { int num = (int)ArrayUtil.Add(ref itemSet.Templates, this); } } if (Mods != null) { ArrayUtil.TruncVals(ref Mods); } else { Mods = StatModifier.EmptyArray; } IsCharter = Flags.HasFlag(ItemFlags.Charter); RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (IsCharter) { Creator = () => (Item) new PetitionCharter(); } else if (IsContainer) { Creator = () => (Item) new Container(); } else { Creator = () => new Item(); } }
internal void InitializeTemplate() { if (Names == null) { Names = new string[(int)ClientLocale.End]; } if (Descriptions == null) { Descriptions = new string[(int)ClientLocale.End]; } if (DefaultDescription == null) { DefaultDescription = ""; } if (string.IsNullOrEmpty(DefaultName) || Id == 0) { // something's off with these entries return; } ItemId = (ItemId)Id; //Faction = (FactionId)Faction; // faction, 3.2.2 RequiredSkill = SkillHandler.Get(RequiredSkillId); Set = ItemMgr.GetSet(SetId); Lock = LockEntry.Entries.Get(LockId); RequiredFaction = FactionMgr.Get(RequiredFactionId); RequiredProfession = SpellHandler.Get(RequiredProfessionId); SubClassMask = (ItemSubClassMask)(1 << (int)SubClass); EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType); InventorySlotMask = (InventorySlotTypeMask)(1 << (int)InventorySlotType); IsAmmo = InventorySlotType == InventorySlotType.Ammo; IsKey = Class == ItemClass.Key; IsBag = InventorySlotType == InventorySlotType.Bag; IsContainer = Class == ItemClass.Container || Class == ItemClass.Quiver; // enchantables can't be stacked IsStackable = MaxAmount > 1 && RandomSuffixId == 0 && RandomPropertiesId == 0; IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon; SetIsWeapon(); if (ToolCategory != 0) // && TotemCategory != TotemCategory.SkinningKnife) { ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this; } if (GemPropertiesId != 0) { GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId); if (GemProperties != null) { GemProperties.Enchantment.GemTemplate = this; } } if (Sockets == null) { Sockets = new SocketInfo[ItemConstants.MaxSocketCount]; } else if (Sockets.Contains(sock => sock.Color != 0)) { HasSockets = true; } if (Damages == null) { Damages = DamageInfo.EmptyArray; } if (Resistances == null) { Resistances = new int[(int)DamageSchool.Count]; } if (SocketBonusEnchantId != 0) { SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId); } switch (Class) { case ItemClass.Weapon: ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass); break; case ItemClass.Armor: ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass); break; } if (SheathType == SheathType.Undetermined) { // TODO: Read sheath-id from Item.dbc } // spells if (Spells != null) { ArrayUtil.Prune(ref Spells); for (int i = 0; i < 5; i++) { Spells[i].Index = (uint)i; Spells[i].FinalizeAfterLoad(); } } else { Spells = ItemSpell.EmptyArray; } UseSpell = Spells.Where(itemSpell => itemSpell.Trigger == ItemSpellTrigger.Use && itemSpell.Spell != null).FirstOrDefault(); if (UseSpell != null) { UseSpell.Spell.RequiredTargetType = RequiredTargetType; UseSpell.Spell.RequiredTargetId = RequiredTargetId; } EquipSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Equip && spell.Spell != null).Select(itemSpell => itemSpell.Spell).ToArray(); SoulstoneSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Soulstone && spell.Spell != null).Select(itemSpell => itemSpell.Spell).FirstOrDefault(); HitSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.ChanceOnHit && spell.Spell != null).Select(itemSpell => itemSpell.Spell).ToArray(); if (UseSpell != null && (UseSpell.Id == SpellId.Learning || UseSpell.Id == SpellId.Learning_2)) { // Teaching TeachSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Consume).FirstOrDefault(); } ConsumesAmount = (Class == ItemClass.Consumable || Spells.Contains(spell => spell.Trigger == ItemSpellTrigger.Consume)) && (UseSpell == null || !UseSpell.HasCharges); IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell; IsInventory = InventorySlotType != InventorySlotType.None && InventorySlotType != InventorySlotType.Bag && InventorySlotType != InventorySlotType.Quiver && InventorySlotType != InventorySlotType.Relic; // find set if (SetId != 0) { var set = ItemMgr.Sets.Get((uint)SetId); if (set != null) { ArrayUtil.Add(ref set.Templates, this); } } // truncate arrays if (Mods != null) { ArrayUtil.TruncVals(ref Mods); } else { Mods = StatModifier.EmptyArray; } IsCharter = Flags.HasFlag(ItemFlags.Charter); RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (IsCharter) { Creator = () => new PetitionCharter(); } else if (IsContainer) { Creator = () => new Container(); } else { Creator = () => new Item(); } }
public Item AddUnchecked(int slot, ItemId id, int amount, bool isNew) { var templ = ItemMgr.GetTemplate(id); return(AddUnchecked(slot, templ, amount, isNew)); }
public static void Initialize() { ItemMgr.InitMisc(); ItemMgr.LoadAll(); }
/// <summary> /// Tries to add a new item with the given id to a free slot. /// </summary> /// <returns>The result (InventoryError.OK in case that it worked)</returns> public InventoryError TryAdd(ItemId id, ItemReceptionType reception = ItemReceptionType.Receive) { return(TryAdd(ItemMgr.GetTemplate(id), reception)); }
internal void InitializeTemplate() { if (this.Names == null) { this.Names = new string[8]; } if (this.Descriptions == null) { this.Descriptions = new string[8]; } if (this.DefaultDescription == null) { this.DefaultDescription = ""; } if (string.IsNullOrEmpty(this.DefaultName) || this.Id == 0U) { return; } this.ItemId = (Asda2ItemId)this.Id; this.RequiredSkill = SkillHandler.Get(this.RequiredSkillId); this.Set = ItemMgr.GetSet(this.SetId); this.Lock = LockEntry.Entries.Get <LockEntry>(this.LockId); this.RequiredFaction = FactionMgr.Get(this.RequiredFactionId); this.RequiredProfession = SpellHandler.Get(this.RequiredProfessionId); this.SubClassMask = (ItemSubClassMask)(1 << (int)(this.SubClass & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown)) ); this.EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get <EquipmentSlot[]>((uint)this.InventorySlotType); this.InventorySlotMask = (InventorySlotTypeMask)(1 << (int)(this.InventorySlotType & (InventorySlotType.WeaponRanged | InventorySlotType.Cloak))); this.IsAmmo = this.InventorySlotType == InventorySlotType.Ammo; this.IsKey = this.Class == ItemClass.Key; this.IsBag = this.InventorySlotType == InventorySlotType.Bag; this.IsContainer = this.Class == ItemClass.Container || this.Class == ItemClass.Quiver; this.IsStackable = this.MaxAmount > 1 && this.RandomSuffixId == 0U && this.RandomPropertiesId == 0U; this.IsTwoHandWeapon = this.InventorySlotType == InventorySlotType.TwoHandWeapon; this.SetIsWeapon(); if (this.ToolCategory != ToolCategory.None) { ItemMgr.FirstTotemsPerCat[(uint)this.ToolCategory] = this; } if (this.GemPropertiesId != 0U) { this.GemProperties = EnchantMgr.GetGemproperties(this.GemPropertiesId); if (this.GemProperties != null) { this.GemProperties.Enchantment.GemTemplate = this; } } if (this.Sockets == null) { this.Sockets = new SocketInfo[3]; } else if (((IEnumerable <SocketInfo>) this.Sockets).Contains <SocketInfo>( (Func <SocketInfo, bool>)(sock => sock.Color != SocketColor.None))) { this.HasSockets = true; } if (this.Damages == null) { this.Damages = DamageInfo.EmptyArray; } if (this.Resistances == null) { this.Resistances = new int[7]; } if (this.SocketBonusEnchantId != 0U) { this.SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(this.SocketBonusEnchantId); } switch (this.Class) { case ItemClass.Weapon: this.ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get <SkillId>((uint)this.SubClass); break; case ItemClass.Armor: this.ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get <SkillId>((uint)this.SubClass); break; } int sheathType = (int)this.SheathType; if (this.Spells != null) { ArrayUtil.Prune <ItemSpell>(ref this.Spells); for (int index = 0; index < 5; ++index) { this.Spells[index].Index = (uint)index; this.Spells[index].FinalizeAfterLoad(); } } else { this.Spells = ItemSpell.EmptyArray; } this.UseSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>( (Func <ItemSpell, bool>)(itemSpell => { if (itemSpell.Trigger == ItemSpellTrigger.Use) { return(itemSpell.Spell != null); } return(false); })).FirstOrDefault <ItemSpell>(); if (this.UseSpell != null) { this.UseSpell.Spell.RequiredTargetType = this.RequiredTargetType; this.UseSpell.Spell.RequiredTargetId = this.RequiredTargetId; } this.EquipSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.Equip) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>(); this.SoulstoneSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>( (Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.Soulstone) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)) .FirstOrDefault <Spell>(); this.HitSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.ChanceOnHit) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>(); this.ConsumesAmount = (this.Class == ItemClass.Consumable || ((IEnumerable <ItemSpell>) this.Spells).Contains <ItemSpell>( (Func <ItemSpell, bool>)(spell => spell.Trigger == ItemSpellTrigger.Consume))) && (this.UseSpell == null || !this.UseSpell.HasCharges); this.IsHearthStone = this.UseSpell != null && this.UseSpell.Spell.IsHearthStoneSpell; this.IsInventory = this.InventorySlotType != InventorySlotType.None && this.InventorySlotType != InventorySlotType.Bag && this.InventorySlotType != InventorySlotType.Quiver && this.InventorySlotType != InventorySlotType.Relic; if (this.SetId != ItemSetId.None) { ItemSet itemSet = ItemMgr.Sets.Get <ItemSet>((uint)this.SetId); if (itemSet != null) { int num = (int)ArrayUtil.Add <ItemTemplate>(ref itemSet.Templates, this); } } if (this.Mods != null) { ArrayUtil.TruncVals <StatModifier>(ref this.Mods); } else { this.Mods = StatModifier.EmptyArray; } this.IsCharter = this.Flags.HasFlag((Enum)ItemFlags.Charter); this.RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (this.IsCharter) { this.Creator = (Func <Item>)(() => (Item) new PetitionCharter()); } else if (this.IsContainer) { this.Creator = (Func <Item>)(() => (Item) new Container()); } else { this.Creator = (Func <Item>)(() => new Item()); } }
public Item AddUnchecked(int slot, Asda2ItemId id, int amount, bool isNew) { ItemTemplate template = ItemMgr.GetTemplate(id); return(this.AddUnchecked(slot, template, amount, isNew)); }
internal static void EnsureItemQuestRelations() { foreach (QuestTemplate template1 in QuestMgr.Templates) { if (template1 != null && template1.CollectableItems != null) { foreach (Asda2ItemStackDescription collectableItem in template1.CollectableItems) { ItemTemplate template2 = ItemMgr.GetTemplate(collectableItem.ItemId); if (template2 == null) { ContentMgr.OnInvalidDBData("QuestTemplate \"{0}\" refered to non-existing Item: {1}", (object)template1, (object)collectableItem); } else if (template2.CollectQuests == null) { template2.CollectQuests = new QuestTemplate[1] { template1 }; } else { int num = (int)ArrayUtil.AddOnlyOne <QuestTemplate>(ref template2.CollectQuests, template1); } } foreach (Asda2ItemStackDescription collectableSourceItem in template1.CollectableSourceItems) { ItemTemplate template2 = ItemMgr.GetTemplate(collectableSourceItem.ItemId); if (template2 == null) { ContentMgr.OnInvalidDBData("QuestTemplate \"{0}\" refered to non-existing Item: {1}", (object)template1, (object)collectableSourceItem); } else if (template2.CollectQuests == null) { template2.CollectQuests = new QuestTemplate[1] { template1 }; } else { int num = (int)ArrayUtil.AddOnlyOne <QuestTemplate>(ref template2.CollectQuests, template1); } } } } foreach (ItemTemplate template1 in ItemMgr.Templates) { if (template1 != null && template1.QuestId != 0U) { QuestTemplate template2 = QuestMgr.GetTemplate(template1.QuestId); if (template2 == null) { ContentMgr.OnInvalidDBData("Item {0} had invalid QuestId: {1}", (object)template1, (object)template1.QuestId); } else { template2.Starters.Add((IQuestHolderEntry)template1); } } } }