Пример #1
0
        /// <summary>
        /// Disassembles byte array into <see cref="CPStruct"/> using <see cref="BinaryReader"/>
        /// provided.
        /// </summary>
        /// <param name="br"><see cref="BinaryReader"/> to read with.</param>
        /// <param name="str_reader"><see cref="BinaryReader"/> to read strings with.</param>
        public override void Disassemble(BinaryReader br, BinaryReader str_reader)
        {
            const uint negative = 0xFFFFFFFF;

            this.Templated = br.ReadInt16() == 0 ? eBoolean.False : eBoolean.True;

            if (this.Templated == eBoolean.True)
            {
                // Read concatenator
                long position = br.ReadUInt16();

                if (position != 0xFFFF)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.Concatenator       = str_reader.ReadNullTermUTF8();
                    this.ConcatenatorExists = eBoolean.True;
                }

                // Read geometry lod A, if valid
                position = br.ReadUInt32();

                if (position != negative)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.GeometryLodA       = str_reader.ReadNullTermUTF8();
                    this.GeometryLodAExists = eBoolean.True;
                }

                // Read geometry lod B, if valid
                position = br.ReadUInt32();

                if (position != negative)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.GeometryLodB       = str_reader.ReadNullTermUTF8();
                    this.GeometryLodBExists = eBoolean.True;
                }

                // Read geometry lod C, if valid
                position = br.ReadUInt32();

                if (position != negative)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.GeometryLodC       = str_reader.ReadNullTermUTF8();
                    this.GeometryLodCExists = eBoolean.True;
                }

                // Read geometry lod D, if valid
                position = br.ReadUInt32();

                if (position != negative)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.GeometryLodD       = str_reader.ReadNullTermUTF8();
                    this.GeometryLodDExists = eBoolean.True;
                }

                // Read geometry lod E, if valid
                position = br.ReadUInt32();

                if (position != negative)
                {
                    str_reader.BaseStream.Position = position << 2;
                    this.GeometryLodE       = str_reader.ReadNullTermUTF8();
                    this.GeometryLodEExists = eBoolean.True;
                }
            }
            else
            {
                uint key = br.ReadUInt16();                 // skip concatenator

                // Read geometry lod A, if valid
                key = br.ReadUInt32();

                if (key != negative)
                {
                    this.GeometryLodA       = key.BinString(LookupReturn.EMPTY);
                    this.GeometryLodAExists = eBoolean.True;
                }

                // Read geometry lod B, if valid
                key = br.ReadUInt32();

                if (key != negative)
                {
                    this.GeometryLodB       = key.BinString(LookupReturn.EMPTY);
                    this.GeometryLodBExists = eBoolean.True;
                }

                // Read geometry lod C, if valid
                key = br.ReadUInt32();

                if (key != negative)
                {
                    this.GeometryLodC       = key.BinString(LookupReturn.EMPTY);
                    this.GeometryLodCExists = eBoolean.True;
                }

                // Read geometry lod D, if valid
                key = br.ReadUInt32();

                if (key != negative)
                {
                    this.GeometryLodD       = key.BinString(LookupReturn.EMPTY);
                    this.GeometryLodDExists = eBoolean.True;
                }

                // Read geometry lod E, if valid
                key = br.ReadUInt32();

                if (key != negative)
                {
                    this.GeometryLodE       = key.BinString(LookupReturn.EMPTY);
                    this.GeometryLodEExists = eBoolean.True;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Constructor for <see cref="CustomCP"/>.
 /// </summary>
 /// <param name="key">Key of this <see cref="CustomCP"/>.</param>
 public CustomCP(uint key)
 {
     this.Key        = key;
     this.Name       = key.BinString(LookupReturn.EMPTY);
     this.AttribType = CarPartAttribType.Integer;
 }