Esempio n. 1
0
            partial void CustomEnd(OverlayStream stream, int finalPos, int offset)
            {
                if (stream.Complete)
                {
                    return;
                }
                var startPos = stream.Position;

                if (!stream.TryGetGroup(out var groupMeta))
                {
                    return;
                }
                if (groupMeta.GroupType != (int)GroupTypeEnum.TopicChildren)
                {
                    return;
                }
                this._grupData = stream.ReadMemory(checked ((int)groupMeta.TotalLength));
                var formKey = FormKey.Factory(_package.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeData));

                if (formKey != this.FormKey)
                {
                    throw new ArgumentException("Dialog children group did not match the FormID of the parent.");
                }
                var contentSpan = this._grupData.Value.Slice(_package.MetaData.Constants.GroupConstants.HeaderLength);

                this.Items = BinaryOverlayList.FactoryByArray <IDialogItemGetter>(
                    contentSpan,
                    _package,
                    getter: (s, p) => DialogItemBinaryOverlay.DialogItemFactory(new OverlayStream(s, p), p),
                    locs: ParseRecordLocations(
                        stream: new OverlayStream(contentSpan, _package),
                        trigger: DialogItem_Registration.TriggeringRecordType,
                        constants: GameConstants.Oblivion.MajorConstants,
                        skipHeader: false));
            }
Esempio n. 2
0
            public partial ParseResult CountCustomParse(OverlayStream stream, int offset)
            {
                int[] counts = FootstepSetBinaryCreateTranslation.GetListCounts(stream);

                IReadOnlyList <IFormLinkGetter <IFootstepGetter> > Get(int index)
                {
                    var ret = BinaryOverlayList.FactoryByCount <IFormLinkGetter <IFootstepGetter> >(
                        _data.Slice(stream.Position - offset, 4 * counts[index]),
                        _package,
                        itemLength: 4,
                        count: checked ((uint)counts[index]),
                        getter: (s, p) => new FormLink <IFootstepGetter>(FormKeyBinaryTranslation.Instance.Parse(s, p.MetaData.MasterReferences !)));

                    stream.Position += 4 * counts[index];
                    return(ret);
                }

                WalkForwardFootsteps           = Get(0);
                RunForwardFootsteps            = Get(1);
                WalkForwardAlternateFootsteps  = Get(2);
                RunForwardAlternateFootsteps   = Get(3);
                WalkForwardAlternateFootsteps2 = Get(4);

                return(null);
            }
Esempio n. 3
0
        partial void PointsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed)
        {
            if (stream.Complete)
            {
                return;
            }
            var subMeta = stream.GetSubrecord();

            if (subMeta.RecordType != RecordTypes.PGRP)
            {
                return;
            }
            stream.Position += subMeta.HeaderLength;
            var pointBytes = stream.ReadMemory(subMeta.ContentLength);

            subMeta = stream.GetSubrecord();
            switch (subMeta.RecordTypeInt)
            {
            case 0x52524750:     // "PGRR":
                stream.Position += subMeta.HeaderLength;
                var connBytes = stream.ReadMemory(subMeta.ContentLength);
                this.Points = BinaryOverlayList.FactoryByLazyParse <IRoadPointGetter>(
                    pointBytes,
                    _package,
                    getter: (s, p) =>
                {
                    int numPts         = pointBytes.Length / RoadBinaryCreateTranslation.POINT_LEN;
                    RoadPoint[] points = new RoadPoint[numPts];
                    var connFloats     = connBytes.Span.AsFloatSpan();
                    for (int i = 0; i < numPts; i++)
                    {
                        var pt          = RoadBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn);
                        s               = s.Slice(RoadBinaryCreateTranslation.POINT_LEN);
                        P3Float[] conns = new P3Float[numConn];
                        for (int j = 0; j < numConn; j++)
                        {
                            conns[j] = new P3Float(
                                x: connFloats[0],
                                y: connFloats[1],
                                z: connFloats[2]);
                            connFloats = connFloats.Slice(3);
                        }
                        pt.Connections.AddRange(conns);
                        points[i] = pt;
                    }
                    return(points);
                });
                break;

            default:
                this.Points = BinaryOverlayList.FactoryByStartIndex <IRoadPointGetter>(
                    pointBytes,
                    _package,
                    itemLength: RoadBinaryCreateTranslation.POINT_LEN,
                    getter: (s, p) => RoadBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn));
                break;
            }
        }
Esempio n. 4
0
 partial void CustomFactoryEnd(OverlayStream stream, int finalPos, int offset)
 {
     stream.Position = FileNameEndingPos;
     Fragments       = BinaryOverlayList.FactoryByCount <IIndexedScriptFragmentGetter>(
         stream,
         _package,
         stream.ReadUInt16(),
         (s, p) => IndexedScriptFragmentBinaryOverlay.IndexedScriptFragmentFactory(s, p));
 }
Esempio n. 5
0
 partial void ItemsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, int?lastParsed)
 {
     this.Items = BinaryOverlayList.FactoryByArray <CellBinaryOverlay>(
         mem: stream.RemainingMemory,
         package: _package,
         recordTypeConverter: null,
         getter: (s, p, recConv) => CellBinaryOverlay.CellFactory(new OverlayStream(s, p), p, insideWorldspace: true),
         locs: CellBinaryOverlay.ParseRecordLocations(
             stream: stream,
             package: _package));
 }
Esempio n. 6
0
 partial void CellsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed)
 {
     this.Cells = BinaryOverlayList.FactoryByArray <CellBinaryOverlay>(
         mem: stream.RemainingMemory,
         package: _package,
         parseParams: null,
         getter: (s, p, recConv) => CellBinaryOverlay.CellFactory(new OverlayStream(s, p), p, recConv),
         locs: CellBinaryOverlay.ParseRecordLocations(
             stream: stream,
             package: _package));
 }
Esempio n. 7
0
            public static IReadOnlyList <ConditionBinaryOverlay> ConstructBinayOverlayList(OverlayStream stream, BinaryOverlayFactoryPackage package)
            {
                var span       = stream.RemainingMemory;
                var pos        = stream.Position;
                var recordLocs = ParseRecordLocations(
                    stream: stream,
                    finalPos: long.MaxValue,
                    constants: package.MetaData.Constants.SubConstants,
                    trigger: RecordTypes.CTDA,
                    includeTriggers: IncludeTriggers,
                    skipHeader: false);

                span = span.Slice(0, stream.Position - pos);
                return(BinaryOverlayList.FactoryByArray <ConditionBinaryOverlay>(
                           mem: span,
                           package: package,
                           getter: (s, p) => ConditionBinaryOverlay.ConditionFactory(new OverlayStream(s, p), p),
                           locs: recordLocs));
            }
Esempio n. 8
0
            partial void CustomNavmeshSetsEndPos()
            {
                var count = BinaryPrimitives.ReadInt32LittleEndian(this._data);

                int[] locs = new int[count];
                var   span = this._data.Slice(4);
                int   loc  = 0;

                for (int i = 0; i < count; i++)
                {
                    var subCount = BinaryPrimitives.ReadInt32LittleEndian(span);
                    var len      = 4 + subCount * 4;
                    span    = span.Slice(len);
                    locs[i] = loc;
                    loc    += len;
                }
                this.NavmeshSets = BinaryOverlayList.FactoryByArray <INavmeshSetGetter>(
                    this._data.Slice(4),
                    this._package,
                    (s, p) => NavmeshSetBinaryOverlay.NavmeshSetFactory(s, p),
                    locs);
                this.NavmeshSetsEndingPos = 4 + loc;
            }
Esempio n. 9
0
        partial void PointToPointConnectionsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, int?lastParsed)
        {
            var  dataFrame = stream.ReadSubrecordFrame();
            uint ptCount   = BinaryPrimitives.ReadUInt16LittleEndian(dataFrame.Content);

            var pgrpMeta = stream.GetSubrecord();

            if (pgrpMeta.RecordType != PathGridBinaryCreateTranslation.PGRP)
            {
                return;
            }
            stream.Position += pgrpMeta.HeaderLength;
            var pointData     = stream.ReadMemory(pgrpMeta.ContentLength);
            var bytePointsNum = pgrpMeta.ContentLength / PathGridBinaryCreateTranslation.POINT_LEN;

            if (bytePointsNum != ptCount)
            {
                throw new ArgumentException($"Unexpected point byte length, when compared to expected point count. {pgrpMeta.ContentLength} bytes: {bytePointsNum} != {ptCount} points.");
            }

            bool readPGRR = false;

            for (int recAttempt = 0; recAttempt < 2; recAttempt++)
            {
                if (stream.Complete)
                {
                    break;
                }
                var subMeta = stream.GetSubrecord();
                switch (subMeta.RecordType.TypeInt)
                {
                case 0x47414750:     //"PGAG":
                    this._PGAGLocation = stream.Position - offset;
                    stream.Position   += subMeta.TotalLength;
                    break;

                case 0x52524750:     // "PGRR":
                    stream.Position += subMeta.HeaderLength;
                    var connectionPtData = stream.ReadMemory(subMeta.ContentLength);
                    this.PointToPointConnections = BinaryOverlayList.FactoryByLazyParse <IPathGridPointGetter>(
                        pointData,
                        _package,
                        getter: (s, p) =>
                    {
                        var connectionInts = connectionPtData.Span.AsInt16Span();
                        IPathGridPointGetter[] pathGridPoints = new IPathGridPointGetter[bytePointsNum];
                        for (int i = 0; i < bytePointsNum; i++)
                        {
                            var pt = PathGridPointBinaryOverlay.Factory(s, p);
                            pt.Connections.AddRange(connectionInts.Slice(0, pt.NumConnections).ToArray());
                            pathGridPoints[i] = pt;
                            s = s.Slice(16);
                            connectionInts = connectionInts.Slice(pt.NumConnections);
                        }
                        return(pathGridPoints);
                    });
                    readPGRR = true;
                    break;

                default:
                    break;
                }
            }

            if (!readPGRR)
            {
                this.PointToPointConnections = BinaryOverlayList.FactoryByStartIndex <IPathGridPointGetter>(
                    pointData,
                    this._package,
                    itemLength: 16,
                    getter: (s, p) =>
                {
                    return(PathGridBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn));
                });
            }
        }