Exemplo n.º 1
0
        private void FixVMADScriptIDs(IMutagenReadStream stream, long fileOffset, ushort objectFormat)
        {
            // skip name
            var len = stream.ReadUInt16();

            stream.Position += len;
            // Skip flags
            stream.Position += 1;
            var propCount = stream.ReadUInt16();

            for (int j = 0; j < propCount; j++)
            {
                // skip name
                len              = stream.ReadUInt16();
                stream.Position += len;
                var type = (ScriptProperty.Type)stream.ReadUInt8();
                // skip flags
                stream.Position += 1;
                // Going to cheat here, and use the autogenerated records
                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(),
                };
                switch (prop)
                {
                case ScriptObjectProperty obj:
                    FixObjectPropertyIDs(stream, fileOffset, objectFormat);
                    break;

                case ScriptObjectListProperty objList:
                    var count = stream.ReadUInt32();
                    for (int i = 0; i < count; i++)
                    {
                        FixObjectPropertyIDs(stream, fileOffset, objectFormat);
                    }
                    break;

                default:
                    prop.CopyInFromBinary(new MutagenFrame(stream));
                    break;
                }
            }
        }