示例#1
0
        public new static Script Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            Script script = mapper.Map <Script>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                ushort pathLength = memory.ReadUInt16();
                script.Path = memory.ReadString(pathLength);
                uint scriptCount = memory.ReadUInt32();

                for (int i = 0; i < scriptCount; i++)
                {
                    ScriptFile scriptFile       = new ScriptFile();
                    ulong      pathHash         = memory.ReadUInt64();
                    ulong      dataHash         = memory.ReadUInt64();
                    ushort     scriptPathLength = memory.ReadUInt16();
                    scriptFile.Path = memory.ReadString(scriptPathLength);
                    uint scriptLength = memory.ReadUInt32();
                    scriptFile.Data = memory.ReadBytes((int)scriptLength);

                    if (scriptFile.PathHash != pathHash || scriptFile.DataHash != dataHash)
                    {
                        throw new InvalidDataException();
                    }

                    script.Scripts.Add(scriptFile);
                }
            }

            return(script);
        }
示例#2
0
文件: Texture.cs 项目: Mettak/sdslib
        public new static Texture Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            Texture texture = mapper.Map <Texture>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                if (version == 2)
                {
                    memory.Seek(sizeof(ulong), SeekOrigin.Begin);
                }

                else if (version == 3)
                {
                    memory.Seek(sizeof(ulong), SeekOrigin.Begin);
                    texture.Info.SourceDataDescription = $"{texture.ResourceNameHash}.dds";
                }

                if (version == 2)
                {
                    texture.Unknown8 = memory.ReadUInt8();
                }

                texture.HasMipMap = System.Convert.ToBoolean(memory.ReadUInt8());
                texture.Data      = memory.ReadAllBytesFromCurrentPosition();
            }
            return(texture);
        }
示例#3
0
        public new static MemFile Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            MemFile type = mapper.Map <MemFile>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            if (version == 2)
            {
                using (MemoryStream memory = new MemoryStream(rawData))
                {
                    uint pathLength = memory.ReadUInt32();
                    type.Path = memory.ReadString((int)pathLength);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    byte[] buffer = memory.ReadAllBytesFromCurrentPosition();
                    type.Data = Encoding.UTF8.GetBytes(Encoding.UTF8.GetString(buffer));
                }
            }

            else if (version == 4)
            {
                using (MemoryStream memory = new MemoryStream(rawData))
                {
                    memory.Seek(sizeof(uint), SeekOrigin.Begin);
                    uint pathLength = memory.ReadUInt32();
                    type.Path = memory.ReadString((int)pathLength);
                    type.Info.SourceDataDescription = type.Path;
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    uint dataLength = memory.ReadUInt32();
                    type.Data = memory.ReadAllBytesFromCurrentPosition();
                }
            }

            return(type);
        }
示例#4
0
        public new static Mipmap Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            Mipmap texture = mapper.Map <Mipmap>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                memory.Seek(sizeof(ulong), SeekOrigin.Begin);
                texture.Unknown8 = memory.ReadUInt8();
                texture.Data     = memory.ReadAllBytesFromCurrentPosition();
            }
            return(texture);
        }
示例#5
0
        public new static Flash Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            Flash type = mapper.Map <Flash>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                ushort pathLength = memory.ReadUInt16();
                type.Path = memory.ReadString(pathLength);
                type.Info.SourceDataDescription = type.Path;
                type.Unknown64            = memory.ReadUInt64();
                pathLength                = memory.ReadUInt16();
                type.NameWithoutExtension = memory.ReadString(pathLength);
                uint dataLength = memory.ReadUInt32();
                type.Data = memory.ReadAllBytesFromCurrentPosition();
            }

            return(type);
        }
示例#6
0
        public new static SystemObjectDatabase Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            SystemObjectDatabase type = mapper.Map <SystemObjectDatabase>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }
示例#7
0
        public new static AnimalTrafficPaths Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            AnimalTrafficPaths type = mapper.Map <AnimalTrafficPaths>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }
示例#8
0
        public new static FrameNameTable Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            FrameNameTable type = mapper.Map <FrameNameTable>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }
示例#9
0
        public new static IndexBufferPool Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            IndexBufferPool type = mapper.Map <IndexBufferPool>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }
示例#10
0
        public new static NAV_PATH_DATA Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            NAV_PATH_DATA type = mapper.Map <NAV_PATH_DATA>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }
示例#11
0
        public new static XML Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired,
                                          uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            XML xml = mapper.Map <XML>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                xml.TargetModule = memory.ReadString((int)memory.ReadUInt32());
                xml.Unknown8     = memory.ReadUInt8();
                xml.Path         = memory.ReadString((int)memory.ReadUInt32());

                if (xml.Path != xml.Info.SourceDataDescription)
                {
                    xml.Info.SourceDataDescription = xml.Path;
                }

                xml.Unknown16 = memory.ReadUInt16();

                if (xml.Unknown16 != 1024)
                {
                    xml.rawUnsolved = rawData;
                    return(xml);
                }

                uint   nodesCount = memory.ReadUInt32();
                byte[] valuesDb   = new byte[memory.ReadUInt32()];

                memory.Read(valuesDb, 0, valuesDb.Length);
                using (MemoryStream valuesDbStream = new MemoryStream(valuesDb))
                {
                    for (int i = 0; i < nodesCount; i++)
                    {
                        Node node = new Node();

                        uint nameOffset = memory.ReadUInt32();
                        valuesDbStream.Seek(nameOffset, SeekOrigin.Begin);
                        node.Name.Type      = valuesDbStream.ReadUInt32();
                        node.Name.Unknown32 = valuesDbStream.ReadUInt32();
                        node.Name.Value     = valuesDbStream.ReadStringDynamic();

                        uint valueOffset = memory.ReadUInt32();
                        valuesDbStream.Seek(valueOffset, SeekOrigin.Begin);
                        node.Value.Type      = valuesDbStream.ReadUInt32();
                        node.Value.Unknown32 = valuesDbStream.ReadUInt32();
                        node.Value.Value     = valuesDbStream.ReadStringDynamic();

                        node.Id = memory.ReadUInt32();

                        uint childCount = memory.ReadUInt32();
                        for (int j = 0; j < childCount; j++)
                        {
                            node.Childs.Add(memory.ReadUInt32());
                        }

                        uint attributesCount = memory.ReadUInt32();
                        for (int k = 0; k < attributesCount; k++)
                        {
                            Node.Attribute attribute = new Node.Attribute();

                            uint attributeNameOffset = memory.ReadUInt32();
                            valuesDbStream.Seek(attributeNameOffset, SeekOrigin.Begin);
                            attribute.Name.Type      = valuesDbStream.ReadUInt32();
                            attribute.Name.Unknown32 = valuesDbStream.ReadUInt32();
                            attribute.Name.Value     = valuesDbStream.ReadStringDynamic();

                            uint attributeValueOffset = memory.ReadUInt32();
                            valuesDbStream.Seek(attributeValueOffset, SeekOrigin.Begin);
                            attribute.Value.Type      = valuesDbStream.ReadUInt32();
                            attribute.Value.Unknown32 = valuesDbStream.ReadUInt32();
                            attribute.Value.Value     = valuesDbStream.ReadStringDynamic();

                            node.Attributes.Add(attribute);
                        }

                        xml._nodes.Add(node);
                    }
                }
            }
            return(xml);
        }