Ejemplo n.º 1
0
            public static RawItemRoot Read(Stream input, Endian endian)
            {
                var instance = new RawItemRoot();

                instance.ItemOffset = input.ReadValueS64(endian);
                instance.ItemCount  = input.ReadValueS64(endian);
                return(instance);
            }
Ejemplo n.º 2
0
 public static void Write(Stream output, RawItemRoot instance, Endian endian)
 {
     output.WriteValueS64(instance.ItemOffset, endian);
     output.WriteValueS64(instance.ItemCount, endian);
 }
Ejemplo n.º 3
0
        public void Deserialize(Stream input, Endian endian)
        {
            var basePosition = input.Position;

            var rawItemRoot = RawItemRoot.Read(input, endian);

            var items = new Item[rawItemRoot.ItemCount];

            if (rawItemRoot.ItemCount != 0)
            {
                if (rawItemRoot.ItemCount < 0 || rawItemRoot.ItemCount > int.MaxValue)
                {
                    throw new FormatException();
                }

                var rawItems = new RawItem[rawItemRoot.ItemCount];
                input.Position = basePosition + rawItemRoot.ItemOffset;
                for (long i = 0; i < rawItemRoot.ItemCount; i++)
                {
                    rawItems[i] = RawItem.Read(input, endian);
                }

                for (long i = 0; i < rawItemRoot.ItemCount; i++)
                {
                    var rawItem = rawItems[i];
                    var item    = new Item()
                    {
                        Name              = rawItem.Name,
                        BaseName          = rawItem.BaseName,
                        Type              = rawItem.Type,
                        Purchasable       = rawItem.Purchasable,
                        Consumable        = rawItem.Consumable,
                        Rewardable        = rawItem.Rewardable,
                        Collectable       = rawItem.Collectable,
                        Feats             = new uint[rawItem.FeatCount],
                        Region            = rawItem.Region,
                        RebelDropTimer    = rawItem.RebelDropTimer,
                        MaxInventory      = rawItem.MaxInventory,
                        UIType            = rawItem.UIType,
                        UIFlag            = rawItem.UIFlag,
                        UIDisplayOrder    = rawItem.UIDisplayOrder,
                        UIName            = rawItem.UIName,
                        UIDescription     = rawItem.UIDescription,
                        UITypeDescription = rawItem.UITypeDescription,
                        UIFlagDescription = rawItem.UIFlagDescription,
                        UIPar0            = rawItem.UIPar0,
                        UIPar1            = rawItem.UIPar1,
                        UIPar2            = rawItem.UIPar2,
                        UIPar3            = rawItem.UIPar3,
                        UIPar4            = rawItem.UIPar4,
                    };

                    if (rawItem.FeatCount != 0)
                    {
                        if (rawItem.FeatCount < 0 || rawItem.FeatCount > int.MaxValue)
                        {
                            throw new FormatException();
                        }

                        input.Position = basePosition + rawItem.FeatOffset;
                        for (long j = 0; j < rawItem.FeatCount; j++)
                        {
                            item.Feats[j] = input.ReadValueU32(endian);
                        }
                    }

                    if (rawItem.UIImagePathOffset != 0)
                    {
                        input.Position   = basePosition + rawItem.UIImagePathOffset;
                        item.UIImagePath = input.ReadStringZ(Encoding.ASCII);
                    }

                    if (rawItem.UIVideoPathOffset != 0)
                    {
                        input.Position   = basePosition + rawItem.UIImagePathOffset;
                        item.UIVideoPath = input.ReadStringZ(Encoding.ASCII);
                    }

                    items[i] = item;
                }
            }

            this._Items.Clear();
            this._Items.AddRange(items);
        }