Exemple #1
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(ObjectID);
     writer.Write(DataOffset);
     writer.Write(DataSize);
     writer.Write(TypeIndex);
 }
Exemple #2
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(Entries.Count());
     writer.Write(StringBuffer.Length);
     foreach (var entry in Entries)
     {
         entry.Write(writer);
     }
     writer.WriteChars(StringBuffer);
 }
Exemple #3
0
 public void WritePtr(AssetsWriter writer)
 {
     if (isNull)
     {
         byte[] buf = new byte[12];
         writer.Write(buf);
         return;
     }
     writer.Write(FileID);
     writer.AlignTo(4);
     writer.Write(Target.ObjectID);
 }
Exemple #4
0
        public void Write(AssetsWriter writer, byte[] compressedData)
        {
            if (fileVersion != 6)
            {
                throw new NotSupportedException("File version is not supported");
            }
            //basic header stuff
            writer.WriteCString(signature);
            writer.WriteBEInt32(fileVersion);
            // TODO ADD
            // WriteDirectory to a MemoryStream
            // Check length of the resultant byte array, should be = UncompressedLength
            // Compress it
            // Write compressed length
            MemoryStream s = new MemoryStream();

            using (AssetsWriter w = new AssetsWriter(s))
            {
                WriteDirectory(w);
            }
            int uncompressedLength = (int)s.Length;
            // todo
            var compressedMetadata = LZ4.LZ4Codec.EncodeHC(s.ToArray(), 0, uncompressedLength);

            BundleSize += compressedMetadata.Length;
            writer.WriteCString(PlayerVersion);
            writer.WriteCString(EngineVersion);
            writer.WriteBEInt64(BundleSize);

            // compressedSize is actually the size of the METADATA byte array
            // The one with the Entries and BlockInfos + unknown directory header
            writer.WriteBEInt32(compressedMetadata.Length);
            writer.WriteBEInt32(uncompressedLength);
            writer.WriteBEUInt32(flags);

            if (!IsDirectoryAtEnd(flags))
            {
                // Actually write the directory information to the file
                writer.Write(compressedMetadata);
            }
            // Now write the actual data the BlockInfos use
            writer.Write(compressedData);
            if (IsDirectoryAtEnd(flags))
            {
                // Actually write the directory information to the file
                writer.Write(compressedMetadata);
            }
        }
Exemple #5
0
 public void Write(AssetsWriter writer)
 {
     Texture.Write(writer);
     AlphaTexture.Write(writer);
     writer.WriteArrayOf(SubMeshes, (o, w) => o.Write(w));
     writer.WriteArray(IndexBuffer);
     writer.AlignTo(4);
     VertexData.Write(writer);
     writer.WriteArrayOf(BindPose, (o, w) => w.Write(o));
     TextureRect.Write(writer);
     TextureRectOffset.Write(writer);
     AtlasRectOffset.Write(writer);
     writer.Write(SettingsRaw);
     UVTransform.Write(writer);
     writer.Write(DownscaleMultiplier);
 }
Exemple #6
0
        public void Write(AssetsWriter writer)
        {
            writer.Write(ClassID);
            writer.Write(Unknown1);
            writer.Write(Unknown2);
            if (IsScriptType)
            {
                writer.Write(ScriptHash);
            }
            writer.Write(TypeHash);

            if (TypeTree != null)
            {
                TypeTree.Write(writer);
            }
        }
Exemple #7
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(Version);
     writer.Write(Depth);
     writer.Write(IsArray);
     writer.Write(TypeOffset);
     writer.Write(NameOffset);
     writer.Write(Size);
     writer.Write(Index);
     writer.Write(Flags);
 }
Exemple #8
0
 public void Write(AssetsWriter writer)
 {
     writer.WriteBEInt32(MetadataSize);
     writer.WriteBEInt32(FileSize);
     writer.WriteBEInt32(Version);
     writer.WriteBEInt32(ObjectDataOffset);
     writer.Write(IsBigEndian);
     writer.AlignTo(4);
     //writer.Write(new byte[3]);
 }
Exemple #9
0
        private void WriteDirectory(AssetsWriter writer)
        {
            //unknown?
            writer.Write(_directoryUnknown);
            writer.WriteBEInt32(BlockInfos.Count);

            for (int i = 0; i < BlockInfos.Count; i++)
            {
                BlockInfos[i].Write(writer);
            }

            writer.WriteBEInt32(Entries.Count);
            for (int i = 0; i < Entries.Count; i++)
            {
                Entries[i].Write(writer);
            }
        }
Exemple #10
0
 protected override void WriteBase(AssetsWriter writer)
 {
     base.WriteBase(writer);
     writer.Write(Name);
     Rect.Write(writer);
     Offset.Write(writer);
     Border.Write(writer);
     writer.Write(PixelsToUnits);
     Pivot.Write(writer);
     writer.Write(Extrude);
     writer.Write(IsPolygon);
     writer.AlignTo(4);
     writer.Write(RenderDataKey.First);
     writer.Write(RenderDataKey.Second);
     writer.WriteArrayOf(AtlasTags, (o, w) => w.Write(o));
     SpriteAtlas.Write(writer);
     RenderData.Write(writer);
     writer.WriteArrayOf(PhysicsShape, (o, w) => w.WriteArrayOf(o, (o2, w2) => o2.Write(w2)));
     writer.WriteArrayOf(Bones, (o, w) => o.Write(w));
 }
Exemple #11
0
 public void Write(AssetsWriter writer)
 {
     writer.WriteCString(Version);
     writer.Write(Platform);
     writer.Write(HasTypeTrees);
     writer.Write(Types.Count());
     Types.ForEach(x => x.Write(writer));
     writer.Write(ObjectInfos.Count());
     ObjectInfos.ForEach(x => {
         writer.AlignTo(4);
         x.Write(writer);
     });
     writer.Write(Adds.Count());
     Adds.ForEach(x => {
         writer.AlignTo(4);
         x.Write(writer);
     });
     writer.Write(ExternalFiles.Count());
     ExternalFiles.ForEach(x => x.Write(writer));
     writer.WriteCString("");
 }
Exemple #12
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(FileID);
     writer.AlignTo(4);
     writer.Write(PathID);
 }
Exemple #13
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(PreloadIndex);
     writer.Write(PreloadSize);
     Asset.WritePtr(writer);
 }
Exemple #14
0
 protected virtual void WriteObject(AssetsWriter writer)
 {
     writer.Write(Data);
 }