Esempio n. 1
0
            partial void DataLogicCustomParse(OverlayStream stream, int offset)
            {
                var subHeader     = stream.ReadSubrecord();
                var contentLength = subHeader.ContentLength;

                _dataSpan        = _data.Slice(stream.Position - offset, contentLength);
                stream.Position += contentLength;
            }
Esempio n. 2
0
 partial void AnimationsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed)
 {
     var subHeader = stream.ReadSubrecord();
     Animations = BinaryOverlayList.FactoryByStartIndex<IFormLinkGetter<IIdleAnimationGetter>>(
         mem: stream.RemainingMemory.Slice(0, subHeader.ContentLength),
         package: _package,
         itemLength: 4,
         getter: (s, p) => new FormLink<IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences!, BinaryPrimitives.ReadUInt32LittleEndian(s))));
 }
Esempio n. 3
0
            partial void VestigialCustomParse(OverlayStream stream, int offset)
            {
                var subMeta = stream.ReadSubrecord();

                if (subMeta.ContentLength != 1)
                {
                    throw new ArgumentException($"Unexpected length: {subMeta.ContentLength}");
                }
                if (stream.ReadUInt8() > 0)
                {
                    this._vestigialMarker = true;
                }
            }
Esempio n. 4
0
            partial void IDParseCustomParse(OverlayStream stream, int offset)
            {
                var subMeta = stream.ReadSubrecord();

                this.Type = subMeta.RecordTypeInt switch
                {
                    // ALST
                    0x54534C41 => QuestAlias.TypeEnum.Reference,
                    // ALLS
                    0x534C4C41 => QuestAlias.TypeEnum.Location,
                    _ => throw new NotImplementedException(),
                };
                this.ID = stream.ReadUInt32();
            }
Esempio n. 5
0
            partial void LengthLogicCustomParse(OverlayStream stream, int offset)
            {
                var xxxxHeader = stream.ReadSubrecordFrame();

                if (xxxxHeader.Content.Length != 4)
                {
                    throw new ArgumentException("Unexpected length");
                }
                var len = checked ((int)BinaryPrimitives.ReadUInt32LittleEndian(xxxxHeader.Content));

                stream.ReadSubrecord();
                _dataSpan        = _data.Slice(stream.Position - offset, len);
                stream.Position += checked ((int)len);
            }
Esempio n. 6
0
            public partial ParseResult IDParseCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed)
            {
                var subMeta = stream.ReadSubrecord();

                this.Type = subMeta.RecordTypeInt switch
                {
                    // ALST
                    0x54534C41 => QuestAlias.TypeEnum.Reference,
                    // ALLS
                    0x534C4C41 => QuestAlias.TypeEnum.Location,
                    _ => throw new NotImplementedException(),
                };
                this.ID = stream.ReadUInt32();
                return(lastParsed);
            }
Esempio n. 7
0
            public static IBodyTemplateGetter?CustomFactory(OverlayStream stream, BinaryOverlayFactoryPackage package)
            {
                var subFrame = stream.ReadSubrecord();
                var version  = package.FormVersion !.FormVersion !.Value;

                switch (subFrame.RecordTypeInt)
                {
                case RecordTypeInts.BODT:
                    return(BodyTemplateBinaryCreateTranslation.ParseBodt(version, stream, subFrame));

                case RecordTypeInts.BOD2:
                    return(BodyTemplateBinaryCreateTranslation.ParseBod2(version, stream, subFrame));

                default:
                    throw new ArgumentException();
                }
            }
Esempio n. 8
0
            partial void AnimationsCustomParse(
                OverlayStream stream,
                long finalPos,
                int offset,
                RecordType type,
                PreviousParse lastParsed)
            {
                byte?count = null;

                for (int i = 0; i < 3; i++)
                {
                    var subRecord = stream.GetSubrecordFrame();
                    if (subRecord.RecordType == RecordTypes.IDLC)
                    {
                        // Counter start
                        if (subRecord.Content.Length != 1)
                        {
                            throw new ArgumentException("Unexpected counter length");
                        }
                        count            = subRecord.Content[0];
                        stream.Position += subRecord.TotalLength;
                    }
                    else if (subRecord.RecordType == RecordTypes.IDLA)
                    {
                        if (count == null)
                        {
                            this.Animations = BinaryOverlayList.FactoryByArray <IFormLinkGetter <IIdleAnimationGetter> >(
                                mem: stream.RemainingMemory,
                                package: _package,
                                getter: (s, p) => new FormLink <IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(s))),
                                locs: ParseRecordLocations(
                                    stream: stream,
                                    constants: _package.MetaData.Constants.SubConstants,
                                    trigger: type,
                                    skipHeader: true));
                        }
                        else
                        {
                            var subMeta = stream.ReadSubrecord();
                            var subLen  = subMeta.ContentLength;
                            this.Animations = BinaryOverlayList.FactoryByStartIndex <IFormLinkGetter <IIdleAnimationGetter> >(
                                mem: stream.RemainingMemory.Slice(0, subLen),
                                package: _package,
                                itemLength: 4,
                                getter: (s, p) => new FormLink <IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(s))));
                            stream.Position += subLen;
                        }
                    }
                    else if (subRecord.RecordType == RecordTypes.IDLT)
                    {
                        _timerSetting    = subRecord.Content.Float();
                        stream.Position += subRecord.TotalLength;
                    }
                    else
                    {
                        break;
                    }
                }
                if (count.HasValue && count.Value != Animations.Count)
                {
                    throw new ArgumentException("Idle animation counts did not match.");
                }
            }