Ejemplo n.º 1
0
        public MapleItem Search(int id, Func <int, int[]> getDroppedBy)
        {
            WZProperty stringWz = WZ.Resolve("String");

            string    idString = id.ToString();
            MapleItem result   = null;

            WZProperty item = (stringWz.Resolve("Eqp/Eqp") ?? stringWz.Resolve("Item/Eqp")).Children.FirstOrDefault(c => c.Children.Any(b => b.NameWithoutExtension.Equals(idString)))?.Resolve(idString);

            if (item != null)
            {
                result = Equip.Parse(item);
            }

            if (result == null)
            {
                item = (stringWz.Resolve("Etc/Etc") ?? stringWz.Resolve("Item/Etc"))?.Resolve(idString);
                if (item != null)
                {
                    result = Etc.Parse(item);
                }
            }

            if (result == null)
            {
                item = (stringWz.Resolve("Ins") ?? stringWz.Resolve("Item/Ins")).Resolve(idString);
                if (item != null)
                {
                    result = Install.Parse(item);
                }
            }

            if (result == null)
            {
                item = (stringWz.Resolve("Cash") ?? stringWz.Resolve("Item/Cash")).Resolve(idString);
                if (item != null)
                {
                    result = Cash.Parse(item);
                }
            }

            if (result == null)
            {
                item = (stringWz.Resolve("Consume") ?? stringWz.Resolve("Item/Con")).Resolve(idString);
                if (item != null)
                {
                    result = Consume.Parse(item);
                }
            }

            if (result == null)
            {
                item = (stringWz.Resolve("Pet") ?? stringWz.Resolve("Item/Pet")).Resolve(idString);
                if (item != null)
                {
                    result = Pet.Parse(item);
                }
            }

            MobFactory mobs = new MobFactory();

            mobs.CloneWZFrom(this);

            if (result != null && result.MetaInfo != null)
            {
                result.MetaInfo.DroppedBy = getDroppedBy(id)?.Join(mobs.GetMobs().Where(c => c != null), c => c, c => c.Id, (a, b) => b)?.ToArray();
            }

            return(result);
        }