Пример #1
0
            public static partial void FillBinaryFlags2Custom(MutagenFrame frame, IRaceInternal item)
            {
                // Clear out upper flags
                item.Flags &= ((Race.Flag) 0x00000000FFFFFFFF);

                // Set upper flags
                ulong flags2 = frame.ReadUInt32();

                flags2    <<= 32;
                item.Flags |= ((Race.Flag)flags2);
            }
Пример #2
0
 static partial void FillBinaryFlagsCustom(MutagenFrame frame, IMaterialObjectInternal item)
 {
     if (item.FormVersion >= 44 || (frame.Remaining >= 8 && item.FormVersion == 43 && frame.MetaData.Constants.Release == GameRelease.SkyrimVR))
     {
         item.Flags = (MaterialObject.Flag)frame.ReadUInt64();
     }
     else
     {
         item.Flags = (MaterialObject.Flag)frame.ReadUInt32();
     }
 }
Пример #3
0
            static partial void FillBinaryIDParseCustom(MutagenFrame frame, IQuestAlias item)
            {
                var subMeta = frame.ReadSubrecord();

                item.Type = subMeta.RecordTypeInt switch
                {
                    // ALST
                    0x54534C41 => QuestAlias.TypeEnum.Reference,
                    // ALLS
                    0x534C4C41 => QuestAlias.TypeEnum.Location,
                    _ => throw new NotImplementedException(),
                };
                item.ID = frame.ReadUInt32();
            }
Пример #4
0
            static partial void FillBinaryFlags2Custom(MutagenFrame frame, IWeaponData item)
            {
                var flags2 = frame.ReadUInt32();

                flags2 <<= UpperFlagShift;

                // Clean existing flags
                var flags = (uint)item.Flags;

                flags &= ~UpperFlagMask;

                flags     |= flags2;
                item.Flags = (WeaponData.Flag)flags;
            }
            static void FillProperties(MutagenFrame frame, ushort objectFormat, IScriptEntry item)
            {
                var count = frame.ReadUInt16();

                for (int i = 0; i < count; i++)
                {
                    var            name  = StringBinaryTranslation.Instance.Parse(frame, stringBinaryType: StringBinaryType.PrependLengthUShort, encoding: frame.MetaData.Encodings.NonTranslated);
                    var            type  = (ScriptProperty.Type)frame.ReadUInt8();
                    var            flags = (ScriptProperty.Flag)frame.ReadUInt8();
                    ScriptProperty prop  = type switch
                    {
                        ScriptProperty.Type.None => new ScriptProperty(),
                        ScriptProperty.Type.Object => new ScriptObjectProperty(),
                        ScriptProperty.Type.String => new ScriptStringProperty(),
                        ScriptProperty.Type.Int => new ScriptIntProperty(),
                        ScriptProperty.Type.Float => new ScriptFloatProperty(),
                        ScriptProperty.Type.Bool => new ScriptBoolProperty(),
                        ScriptProperty.Type.ArrayOfObject => new ScriptObjectListProperty(),
                        ScriptProperty.Type.ArrayOfString => new ScriptStringListProperty(),
                        ScriptProperty.Type.ArrayOfInt => new ScriptIntListProperty(),
                        ScriptProperty.Type.ArrayOfFloat => new ScriptFloatListProperty(),
                        ScriptProperty.Type.ArrayOfBool => new ScriptBoolListProperty(),
                        _ => throw new NotImplementedException(),
                    };
                    prop.Name  = name;
                    prop.Flags = flags;
                    switch (prop)
                    {
                    case ScriptObjectProperty obj:
                        FillObject(frame, obj, objectFormat);
                        break;

                    case ScriptObjectListProperty objList:
                        var objListCount = frame.ReadUInt32();
                        for (int j = 0; j < objListCount; j++)
                        {
                            var subObj = new ScriptObjectProperty();
                            FillObject(frame, subObj, objectFormat);
                            objList.Objects.Add(subObj);
                        }
                        break;

                    default:
                        prop.CopyInFromBinary(frame);
                        break;
                    }
                    item.Properties.Add(prop);
                }
            }
Пример #6
0
        public static Percent Parse(MutagenFrame reader, FloatIntegerType integerType)
        {
            switch (integerType)
            {
            case FloatIntegerType.UInt:
                return(Percent.FactoryPutInRange(((double)reader.ReadUInt32()) / uint.MaxValue));

            case FloatIntegerType.UShort:
                return(Percent.FactoryPutInRange(((double)reader.ReadUInt16()) / ushort.MaxValue));

            case FloatIntegerType.Byte:
                return(Percent.FactoryPutInRange(((double)reader.ReadUInt8()) / byte.MaxValue));

            default:
                throw new NotImplementedException();
            }
        }
Пример #7
0
        public static APackageTarget CreateFromBinary(MutagenFrame frame)
        {
            APackageTarget target = ((APackageTarget.Type)frame.ReadUInt32()) switch
            {
                APackageTarget.Type.SpecificReference => new PackageTargetSpecificReference()
                {
                    Reference = FormKeyBinaryTranslation.Instance.Parse(frame)
                },
                APackageTarget.Type.ObjectID => new PackageTargetObjectID()
                {
                    Reference = FormKeyBinaryTranslation.Instance.Parse(frame)
                },
                APackageTarget.Type.ObjectType => new PackageTargetObjectType()
                {
                    Type = (TargetObjectType)frame.ReadInt32()
                },
                APackageTarget.Type.LinkedReference => new PackageTargetReference()
                {
                    Reference = FormKeyBinaryTranslation.Instance.Parse(frame)
                },
                APackageTarget.Type.RefAlias => new PackageTargetAlias()
                {
                    Alias = frame.ReadInt32()
                },
                APackageTarget.Type.Unknown => new PackageTargetUnknown()
                {
                    Data = frame.ReadInt32()
                },
                APackageTarget.Type.Self => new PackageTargetSelf()
                {
                    Data = frame.ReadInt32()
                },
                _ => throw new NotImplementedException(),
            };

            target.CountOrDistance = frame.ReadInt32();
            return(target);
        }
Пример #8
0
 public static partial void FillBinaryTeachesCustom(MutagenFrame frame, IBookInternal item)
 {
     if ((((int)item.Flags) & SpellFlag) > 0)
     {
         item.Teaches = new BookSpell()
         {
             Spell = new FormLink <ISpellGetter>(FormLinkBinaryTranslation.Instance.Parse(frame))
         };
     }
     else if ((((int)item.Flags) & SkillFlag) > 0)
     {
         item.Teaches = new BookSkill
         {
             Skill = (Skill)frame.ReadInt32()
         };
     }
     else
     {
         item.Teaches = new BookTeachesNothing()
         {
             RawContent = frame.ReadUInt32()
         };
     }
 }
Пример #9
0
 public TranslatedString Parse(
     MutagenFrame reader,
     StringsSource source,
     StringBinaryType stringBinaryType,
     bool parseWhole = true)
 {
     if (reader.MetaData.StringsLookup != null)
     {
         if (reader.Remaining != 4)
         {
             throw new ArgumentException($"String in Strings File format had unexpected length: {reader.Remaining} != 4");
         }
         uint key = reader.ReadUInt32();
         if (key == 0)
         {
             return(new TranslatedString(directString: null));
         }
         return(reader.MetaData.StringsLookup.CreateString(source, key));
     }
     else
     {
         return(Parse(reader, parseWhole, stringBinaryType));
     }
 }