예제 #1
0
        public ClothingItem(DB db, long id, long key)
        {
            this.key = key;
            this.id  = id;
            try
            {
                CObject gearDef = db.toObj(id, key);
                if (id == 7629)
                {
                    this.name = gearDef.getMember(0).convert() + "";
                    if (gearDef.hasMember(1))
                    {
                        this.langKey = gearDef.getMember(1).getIntMember(0);
                    }
                    if (gearDef.hasMember(4))
                    {
                        icon = db.toObj(6009, gearDef.getIntMember(4)).getStringMember(1);
                    }
                    if (gearDef.hasMember(5))
                    {
                        CObject allowedSlotsArray = gearDef.getMember(5);
                        foreach (CObject o in allowedSlotsArray.members)
                        {
                            int slot = int.Parse(o.convert() + "");
                            allowedSlots.Add(WardrobeStuff.getSlot(slot));
                        }
                    }


                    if (gearDef.hasMember(6))
                    {
                        type = WardrobeStuff.getGearType(gearDef.getIntMember(6));
                    }
                    if (gearDef.hasMember(7))
                    {
                        hidden = gearDef.getBoolMember(7, false);
                    }
                    nifKey = gearDef.getIntMember(2);
                    nifRef = new NIFReference(db, nifKey);
                }
                else if (id == 7305)
                {
                    nifRef = new NIFReference(db, key);
                    nifKey = key;


                    if (gearDef.hasMember(2))
                    {
                        string nifPath = gearDef.getMember(2).convert() + "";
                        this.name = System.IO.Path.GetFileName(nifPath);
                        if (nifPath.Contains(@"\player\") && nifPath.Contains(@"\wings\"))
                        {
                            allowedSlots.Add(GearSlot.CAPE);
                        }
                    }

                    if (gearDef.hasMember(15))
                    {
                        CObject allowedSlotsArray = gearDef.getMember(15);
                        foreach (CObject o in allowedSlotsArray.members)
                        {
                            int slot = int.Parse(o.convert() + "");
                            allowedSlots.Add(WardrobeStuff.getSlot(slot));
                        }
                    }
                    else
                    {
                    }
                }
                else
                {
                    throw new Exception("Bad id:" + id);
                }
            }
            catch (Exception ex)
            {
                Debug.Log("Unable to process [" + this + "] nif reference:" + ex);
            }
        }