Пример #1
0
 public static void FillBinaryStructs(
     ICellInternal item,
     MutagenFrame frame)
 {
     Fallout4MajorRecordBinaryCreateTranslation.FillBinaryStructs(
         item: item,
         frame: frame);
 }
Пример #2
0
 public static void CopyInFromBinary(
     this ICellInternal item,
     MutagenFrame frame,
     TypedParseParams?translationParams = null)
 {
     ((CellSetterCommon)((ICellGetter)item).CommonSetterInstance() !).CopyInFromBinary(
         item: item,
         frame: frame,
         translationParams: translationParams);
 }
Пример #3
0
 public static void CopyInFromBinary(
     this ICellInternal item,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter = null)
 {
     ((CellSetterCommon)((ICellGetter)item).CommonSetterInstance() !).CopyInFromBinary(
         item: item,
         frame: frame,
         recordTypeConverter: recordTypeConverter);
 }
Пример #4
0
 public static partial void CustomBinaryEndImport(MutagenFrame frame, ICellInternal obj)
 {
     try
     {
         CustomBinaryEnd(frame, obj);
     }
     catch (Exception ex)
     {
         throw RecordException.Enrich(ex, obj);
     }
 }
Пример #5
0
 public virtual void CopyInFromBinary(
     ICellInternal item,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter = null)
 {
     PluginUtilityTranslation.MajorRecordParse <ICellInternal>(
         record: item,
         frame: frame,
         recordTypeConverter: recordTypeConverter,
         fillStructs: CellBinaryCreateTranslation.FillBinaryStructs,
         fillTyped: CellBinaryCreateTranslation.FillBinaryRecordTypes);
 }
Пример #6
0
 public virtual void CopyInFromBinary(
     ICellInternal item,
     MutagenFrame frame,
     TypedParseParams?translationParams = null)
 {
     PluginUtilityTranslation.MajorRecordParse <ICellInternal>(
         record: item,
         frame: frame,
         translationParams: translationParams,
         fillStructs: CellBinaryCreateTranslation.FillBinaryStructs,
         fillTyped: CellBinaryCreateTranslation.FillBinaryRecordTypes);
 }
Пример #7
0
 public static void DeepCopyIn(
     this ICellInternal lhs,
     ICellGetter rhs,
     ErrorMaskBuilder?errorMask,
     TranslationCrystal?copyMask)
 {
     ((CellSetterTranslationCommon)((ICellGetter)lhs).CommonSetterTranslationInstance() !).DeepCopyIn(
         item: lhs,
         rhs: rhs,
         errorMask: errorMask,
         copyMask: copyMask,
         deepCopy: false);
 }
Пример #8
0
 public void DeepCopyIn(
     ICellInternal item,
     ICellGetter rhs,
     ErrorMaskBuilder?errorMask,
     TranslationCrystal?copyMask,
     bool deepCopy)
 {
     base.DeepCopyIn(
         item,
         rhs,
         errorMask,
         copyMask,
         deepCopy: deepCopy);
 }
Пример #9
0
        public static void DeepCopyIn(
            this ICellInternal lhs,
            ICellGetter rhs,
            out Cell.ErrorMask errorMask,
            Cell.TranslationMask?copyMask = null)
        {
            var errorMaskBuilder = new ErrorMaskBuilder();

            ((CellSetterTranslationCommon)((ICellGetter)lhs).CommonSetterTranslationInstance() !).DeepCopyIn(
                item: lhs,
                rhs: rhs,
                errorMask: errorMaskBuilder,
                copyMask: copyMask?.GetCrystal(),
                deepCopy: false);
            errorMask = Cell.ErrorMask.Factory(errorMaskBuilder);
        }
Пример #10
0
            static void ParseTypical(
                MutagenFrame frame,
                ICellInternal obj,
                IList <IPlaced> coll,
                bool persistentParse)
            {
                var groupMeta = frame.ReadGroup();
                var formKey   = FormKey.Factory(frame.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeData));

                if (formKey != obj.FormKey)
                {
                    throw new ArgumentException("Cell children group did not match the FormID of the parent cell.");
                }
                if (persistentParse)
                {
                    obj.PersistentTimestamp = groupMeta.LastModifiedData.Int32();
                }
                else
                {
                    obj.VisibleWhenDistantTimestamp = groupMeta.LastModifiedData.Int32();
                }
                coll.AddRange(
                    ListBinaryTranslation <IPlaced> .Instance.Parse(
                        reader: frame,
                        transl: (MutagenFrame r, RecordType header, out IPlaced placed) =>
                {
                    switch (header.TypeInt)
                    {
                    case 0x45524341:             // "ACRE":
                        placed = PlacedCreature.CreateFromBinary(r);
                        return(true);

                    case 0x52484341:             //"ACHR":
                        placed = PlacedNpc.CreateFromBinary(r);
                        return(true);

                    case 0x52464552:             // "REFR":
                        placed = PlacedObject.CreateFromBinary(r);
                        return(true);

                    default:
                        throw new NotImplementedException();
                    }
                }));
            }
Пример #11
0
            static void ParseTemporary(MutagenFrame frame, ICellInternal obj)
            {
                var groupMeta = frame.ReadGroup();
                var formKey   = FormKey.Factory(frame.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeData));

                if (formKey != obj.FormKey)
                {
                    throw new ArgumentException("Cell children group did not match the FormID of the parent cell.");
                }
                obj.TemporaryTimestamp = BinaryPrimitives.ReadInt32LittleEndian(groupMeta.LastModifiedData);
                var items = ListBinaryTranslation <IPlaced> .Instance.Parse(
                    reader : frame,
                    transl : (MutagenFrame r, RecordType header, out IPlaced placed) =>
                {
                    switch (header.TypeInt)
                    {
                    case 0x45524341:         // "ACRE":
                        placed = PlacedCreature.CreateFromBinary(r);
                        return(true);

                    case 0x52484341:         //"ACHR":
                        placed = PlacedNpc.CreateFromBinary(r);
                        return(true);

                    case 0x52464552:         // "REFR":
                        placed = PlacedObject.CreateFromBinary(r);
                        return(true);

                    default:
                        if (ParseTemporaryOutliers(frame, obj))
                        {
                            placed = null !;
                            return(false);
                        }
                        throw new NotImplementedException();
                    }
                    placed = null !;
                    return(false);
                });

                obj.Temporary.SetTo(new ExtendedList <IPlaced>(items));
            }
Пример #12
0
            static bool ParseTemporaryOutliers(MutagenFrame frame, ICellInternal obj)
            {
                var majorMeta  = frame.GetMajorRecord();
                var nextHeader = majorMeta.RecordType;

                if (nextHeader.Equals(RecordTypes.PGRD))
                {
                    obj.PathGrid = PathGrid.CreateFromBinary(
                        frame.SpawnWithLength(majorMeta.TotalLength),
                        translationParams: null);
                    return(true);
                }
                else if (nextHeader.Equals(RecordTypes.LAND))
                {
                    obj.Landscape = Landscape.CreateFromBinary(
                        frame.SpawnWithLength(majorMeta.TotalLength),
                        translationParams: null);
                    return(true);
                }
                return(false);
            }
Пример #13
0
            static bool ParseTemporaryOutliers(MutagenFrame frame, ICellInternal obj)
            {
                var majorMeta  = frame.GetMajorRecord();
                var nextHeader = majorMeta.RecordType;

                if (nextHeader.Equals(RecordTypes.NAVM))
                {
                    if (frame.MetaData.InWorldspace)
                    {
                        obj.NavigationMeshes.Add(
                            WorldspaceNavigationMesh.CreateFromBinary(
                                frame.SpawnWithLength(majorMeta.TotalLength),
                                recordTypeConverter: null));
                    }
                    else
                    {
                        obj.NavigationMeshes.Add(
                            CellNavigationMesh.CreateFromBinary(
                                frame.SpawnWithLength(majorMeta.TotalLength),
                                recordTypeConverter: null));
                    }
                    return(true);
                }
                else if (nextHeader.Equals(RecordTypes.LAND))
                {
                    if (obj.Landscape != null)
                    {
                        throw new ArgumentException("Had more than one landscape");
                    }
                    obj.Landscape = Landscape.CreateFromBinary(
                        frame.SpawnWithLength(majorMeta.TotalLength),
                        recordTypeConverter: null);
                    return(true);
                }
                return(false);
            }
Пример #14
0
        private bool TryGetCell(int row, int column, out ICellInternal cell)
        {
            cell = _cells.SingleOrDefault(cellInternal => cellInternal.Row == row && cellInternal.Column == column);

            return(cell != null);
        }
Пример #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 CustomBinaryEndImport(MutagenFrame frame, ICellInternal obj)
 {
     CustomBinaryEnd(frame, obj);
 }
Пример #17
0
 public static void Clear(this ICellInternal item)
 {
     ((CellSetterCommon)((ICellGetter)item).CommonSetterInstance() !).Clear(item: item);
 }
Пример #18
0
            static void ParseTemporary(MutagenFrame frame, ICellInternal obj)
            {
                var groupMeta = frame.ReadGroup();
                var formKey   = FormKey.Factory(frame.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeData));

                if (formKey != obj.FormKey)
                {
                    throw new ArgumentException("Cell children group did not match the FormID of the parent cell.");
                }
                obj.TemporaryTimestamp        = BinaryPrimitives.ReadInt32LittleEndian(groupMeta.LastModifiedData);
                obj.TemporaryUnknownGroupData = BinaryPrimitives.ReadInt32LittleEndian(groupMeta.HeaderData.Slice(groupMeta.HeaderData.Length - 4));
                var items = ListBinaryTranslation <IPlaced> .Instance.Parse(
                    reader : frame,
                    transl : (MutagenFrame r, RecordType header, out IPlaced placed) =>
                {
                    switch (header.TypeInt)
                    {
                    case RecordTypeInts.ACHR:
                        placed = PlacedNpc.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.REFR:
                        placed = PlacedObject.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PARW:
                        placed = PlacedArrow.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PBAR:
                        placed = PlacedBarrier.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PBEA:
                        placed = PlacedBeam.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PCON:
                        placed = PlacedCone.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PFLA:
                        placed = PlacedFlame.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PHZD:
                        placed = PlacedHazard.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PMIS:
                        placed = PlacedMissile.CreateFromBinary(r);
                        return(true);

                    case RecordTypeInts.PGRE:
                        placed = PlacedTrap.CreateFromBinary(r);
                        return(true);

                    default:
                        if (ParseTemporaryOutliers(frame, obj))
                        {
                            placed = null !;
                            return(false);
                        }
                        throw new NotImplementedException();
                    }
                });

                obj.Temporary.SetTo(new ExtendedList <IPlaced>(items));
            }
Пример #19
0
 public void Clear(ICellInternal item)
 {
     ClearPartial();
     base.Clear(item);
 }