Exemple #1
0
        public VariableHeader ReadNextRecordVariableMeta(IBinaryReadStream stream)
        {
            RecordType rec = new RecordType(stream.GetInt32());

            if (rec == Mutagen.Bethesda.Internals.Constants.Group)
            {
                return(this.GroupConstants.VariableMeta(stream.ReadSpan(this.GroupConstants.HeaderLength)));
            }
            else
            {
                return(this.MajorConstants.VariableMeta(stream.ReadSpan(this.MajorConstants.HeaderLength)));
            }
        }
Exemple #2
0
        public SubrecordFrame ReadSubrecordFrame(IBinaryReadStream stream, RecordType targetType)
        {
            var meta = GetSubrecord(stream);

            if (meta.RecordType != targetType)
            {
                throw new ArgumentException($"Unexpected header type: {meta.RecordType}");
            }
            return(new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength)));
        }
Exemple #3
0
 public bool TryReadSubrecordFrame(IBinaryReadStream stream, RecordType targetType, out SubrecordFrame frame)
 {
     if (!TryGetSubrecord(stream, targetType, out var meta))
     {
         frame = default;
         return(false);
     }
     frame = new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength));
     return(true);
 }
Exemple #4
0
 public bool TryReadMod(IBinaryReadStream stream, out ModHeader header)
 {
     if (stream.Remaining < this.ModHeaderLength)
     {
         header = default;
         return(false);
     }
     header = new ModHeader(this, stream.ReadSpan(this.ModHeaderLength));
     return(true);
 }
Exemple #5
0
 public bool TryReadGroupFrame(IBinaryReadStream stream, out GroupFrame frame, bool checkIsGroup = true)
 {
     if (!TryGetGroup(stream, out var meta, checkIsGroup: checkIsGroup))
     {
         frame = default;
         return(false);
     }
     frame = new GroupFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength)));
     return(true);
 }
Exemple #6
0
        /// <summary>
        /// Reads a color from the binary stream.
        /// The stream will be advanced 4 bytes (or 3 if only 3 remain).
        /// If the stream has more than 3 bytes, the 4th byte will be interpreted as alpha.
        /// Will throw an exception if there is not at least 3 bytes remaining.
        /// </summary>
        /// <param name="stream">Stream to read from</param>
        /// <param name="binaryType">Format to read the color as</param>
        /// <returns>Bytes converted to a Color object</returns>
        public static Color ReadColor(this IBinaryReadStream stream, ColorBinaryType binaryType)
        {
            switch (binaryType)
            {
            case ColorBinaryType.NoAlpha:
                return(ReadColor(stream.ReadSpan(3), binaryType));

            case ColorBinaryType.Alpha:
                return(ReadColor(stream.ReadSpan(4), binaryType));

            case ColorBinaryType.NoAlphaFloat:
                return(ReadColor(stream.ReadSpan(12), binaryType));

            case ColorBinaryType.AlphaFloat:
                return(ReadColor(stream.ReadSpan(16), binaryType));

            default:
                throw new NotImplementedException();
            }
        }
Exemple #7
0
        public SubrecordFrame ReadSubrecordFrame(IBinaryReadStream stream)
        {
            var meta = GetSubrecord(stream);

            return(new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength)));
        }
Exemple #8
0
 public SubrecordHeader ReadSubrecord(IBinaryReadStream stream) => new SubrecordHeader(this, stream.ReadSpan(this.SubConstants.HeaderLength));
Exemple #9
0
        public MajorRecordFrame ReadMajorRecordFrame(IBinaryReadStream stream)
        {
            var meta = GetMajorRecord(stream);

            return(new MajorRecordFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength))));
        }
Exemple #10
0
 public MajorRecordHeader ReadMajorRecord(IBinaryReadStream stream) => new MajorRecordHeader(this, stream.ReadSpan(this.MajorConstants.HeaderLength));
Exemple #11
0
        public GroupFrame ReadGroupFrame(IBinaryReadStream stream)
        {
            var meta = GetGroup(stream);

            return(new GroupFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength))));
        }
Exemple #12
0
 public GroupHeader ReadGroup(IBinaryReadStream stream, int offset = 0) => new GroupHeader(this, stream.ReadSpan(this.GroupConstants.HeaderLength, offset));
Exemple #13
0
 public ModHeader ReadMod(IBinaryReadStream stream) => new ModHeader(this, stream.ReadSpan(this.ModHeaderLength));
Exemple #14
0
 public VariableHeader ReadVariableMeta(IBinaryReadStream stream) => new VariableHeader(this, stream.ReadSpan(this.HeaderLength));