示例#1
0
 static partial void FillBinaryScriptsCustom(MutagenFrame frame, IQuestFragmentAlias item)
 {
     item.Scripts.AddRange(AVirtualMachineAdapterBinaryCreateTranslation.ReadEntries(frame, item.ObjectFormat));
 }
示例#2
0
 static partial void FillBinaryLevelMultCustom(MutagenFrame frame, IPcLevelMult item)
 {
     throw new NotImplementedException();
 }
示例#3
0
 static partial void FillBinaryTimerSettingCustom(MutagenFrame frame, IPackageIdles item)
 {
     FillBinaryAnimationsCustom(frame, item);
 }
 public static M MajorRecordParse <M>(
     M record,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter,
     RecordStructFill <M> fillStructs,
     RecordTypeFill <M> fillTyped)
     where M : IMajorRecordCommonGetter
 {
     frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseRecord(frame.Reader));
     fillStructs(
         record: record,
         frame: frame);
     if (fillTyped == null)
     {
         return(record);
     }
     try
     {
         MutagenFrame targetFrame = frame;
         if (record.IsCompressed)
         {
             targetFrame = frame.Decompress();
         }
         Dictionary <RecordType, int>?recordParseCount = null;
         frame.MetaData.FormVersion = record.FormVersion;
         while (!targetFrame.Complete)
         {
             var         subMeta  = targetFrame.GetSubrecord();
             var         finalPos = targetFrame.Position + subMeta.TotalLength;
             ParseResult parsed;
             try
             {
                 parsed = fillTyped(
                     record: record,
                     frame: targetFrame,
                     recordParseCount: recordParseCount,
                     nextRecordType: subMeta.RecordType,
                     contentLength: subMeta.ContentLength,
                     recordTypeConverter: recordTypeConverter);
             }
             catch (Exception ex)
             {
                 throw new SubrecordException(
                           subMeta.RecordType,
                           record.FormKey,
                           majorRecordType: record.Registration.ClassType,
                           modKey: frame.Reader.MetaData.ModKey,
                           edid: record.EditorID,
                           innerException: ex);
             }
             if (!parsed.KeepParsing)
             {
                 break;
             }
             if (parsed.DuplicateParseMarker != null)
             {
                 if (recordParseCount == null)
                 {
                     recordParseCount = new Dictionary <RecordType, int>();
                 }
                 recordParseCount[parsed.DuplicateParseMarker !.Value] = recordParseCount.GetOrAdd(parsed.DuplicateParseMarker !.Value) + 1;
示例#5
0
 static partial void FillBinaryDataLogicCustom(MutagenFrame frame, IANavigationMeshInternal item)
 {
     HeaderTranslation.ReadNextSubrecordType(frame, out var len);
     frame = frame.SpawnWithLength(len);
     GetSetData(frame, item);
 }
示例#6
0
 public static partial void FillBinaryTypeCharCustom(
     MutagenFrame frame,
     IGlobalInternal item);
示例#7
0
 static partial void FillBinaryTopicsCustom(MutagenFrame frame, IPatrol item)
 {
     item.Topics.SetTo(ATopicReferenceBinaryCreateTranslation.Factory(frame));
 }
示例#8
0
 static partial void FillBinaryPointToPointConnectionsCustom(MutagenFrame frame, IPathGridInternal item)
 {
     FillBinaryPointToPointConnections(frame, item);
 }
示例#9
0
        public static void FillBinaryPointToPointConnections(MutagenFrame frame, IPathGridInternal item)
        {
            if (!frame.TryReadSubrecord(RecordTypes.DATA, out var subMeta))
            {
                return;
            }

            uint ptCount = frame.Reader.ReadUInt16();

            if (!frame.Reader.TryReadSubrecord(PGRP, out subMeta))
            {
                return;
            }
            var pointDataSpan = frame.Reader.ReadSpan(subMeta.ContentLength);
            var bytePointsNum = pointDataSpan.Length / POINT_LEN;

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

            bool readPGRR = false;

            for (int recAttempt = 0; recAttempt < 2; recAttempt++)
            {
                if (frame.Reader.Complete)
                {
                    break;
                }
                subMeta = frame.GetSubrecord();
                switch (subMeta.RecordType.TypeInt)
                {
                case 0x47414750:     //"PGAG":
                    frame.Reader.Position += subMeta.HeaderLength;
                    if (Mutagen.Bethesda.Binary.ByteArrayBinaryTranslation.Instance.Parse(
                            frame.SpawnWithLength(subMeta.ContentLength, checkFraming: false),
                            item: out var unknownBytes))
                    {
                        item.PGAG = unknownBytes;
                    }
                    else
                    {
                        item.PGAG = default;
                    }
                    break;

                case 0x52524750:     // "PGRR":
                    frame.Reader.Position += subMeta.HeaderLength;
                    var             connectionInts = frame.Reader.ReadSpan(subMeta.ContentLength).AsInt16Span();
                    int             numPts         = pointDataSpan.Length / POINT_LEN;
                    PathGridPoint[] pathGridPoints = new PathGridPoint[numPts];
                    for (int i = 0; i < numPts; i++)
                    {
                        var pt = ReadPathGridPoint(pointDataSpan, out var numConn);
                        pt.Connections.AddRange(connectionInts.Slice(0, numConn).ToArray());
                        pathGridPoints[i] = pt;
                        pointDataSpan     = pointDataSpan.Slice(16);
                        connectionInts    = connectionInts.Slice(numConn);
                    }
                    item.PointToPointConnections = pathGridPoints.ToExtendedList();
                    readPGRR = true;
                    break;

                default:
                    break;
                }
            }

            if (!readPGRR)
            {
                ExtendedList <PathGridPoint> list = new ExtendedList <PathGridPoint>();
                while (pointDataSpan.Length > 0)
                {
                    list.Add(
                        ReadPathGridPoint(pointDataSpan, out var numConn));
                    pointDataSpan = pointDataSpan.Slice(16);
                }
                item.PointToPointConnections = list;
            }
        }
示例#10
0
 public static partial void FillBinaryOwnerCustom(MutagenFrame frame, IExtraData item)
 {
     item.Owner = GetBinaryOwner(frame.ReadSpan(8), frame.MetaData.RecordInfoCache !, frame.MetaData.MasterReferences !);
 }
示例#11
0
 public static partial void FillBinaryFlagsCustom(MutagenFrame frame, IBookInternal item)
 {
     item.Flags = (Book.Flag)frame.ReadUInt8();
 }
示例#12
0
 static partial void FillBinaryConditionsCustom(MutagenFrame frame, IConstructibleObjectInternal item)
 {
     ConditionBinaryCreateTranslation.FillConditionsList(item.Conditions, frame);
 }
示例#13
0
 static partial void FillBinaryTargetCustom(MutagenFrame frame, ILocationTargetRadius item)
 {
     item.Target = GetLocationTarget(frame);
 }
示例#14
0
 public static partial void FillBinaryFunctionParametersCustom(MutagenFrame frame, IAPerkEntryPointEffect item)
 {
 }
示例#15
0
            private static void CustomBinaryEnd(MutagenFrame frame, ICellInternal obj)
            {
                if (frame.Reader.Complete)
                {
                    return;
                }
                if (!frame.TryGetGroup(out var groupMeta))
                {
                    return;
                }
                var formKey = FormKey.Factory(frame.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeData));

                if (groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
                {
                    obj.Timestamp   = BinaryPrimitives.ReadInt32LittleEndian(groupMeta.LastModifiedData);
                    frame.Position += groupMeta.HeaderLength;
                    if (formKey != obj.FormKey)
                    {
                        throw new ArgumentException("Cell children group did not match the FormID of the parent cell.");
                    }
                }
                else
                {
                    return;
                }
                var subFrame = frame.SpawnWithLength(groupMeta.ContentLength);

                while (!subFrame.Complete)
                {
                    var persistGroupMeta = frame.GetGroup();
                    if (!persistGroupMeta.IsGroup)
                    {
                        throw new ArgumentException();
                    }
                    GroupTypeEnum type      = (GroupTypeEnum)persistGroupMeta.GroupType;
                    var           itemFrame = frame.SpawnWithLength(persistGroupMeta.TotalLength);
                    switch (type)
                    {
                    case GroupTypeEnum.CellPersistentChildren:
                        ParseTypical(
                            frame: itemFrame,
                            obj: obj,
                            coll: obj.Persistent,
                            persistentParse: true);
                        break;

                    case GroupTypeEnum.CellTemporaryChildren:
                        ParseTemporary(
                            itemFrame,
                            obj);
                        break;

                    case GroupTypeEnum.CellVisibleDistantChildren:
                        ParseTypical(
                            frame: itemFrame,
                            obj: obj,
                            coll: obj.VisibleWhenDistant,
                            persistentParse: false);
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
示例#16
0
 public static partial void FillBinaryCustomLogicCustom(
     MutagenFrame frame,
     IADamageTypeInternal item);
示例#17
0
 static partial void FillBinaryConditionsCustom(MutagenFrame frame, IDialogResponsesInternal item)
 {
     ConditionBinaryCreateTranslation.FillConditionsList(item.Conditions, frame);
 }
示例#18
0
            public static partial void FillBinaryAliasIndexCustom(MutagenFrame frame, IFindMatchingRefNearAlias item)
            {
                var subrecord = frame.ReadSubrecordFrame();

                item.AliasIndex = checked ((short) BinaryPrimitives.ReadInt32LittleEndian(subrecord.Content));
            }
示例#19
0
 public virtual void CopyInFromBinary(
     IGlobalInternal item,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter = null)
 {
 }
示例#20
0
 public static void FillBinaryStructs(
     IRegionLand item,
     MutagenFrame frame)
 {
 }
示例#21
0
 public static partial void FillBinaryContainedRecordTypeCustom(
     MutagenFrame frame,
     ISkyrimListGroup <T> item)
 {
     frame.Reader.Position += 4;
 }
 public virtual void CopyInFromBinary(
     IGameSettingInternal item,
     MutagenFrame frame,
     TypedParseParams?translationParams = null)
 {
 }
示例#23
0
        private static void AlignGroupsByRules(
            MutagenBinaryReadStream inputStream,
            MutagenWriter writer,
            AlignmentRules alignmentRules,
            RecordLocator.FileLocations fileLocs)
        {
            while (!inputStream.Complete)
            {
                // Import until next listed major record
                long noRecordLength;
                if (fileLocs.GrupLocations.TryGetInDirection(
                        inputStream.Position,
                        higher: true,
                        result: out var nextRec))
                {
                    noRecordLength = nextRec.Value - inputStream.Position;
                }
                else
                {
                    noRecordLength = inputStream.Remaining;
                }
                inputStream.WriteTo(writer.BaseStream, (int)noRecordLength);

                // If complete overall, return
                if (inputStream.Complete)
                {
                    break;
                }
                var groupMeta = inputStream.GetGroup();
                if (!groupMeta.IsGroup)
                {
                    throw new ArgumentException();
                }
                inputStream.WriteTo(writer.BaseStream, checked ((int)groupMeta.HeaderLength));

                if (!alignmentRules.GroupTypeAlignment.TryGetValue(groupMeta.GroupType, out var groupRules))
                {
                    continue;
                }

                var storage = new Dictionary <RecordType, List <ReadOnlyMemorySlice <byte> > >();
                var rest    = new List <ReadOnlyMemorySlice <byte> >();
                using (var frame = MutagenFrame.ByLength(inputStream, groupMeta.ContentLength))
                {
                    while (!frame.Complete)
                    {
                        var majorMeta = inputStream.GetMajorRecord();
                        var bytes     = inputStream.ReadMemory(checked ((int)majorMeta.TotalLength), readSafe: true);
                        var type      = majorMeta.RecordType;
                        if (groupRules.Contains(type))
                        {
                            storage.GetOrAdd(type).Add(bytes);
                        }
                        else
                        {
                            rest.Add(bytes);
                        }
                    }
                }
                foreach (var rule in groupRules)
                {
                    if (storage.TryGetValue(rule, out var storageBytes))
                    {
                        foreach (var item in storageBytes)
                        {
                            writer.Write(item);
                        }
                    }
                }
                foreach (var item in rest)
                {
                    writer.Write(item);
                }
            }
        }
示例#24
0
 public static partial ParseResult FillBinaryResponseCountCustom(MutagenFrame frame, IDialogTopicInternal item)
 {
     // Skip counter
     frame.ReadSubrecordFrame();
     return(null);
 }
示例#25
0
文件: Water.cs 项目: Noggog/Mutagen
 static partial void FillBinaryDataCustom(MutagenFrame frame, IWaterInternal item)
 {
     item.Data = CreateCustom(frame);
 }
示例#26
0
 static partial void FillBinaryConditionsCustom(MutagenFrame frame, IQuestLogEntry item)
 {
     ConditionBinaryCreateTranslation.FillConditionsList(item.Conditions, frame);
 }
示例#27
0
 static partial void FillBinaryScriptFragmentsCustom(MutagenFrame frame, IPerkAdapter item)
 {
     item.ScriptFragments = Mutagen.Bethesda.Skyrim.PerkScriptFragments.CreateFromBinary(frame: frame);
 }
示例#28
0
 static partial void FillBinaryScriptFragmentsCustom(MutagenFrame frame, IPackageAdapter item)
 {
     item.ScriptFragments = Mutagen.Bethesda.Fallout4.PackageScriptFragments.CreateFromBinary(frame: frame);
 }
示例#29
0
 static partial void FillBinaryParseCustom(MutagenFrame frame, IAvailableMorphs item)
 {
     FillBinaryParse(frame, item);
 }
示例#30
0
 public static partial void FillBinaryDataParseCustom(MutagenFrame frame, IAPackageTarget item)
 {
 }