コード例 #1
0
        /// <summary>
        /// Processes the attribute offset table list chunk
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="reader"></param>
        public void ProcessAttributeOffsetTablesChunk(Chunk chunk, BinaryReader reader)
        {
            if (chunk.Size % 2 != 0)
            {
                throw new ChunkCorruptedException("Invalid CarPartPack attribute offset tables chunk!");
            }

            while (reader.BaseStream.Position < chunk.EndOffset)
            {
                var table = new AttributeOffsetTable
                {
                    Offset = (reader.BaseStream.Position - chunk.DataOffset) / 2
                };
                var numOffsets = reader.ReadUInt16();
                table.Offsets = new List <ushort>(numOffsets);

                for (var i = 0; i < numOffsets; i++)
                {
                    table.Offsets.Add(reader.ReadUInt16());
                }

                _attributeOffsetTables[table.Offset] = table;
            }

            Debug.WriteLine("Loaded {0} attribute offset tables", _attributeOffsetTables.Count);
        }
コード例 #2
0
        private SynchronizedObservableCollection <AaronCarPartAttribute> PrepareAttributes(DBCarPart dbCarPart)
        {
            SynchronizedObservableCollection <AaronCarPartAttribute> attributes = new SynchronizedObservableCollection <AaronCarPartAttribute>();
            AttributeOffsetTable attributeOffsetTable = _attributeOffsetTables[dbCarPart.AttributeTableOffset];

            foreach (var offset in attributeOffsetTable.Offsets)
            {
                var rawAttribute = _attributes[offset];
                AaronCarPartAttribute newAttribute = this.ConvertAttribute(rawAttribute);
                //AaronCarPartAttribute newAttribute = new AaronCarPartAttribute();
                //newAttribute.Name = HashResolver.Resolve(rawAttribute.NameHash);
                //newAttribute.Value = rawAttribute.iParam;


                //switch (newAttribute.Hash)
                //{
                //    case 0xB1027477:
                //    case 0x46B79643:
                //    case 0xFD35FE70:
                //    case 0x7D65A926:
                //        this.LoadSingleAttribString(newAttribute, rawAttribute);
                //        break;
                //    case 0xFE613B98:
                //        this.LoadDoubleAttribString(newAttribute, rawAttribute);
                //        break;
                //}

                attributes.Add(newAttribute);
            }

            return(attributes);
        }
コード例 #3
0
        private void LoadPartAttributes(CarPart carPart, DBCarPart carPartInfo)
        {
            AttributeOffsetTable attributeOffsetTable = _attributeOffsetTables[carPartInfo.AttributeTableOffset];

            foreach (var attributeOffset in attributeOffsetTable.Offsets)
            {
                var attribute = _preparedAttributes[attributeOffset];

                carPart.Attributes.Add(attribute);
            }
        }
コード例 #4
0
        private void ProcessAttributeOffsetTables(Chunk chunk)
        {
            Progress?.Report("Processing attribute offset tables");
            while (Stream.Position < chunk.EndOffset)
            {
                var table = new AttributeOffsetTable();
                table.Offset = (Stream.Position - (chunk.Offset + 8)) / 2;
                var numOffsets = Reader.ReadUInt16();
                table.Offsets = new List <ushort>(numOffsets);

                for (int i = 0; i < numOffsets; i++)
                {
                    table.Offsets.Add(Reader.ReadUInt16());
                }

                _attributeOffsetTables[table.Offset] = table;
            }
        }