Esempio n. 1
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));
            }

            List <ObjectRecord> records = new List <ObjectRecord>();
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = new ObjectRecord(reader);
                records.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();

            //load the object infos in order based on their type
            foreach (var record in records.OrderBy(x => PreloadObjectOrder(x)).ThenBy(x => x.ObjectID))
            {
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, record);

                ObjectInfos.Add(obj);
                if (ShouldForceLoadObject(record))
                {
                    var o = obj.Object;
                }
            }
        }
Esempio n. 2
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(new SmartPtr <T>());
            }

            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. 3
0
 private void Parse(AssetsReader reader)
 {
     MetadataSize     = reader.ReadBEInt32();
     FileSize         = reader.ReadBEInt32();
     Version          = reader.ReadBEInt32();
     ObjectDataOffset = reader.ReadBEInt32();
     IsBigEndian      = reader.ReadBoolean();
     //padding apparently
     //reader.ReadBytes(3);
     reader.AlignTo(4);
 }
Esempio n. 4
0
            public void Parse(AssetsFile assetsFile, AssetsObject owner, AssetsReader reader)
            {
                Texture = SmartPtr <Texture2DObject> .Read(assetsFile, owner, reader);

                AlphaTexture = SmartPtr <Texture2DObject> .Read(assetsFile, owner, reader);

                SubMeshes   = reader.ReadArrayOf(r => new Submesh(reader));
                IndexBuffer = reader.ReadArray();
                reader.AlignTo(4);
                VertexData          = new VertexData(reader);
                BindPose            = reader.ReadArrayOf(r => r.ReadSingle());
                TextureRect         = new RectF(reader);
                TextureRectOffset   = new Vector2F(reader);
                AtlasRectOffset     = new Vector2F(reader);
                SettingsRaw         = reader.ReadUInt32();
                UVTransform         = new Vector4F(reader);
                DownscaleMultiplier = reader.ReadSingle();
            }
Esempio n. 5
0
        public override void ParseObject(AssetsReader reader)
        {
            Name          = reader.ReadString();
            Rect          = new RectF(reader);
            Offset        = new Vector2F(reader);
            Border        = new Vector4F(reader);
            PixelsToUnits = reader.ReadSingle();
            Pivot         = new Vector2F(reader);
            Extrude       = reader.ReadUInt32();
            IsPolygon     = reader.ReadBoolean();
            reader.AlignTo(4);
            RenderDataKey = new Map <Guid, long>(reader.ReadGuid(), reader.ReadInt64());
            AtlasTags     = reader.ReadArrayOf(r => r.ReadString());
            SpriteAtlas   = SmartPtr <AssetsObject> .Read(ObjectInfo.ParentFile, this, reader);

            RenderData   = new SpriteRenderData(ObjectInfo.ParentFile, this, reader);
            PhysicsShape = reader.ReadArrayOf(r => r.ReadArrayOf(r2 => new Vector2F(r2)));
            Bones        = reader.ReadArrayOf(r => (ISmartPtr <Transform>)SmartPtr <Transform> .Read(ObjectInfo.ParentFile, this, reader));
        }
Esempio n. 6
0
 private void Parse(AssetsReader reader)
 {
     FileID = reader.ReadInt32();
     reader.AlignTo(4);
     PathID = reader.ReadInt64();
 }