Exemple #1
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();
                    }
                }));
            }
Exemple #2
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));
            }