Пример #1
0
            static partial void FillBinaryFragmentCountCustom(MutagenFrame frame, IQuestAdapter item)
            {
                var count = frame.ReadUInt16();

                item.FileName = StringBinaryTranslation.Instance.Parse(frame, stringBinaryType: StringBinaryType.PrependLengthUShort);
                item.Fragments.SetTo(
                    ListBinaryTranslation <QuestScriptFragment> .Instance.Parse(
                        frame,
                        amount: count,
                        transl: (MutagenFrame r, out QuestScriptFragment listSubItem) =>
                {
                    listSubItem = QuestScriptFragment.CreateFromBinary(frame);
                    return(true);
                }));
                var aliasCount = frame.ReadUInt16();

                item.Aliases.SetTo(
                    ListBinaryTranslation <QuestFragmentAlias> .Instance.Parse(
                        frame,
                        amount: aliasCount,
                        transl: (MutagenFrame r, out QuestFragmentAlias listSubItem) =>
                {
                    listSubItem = QuestFragmentAlias.CreateFromBinary(frame);
                    return(true);
                }));
            }
Пример #2
0
            static partial void FillBinaryAlwaysLoadedCustom(MutagenFrame frame, IAddonNodeInternal item)
            {
                var flags = frame.ReadUInt16();

                item.AlwaysLoaded = flags switch
                {
                    1 => false,
                    3 => true,
                    _ => throw new NotImplementedException()
                };
            }
        }
Пример #3
0
            partial void CustomFileNameEndPos()
            {
                if (this._data.Length <= this.ScriptsEndingPos)
                {
                    return;
                }
                var frame = new MutagenFrame(
                    new MutagenInterfaceReadStream(
                        new BinaryMemoryReadStream(_data.Slice(ScriptsEndingPos)),
                        _package.MetaData));

                // Skip unknown
                frame.Position += 1;
                var count = frame.ReadUInt16();

                _filename = StringBinaryTranslation.Instance.Parse(frame, stringBinaryType: StringBinaryType.PrependLengthUShort);
                Fragments =
                    ListBinaryTranslation <QuestScriptFragment> .Instance.Parse(
                        frame,
                        amount : count,
                        transl : (MutagenFrame r, out QuestScriptFragment listSubItem) =>
                {
                    listSubItem = QuestScriptFragment.CreateFromBinary(frame);
                    return(true);
                })
                    .ToList();

                var aliasCount = frame.ReadUInt16();

                Aliases =
                    ListBinaryTranslation <QuestFragmentAlias> .Instance.Parse(
                        frame,
                        amount : aliasCount,
                        transl : (MutagenFrame r, out QuestFragmentAlias listSubItem) =>
                {
                    listSubItem = QuestFragmentAlias.CreateFromBinary(frame);
                    return(true);
                })
                    .ToList();
            }
            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);
                }
            }
            public static void FillObject(MutagenFrame frame, IScriptObjectProperty obj, ushort objectFormat)
            {
                switch (objectFormat)
                {
                case 2:
                    obj.Unused         = frame.ReadUInt16();
                    obj.Alias          = frame.ReadInt16();
                    obj.Object.FormKey = FormLinkBinaryTranslation.Instance.Parse(
                        reader: frame,
                        defaultVal: FormKey.Null);
                    break;

                case 1:
                    obj.Object.FormKey = FormLinkBinaryTranslation.Instance.Parse(
                        reader: frame,
                        defaultVal: FormKey.Null);
                    obj.Alias  = frame.ReadInt16();
                    obj.Unused = frame.ReadUInt16();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
Пример #6
0
            static partial void FillBinaryPropertyCustom(MutagenFrame frame, IQuestFragmentAlias item)
            {
                // Preparse object format
                var pos = frame.Position;

                frame.Position += 10;
                var format = frame.ReadUInt16();

                frame.Position = pos;

                var obj = new ScriptObjectProperty();

                AVirtualMachineAdapterBinaryCreateTranslation.FillObject(frame, obj, format);
                item.Property = obj;
            }
            public static IEnumerable <ScriptEntry> ReadEntries(MutagenFrame frame, ushort objectFormat)
            {
                ushort count = frame.ReadUInt16();

                for (int i = 0; i < count; i++)
                {
                    var scriptName  = StringBinaryTranslation.Instance.Parse(frame, stringBinaryType: StringBinaryType.PrependLengthUShort, encoding: frame.MetaData.Encodings.NonTranslated);
                    var scriptFlags = (ScriptEntry.Flag)frame.ReadUInt8();
                    var entry       = new ScriptEntry()
                    {
                        Name  = scriptName,
                        Flags = scriptFlags,
                    };
                    FillProperties(frame, objectFormat, entry);
                    yield return(entry);
                }
            }
Пример #8
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();
            }
        }
Пример #9
0
 public static partial void FillBinaryBlurRadiusCustom(MutagenFrame frame, IImageSpaceDepthOfField item)
 {
     ParseSkyBlurRadius(frame.ReadUInt16(), out var radius, out var sky);
     item.BlurRadius = radius;
     item.Sky        = sky;
 }
Пример #10
0
 static partial void FillBinaryFlagsCustom(MutagenFrame frame, IWeaponData item)
 {
     // Read normally
     item.Flags = (WeaponData.Flag)frame.ReadUInt16();
 }