Ejemplo n.º 1
0
        public static Equipment Read(BinaryReader reader)
        {
            var result = new Equipment
            {
                SortIndex = reader.ReadUInt32(),
                Type      = (EquipmentType)reader.ReadUInt32()
            };

            if (result.Type == EquipmentType.None)
            {
                reader.BaseStream.Seek(15 * 4, SeekOrigin.Current);
                return(null);
            }

            uint value;

            value = reader.ReadUInt32();

            switch (result.Type)
            {
            case EquipmentType.Armor:
                result.ArmorPieceType = (ArmorPieceType)value;
                break;

            case EquipmentType.Weapon:
                result.WeaponType = (WeaponType)value;
                break;

            case EquipmentType.Charm:
                result.CharmId = value;
                break;

            case EquipmentType.Kinsect:
                result.KinsectId = value;
                break;
            }

            result.ClassId       = reader.ReadUInt32();
            result.UpgradeLevel  = reader.ReadUInt32();
            result.UpgradePoints = reader.ReadUInt32();

            result.DecorationSlots = new[]
            {
                (Decoration)reader.ReadUInt32(),
                (Decoration)reader.ReadUInt32(),
                (Decoration)reader.ReadUInt32()
            };

            if (result.Type == EquipmentType.Kinsect)
            {
                result.KinsectType = (KinsectType)reader.ReadUInt32();
                reader.BaseStream.Seek(2 * 4, SeekOrigin.Current); // skip BowgunMod2 and BowgunMod3
            }
            else if (result.Type == EquipmentType.Weapon && (result.WeaponType == WeaponType.LightBowgun || result.WeaponType == WeaponType.HeavyBowgun))
            {
                result.BowgunMods = new[]
                {
                    (BowGunMod)reader.ReadUInt32(),
                    (BowGunMod)reader.ReadUInt32(),
                    (BowGunMod)reader.ReadUInt32(),
                };
            }
            else
            {
                reader.BaseStream.Seek(3 * 4, SeekOrigin.Current);
            }

            result.Augmentations = new[]
            {
                (AugmentationType)reader.ReadUInt32(),
                (AugmentationType)reader.ReadUInt32(),
                (AugmentationType)reader.ReadUInt32(),
            };

            // skip 2 Unknown
            reader.BaseStream.Seek(2 * 4, SeekOrigin.Current);

            return(result);
        }