Esempio n. 1
0
 private void Parse(AssetsReader reader)
 {
     ObjectID   = reader.ReadInt64();
     DataOffset = reader.ReadInt32();
     DataSize   = reader.ReadInt32();
     TypeIndex  = reader.ReadInt32();
 }
Esempio n. 2
0
        public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, reader);

                ObjectInfos.Add(obj);
            }
            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();
        }
Esempio n. 3
0
        public static SmartPtr <T> Read(AssetsFile assetsFile, AssetsObject owner, AssetsReader reader)
        {
            if (owner == null)
            {
                Log.LogErr("WARNING: SmartPtr created without an owner!");
            }
            int fileID = reader.ReadInt32();

            reader.AlignTo(4);
            Int64 pathID = reader.ReadInt64();

            if (fileID == 0 && pathID == 0)
            {
                return(null);
            }

            var objInfo = assetsFile.GetObjectInfo <T>(fileID, pathID);

            if (objInfo == null)
            {
                Log.LogErr($"WARNING: Could not find objectinfo for creating SmartPtr of type {typeof(T).Name} on owner type {owner?.GetType()?.Name ?? "(null owner)"}!  Returned a null pointer instead.");
                return(null);
            }

            SmartPtr <T> ptr = new SmartPtr <T>(owner, assetsFile.GetObjectInfo <T>(fileID, pathID));

            //TODO: not sure this is only ever called by existing objects
            ptr.IsNew = false;

            return(ptr);
        }
Esempio n. 4
0
        public void LoadData()
        {
            BaseStream.Seek(Header.HeaderSize, SeekOrigin.Begin);
            using (AssetsReader reader = new AssetsReader(BaseStream, false))
            {
                Metadata = new AssetsMetadata(this);
                Metadata.Parse(reader);
            }
            BaseStream.Seek(Header.ObjectDataOffset, SeekOrigin.Begin);

            if (Manager.ForceLoadAllFiles)
            {
                foreach (var ext in Metadata.ExternalFiles)
                {
                    Manager.GetAssetsFile(ext.FileName);
                }
            }
            if (!Manager.LazyLoad)
            {
                foreach (var oi in Metadata.ObjectInfos)
                {
                    var o = oi.Object;
                }
                BaseStream.Close();
                BaseStream.Dispose();
                BaseStream = null;
            }
        }
Esempio n. 5
0
 private void Parse(AssetsReader reader)
 {
     R = reader.ReadSingle();
     G = reader.ReadSingle();
     B = reader.ReadSingle();
     A = reader.ReadSingle();
 }
Esempio n. 6
0
 public void Parse(AssetsReader reader)
 {
     X      = reader.ReadSingle();
     Y      = reader.ReadSingle();
     Width  = reader.ReadSingle();
     Height = reader.ReadSingle();
 }
Esempio n. 7
0
 public void Parse(AssetsReader reader)
 {
     Stream    = reader.ReadByte();
     Offset    = reader.ReadByte();
     Format    = reader.ReadByte();
     Dimension = reader.ReadByte();
 }
 private void Parse(AssetsReader reader)
 {
     X = reader.ReadSingle();
     Y = reader.ReadSingle();
     Z = reader.ReadSingle();
     W = reader.ReadSingle();
 }
Esempio n. 9
0
 public BundleFile(Stream stream)
 {
     using (var reader = new AssetsReader(stream, false))
     {
         Parse(reader);
     }
 }
Esempio n. 10
0
        private void Parse(AssetsReader reader)
        {
            UncompressedSize = reader.ReadBEUInt32();
            CompressedSize   = reader.ReadBEUInt32();

            _flags = reader.ReadBEUInt16();
        }
Esempio n. 11
0
        public override void Parse(AssetsReader reader)
        {
            base.ParseBase(reader);
            IsEnabled            = reader.ReadBoolean();
            CastShadows          = reader.ReadByte();
            ReceiveShadows       = reader.ReadByte();
            DynamicOcclude       = reader.ReadByte();
            MotionVectors        = reader.ReadByte();
            LightProbeUsage      = reader.ReadByte();
            ReflectionProbeUsage = reader.ReadByte();
            reader.AlignTo(4);
            RenderingLayerMask = reader.ReadUInt32();
            if (ObjectInfo.ParentFile.Metadata.VersionGte("2018.3"))
            {
                RendererPriority = reader.ReadInt32();
            }
            LightmapIndex               = reader.ReadUInt16();
            LightmapIndexDynamic        = reader.ReadUInt16();
            LightmapTilingOffset        = new Vector4F(reader);
            LightmapTilingOffsetDynamic = new Vector4F(reader);
            Materials       = reader.ReadArrayOf(r => (ISmartPtr <MaterialObject>)SmartPtr <MaterialObject> .Read(ObjectInfo.ParentFile, this, r));
            StaticBatchInfo = new StaticBatchInfo(reader);
            StaticBatchRoot = SmartPtr <Transform> .Read(ObjectInfo.ParentFile, this, reader);

            ProbeAnchor = SmartPtr <Transform> .Read(ObjectInfo.ParentFile, this, reader);

            LightProbeVolumeOverride = SmartPtr <GameObject> .Read(ObjectInfo.ParentFile, this, reader);

            SortingLayerID          = reader.ReadInt32();
            SortingLayer            = reader.ReadInt16();
            SortingOrder            = reader.ReadInt16();
            AdditionalVertexStreams = SmartPtr <MeshObject> .Read(ObjectInfo.ParentFile, this, reader);
        }
Esempio n. 12
0
        public void Parse(AssetsFile file, AssetsObject owner, AssetsReader reader)
        {
            Texture = SmartPtr <Texture2DObject> .Read(file, owner, reader);

            Scale  = new Vector2F(reader);
            Offset = new Vector2F(reader);
        }
Esempio n. 13
0
        protected override void Parse(AssetsReader reader)
        {
            base.Parse(reader);
            Name = reader.ReadString();
            ForcedFallbackFormat = reader.ReadInt32();
            DownscaleFallback    = reader.ReadBoolean();
            reader.AlignTo(4);
            Width             = reader.ReadInt32();
            Height            = reader.ReadInt32();
            CompleteImageSize = reader.ReadInt32();
            TextureFormat     = (TextureFormatType)reader.ReadInt32();
            MipCount          = reader.ReadInt32();
            IsReadable        = reader.ReadBoolean();
            StreamingMipmaps  = reader.ReadBoolean();
            reader.AlignTo(4);
            StreamingMipmapsPriority = reader.ReadInt32();
            ImageCount       = reader.ReadInt32();
            TextureDimension = reader.ReadInt32();
            TextureSettings  = new GLTextureSettings(reader);
            LightmapFormat   = reader.ReadInt32();
            ColorSpace       = reader.ReadInt32();
            int imageDataSize = reader.ReadInt32();

            ImageData = reader.ReadBytes(imageDataSize);
            reader.AlignTo(4);
            StreamData = new StreamingInfo(reader);
        }
Esempio n. 14
0
        public IObjectInfo <T> Clone()
        {
            T newObj = null;

            using (var ms = new MemoryStream())
            {
                ObjectInfo <T> newInfo = (ObjectInfo <T>) ObjectInfo <T> .FromTypeIndex(ParentFile, TypeIndex, null);

                newInfo.DataOffset = 0;
                newInfo.ObjectID   = 0;
                using (var writer = new AssetsWriter(ms))
                {
                    Object.Write(writer);
                }
                newInfo.DataSize = (int)ms.Length;
                ms.Seek(0, SeekOrigin.Begin);
                using (var reader = new AssetsReader(ms))
                {
                    newObj = (T)Activator.CreateInstance(typeof(T), newInfo, reader);
                }
                newInfo.DataOffset = -1;
                newInfo.DataSize   = -1;
                newInfo._object    = newObj;
            }
            return((IObjectInfo <T>)newObj.ObjectInfo);
        }
Esempio n. 15
0
 private void Parse(AssetsReader reader)
 {
     AssetName = reader.ReadCStr();
     ID        = reader.ReadGuid();
     Type      = reader.ReadInt32();
     FileName  = reader.ReadCStr();
 }
Esempio n. 16
0
        private void ParseDetails(AssetsReader reader)
        {
            var readLength = ObjectInfo.DataSize - (reader.Position - ObjectInfo.DataOffset);

            ScriptParametersData = reader.ReadBytes(readLength);
            reader.AlignTo(4);
        }
Esempio n. 17
0
 public void Parse(AssetsReader reader)
 {
     VertexCount = reader.ReadUInt32();
     Channels    = reader.ReadArrayOf(r => new Channel(r));
     Data        = reader.ReadArray();
     reader.AlignTo(4);
 }
Esempio n. 18
0
 public void Parse(AssetsReader reader)
 {
     Verticies   = reader.ReadArrayOf((r) => new BlendShapeVertex(r));
     Shapes      = reader.ReadArrayOf((r) => new BlendShape(r));
     Channels    = reader.ReadArrayOf((r) => new BlendShapeChannel(r));
     FullWeights = reader.ReadArrayOf((r) => r.ReadSingle());
 }
Esempio n. 19
0
 public void Parse(AssetsReader reader)
 {
     Name       = reader.ReadString();
     NameHash   = reader.ReadUInt32();
     FrameIndex = reader.ReadInt32();
     FrameCount = reader.ReadInt32();
 }
Esempio n. 20
0
 private void Parse(AssetsReader reader)
 {
     Offset   = reader.ReadBEInt64();
     Size     = reader.ReadBEInt64();
     _flags   = reader.ReadBEUInt32();
     Filename = reader.ReadCStr();
 }
Esempio n. 21
0
 public void Parse(AssetsReader reader)
 {
     Vertex  = new Vector3F(reader);
     Normal  = new Vector3F(reader);
     Tangent = new Vector3F(reader);
     Index   = reader.ReadUInt32();
 }
Esempio n. 22
0
        public AssetsFile(AssetsManager manager, IAssetsFileProvider fileProvider, string assetsRootPath, string assetsFileName, bool loadData = true)
        {
            Manager        = manager;
            FileProvider   = fileProvider;
            AssetsRootPath = assetsRootPath;
            AssetsFilename = assetsFileName;

            OpenBaseStream();

            BaseStream.Seek(0, SeekOrigin.Begin);
            using (AssetsReader reader = new AssetsReader(BaseStream, false))
            {
                Header = new AssetsFileHeader(reader);
            }

            if (Header.MetadataSize > Header.FileSize || Header.ObjectDataOffset < Header.MetadataSize || Header.Version != 17)
            {
                throw new NotSupportedException($"{AssetsFilename} doesn't appear to be a valid assets file, or {Header.Version} is unsupported!");
            }

            if (loadData)
            {
                LoadData();
            }
        }
Esempio n. 23
0
        public override void Parse(AssetsReader reader)
        {
            base.ParseBase(reader);
            int startPosition = reader.Position;

            Name = reader.ReadString();
            //int readLen = ObjectInfo.DataSize - (reader.Position - startPosition);
            //MeshData = reader.ReadBytes(readLen);
            SubMeshes        = reader.ReadArrayOf(r => new Submesh(r));
            BlendShapeData   = new BlendShapeData(reader);
            BindPose         = reader.ReadArrayOf(r => reader.ReadSingle());
            BoneNameHashes   = reader.ReadArrayOf(r => r.ReadUInt32());
            RootBoneNameHash = reader.ReadUInt32();
            MeshCompression  = reader.ReadByte();
            IsReadable       = reader.ReadBoolean();
            KeepVerticies    = reader.ReadBoolean();
            KeepIndicies     = reader.ReadBoolean();
            reader.AlignTo(4);
            IndexFormat = reader.ReadInt32();
            IndexBuffer = reader.ReadArray();
            reader.AlignTo(4);
            VertexData               = new VertexData(reader);
            CompressedMesh           = new CompressedMesh(reader);
            LocalAABB                = new AABB(reader);
            MeshUsageFlags           = reader.ReadInt32();
            BakedConvexCollisionMesh = reader.ReadArray();
            reader.AlignTo(4);
            BakedTriangleCollisionMesh = reader.ReadArray();
            reader.AlignTo(4);
            MeshMetrics1 = reader.ReadSingle();
            MeshMetrics2 = reader.ReadSingle();
            StreamData   = new StreamingInfo(reader);
        }
Esempio n. 24
0
 public void Parse(AssetsReader reader)
 {
     NumItems = reader.ReadUInt32();
     Data     = reader.ReadArray();
     reader.AlignTo(4);
     BitSize = reader.ReadByte();
     reader.AlignTo(4);
 }
Esempio n. 25
0
        protected override void Parse(AssetsReader reader)
        {
            base.Parse(reader);
            Enabled           = reader.ReadInt32();
            MonoscriptTypePtr = SmartPtr <MonoScriptObject> .Read(ObjectInfo.ParentFile, this, reader);

            Name = reader.ReadString();
        }
Esempio n. 26
0
 public void Parse(AssetsReader reader)
 {
     FirstVertex = reader.ReadUInt32();
     VertexCount = reader.ReadUInt32();
     HasNormals  = reader.ReadBoolean();
     HasTangents = reader.ReadBoolean();
     reader.AlignTo(4);
 }
Esempio n. 27
0
        public override void Parse(AssetsReader reader)
        {
            ParseBase(reader);
            var readLength = ObjectInfo.DataSize - (reader.Position - ObjectInfo.DataOffset);

            ScriptParametersData = reader.ReadBytes(readLength);
            reader.AlignTo(4);
        }
Esempio n. 28
0
 protected override void Parse(AssetsReader reader)
 {
     base.Parse(reader);
     AnchorMin        = new Vector2F(reader);
     AnchorMax        = new Vector2F(reader);
     AnchoredPosition = new Vector2F(reader);
     SizeDelta        = new Vector2F(reader);
     Pivot            = new Vector2F(reader);
 }
Esempio n. 29
0
 protected override void Parse(AssetsReader reader)
 {
     base.Parse(reader);
     LocalRotation = new QuaternionF(reader);
     LocalPosition = new Vector3F(reader);
     LocalScale    = new Vector3F(reader);
     Children      = reader.ReadArrayOf(x => (ISmartPtr <Transform>)SmartPtr <Transform> .Read(ObjectInfo.ParentFile, this, reader));
     Father        = SmartPtr <AssetsObject> .Read(ObjectInfo.ParentFile, this, reader);
 }
Esempio n. 30
0
 private void Parse(AssetsReader reader)
 {
     FilterMode = reader.ReadInt32();
     Aniso      = reader.ReadInt32();
     MipBias    = reader.ReadSingle();
     WrapU      = reader.ReadInt32();
     WrapV      = reader.ReadInt32();
     WrapW      = reader.ReadInt32();
 }