Ejemplo n.º 1
0
        /// <summary>
        ///     Add new item into items_730.bin
        /// </summary>
        /// <param name="itemType" type="KvFileReader.ItemInfo">
        ///     <para>
        ///         Type of item to be added
        ///     </para>
        /// </param>
        /// <param name="quality" type="KvFileReader.QualityInfo">
        ///     <para>
        ///         Quality of the item
        ///     </para>
        /// </param>
        /// <param name="rarity" type="KvFileReader.RarityInfo">
        ///     <para>
        ///         Rarity of the item
        ///     </para>
        /// </param>
        /// <param name="level" type="int">
        ///     <para>
        ///         Level of the item
        ///     </para>
        /// </param>
        /// <param name="attributeAndValue" type="System.Collections.Generic.Dictionary<KvFileReader.AttributeInfo,dynamic>">
        ///     <para>
        ///         Dictionary of item's attributes and their values
        ///     </para>
        /// </param>
        internal void AddNewItem(int codedValueItemType, int codedValueQuality,
            int codedValueRarity, int level, string customName, Dictionary<AttributeInfo, CSOEconItemAttribute> attributeAndValue)
        {
            CSGOItemProto econItem = new CSGOItemProto();

            //NOTE: must be filled with 0 as SSE will fill it later
            econItem.id = 0;
            econItem.inventory = 0;
            econItem.flags = 0;
            econItem.origin = 0;

            econItem.custom_name = customName;
            econItem.def_index = codedValueItemType;
            econItem.level = level;
            econItem.rarity = codedValueRarity;
            econItem.quality = codedValueQuality;

            foreach (var attrib in attributeAndValue)
            {
                econItem.attribute.Add(attrib.Value);
            }

            ItemData dataHeader = new ItemData();

            dataHeader.Type = 1;
            dataHeader.Length = CalcProtoBufSize(econItem);

            _itemList.Add(new Tuple<ItemData, CSGOItemProto>(dataHeader, econItem));
        }
Ejemplo n.º 2
0
        internal void AddNewItem(CSGOItemProto itemProto, Dictionary<AttributeInfo, CSOEconItemAttribute> attributeAndValue)
        {
            CSGOItemProto econItem = new CSGOItemProto();

            econItem = itemProto;

            foreach (var attrib in attributeAndValue)
            {
                econItem.attribute.Add(attrib.Value);
            }

            ItemData dataHeader = new ItemData();

            dataHeader.Type = 1;
            dataHeader.Length = CalcProtoBufSize(econItem);

            _itemList.Add(new Tuple<ItemData, CSGOItemProto>(dataHeader, econItem));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Read stream of items_730.bin from Items730 stream into DataHeaderList and ItemCsgoList
        ///     To be used after calling VerifyHeader()
        /// </summary>
        internal List<CSGOItemProto> ReadItemHeaderAndData()
        {
            List<CSGOItemProto> returnValue = new List<CSGOItemProto>();
            BinaryReader reader;
            int itemCount = this.GetItemCount();
            ItemData dataHeader;
            CSGOItemProto csgoItem;

            for (int i = 0; i < itemCount; i++)
            {
                dataHeader = (ItemData)BinaryFileHelper.Read(_stream, typeof(ItemData));

                if (this.IsDataHeaderValid(dataHeader))
                {
                    DataHeaderList.Add(dataHeader);

                    csgoItem = new CSGOItemProto();

                    byte[] bufferByte = new byte[dataHeader.Length];

                    reader = new BinaryReader(_stream);

                    int byteToRead = Convert.ToInt32(dataHeader.Length);
                    int startingPosition = Convert.ToInt32(_stream.Position);

                    reader.Read(bufferByte, 0, byteToRead);

                    MemoryStream tempMemStream = new MemoryStream(bufferByte);

                    csgoItem = Serializer.Deserialize<CSGOItemProto>(tempMemStream);
                    returnValue.Add(csgoItem);
                }
            }

            return returnValue;
        }