Exemplo n.º 1
0
Arquivo: u3d.cs Projeto: Klanly/ncnn
        SerializedFile MakeDependency(string key)
        {
            key = key.Replace("library/", "resources/").ToLower();
            SerializedFile sf;

            if (UnityAsset.Assets.TryGetValue(key, out sf))
            {
                return(sf);
            }
            else
            {
                sf = new SerializedFile();
                UnityAsset.Assets[key] = sf;
                return(sf);
            }
        }
Exemplo n.º 2
0
Arquivo: u3d.cs Projeto: Klanly/ncnn
        public static unsafe SerializedFile Create(string GameBase, string asset)
        {
            string path = asset;

            if (GameBase != null)
            {
                path = GameBase + '\\' + asset;
            }
            else if (UnityYAMLAsset.GameBase != null)
            {
                path = UnityYAMLAsset.GameBase + '\\' + asset;
            }

            SerializedFile sf = null;

            return(Create(path, sf));
        }
Exemplo n.º 3
0
Arquivo: u3d.cs Projeto: Klanly/ncnn
        static void chkr(string path, string pathkey)
        {
            SerializedFile sery = null;

            if (Assets.TryGetValue(pathkey, out sery))
            {
                if (sery.Header == null)
                {
                    SerializedFile.Create(path, sery);
                }
            }
            else
            {
                sery = SerializedFile.Create(path, sery);
                if (sery != null)
                {
                    Assets[pathkey] = sery;
                }
            }
        }
Exemplo n.º 4
0
 public uMeta(SerializedFile ser)
 {
     src = ser;
 }
Exemplo n.º 5
0
Arquivo: u3d.cs Projeto: Klanly/ncnn
        public static unsafe SerializedFile Create(string path, SerializedFile src)
        {
            Stream reader = File.OpenRead(path);

            if (reader.Length < 0x14)
            {
                reader.Close();
                return(null);
            }

            byte[] buf = reader.ReadBytes(0x30, 0, 0x14);

            ABheader abhh = null;

            if (buf.ru4(0) == 0x74696e55)
            {
                abhh   = new ABheader(reader);
                reader = abhh.reNewReader();

                buf = reader.ReadBytes(0x30, 0, 0x14);
            }

            var tmpHeader = new SerializedFileHeader();

            fixed(byte *srcbb = &buf[0])
            {
                bswap *bs  = (bswap *)srcbb;
                uint   ver = bs[2]._1u();

                tmpHeader.m_Version   = ver;
                tmpHeader.m_Endianess = bs[4];
                if (ver >= 0x16)
                {
                    reader.Read(buf, 0x14, 0x1C);
                    bswap8 *bs8 = (bswap8 *)srcbb;

                    tmpHeader.v16h_0 = bs8[0];
                    tmpHeader.v16h_C = bs[3];

                    tmpHeader.m_MetadataSize = bs[5]._1u();
                    tmpHeader.m_FileSize     = bs8[3]._1u();
                    tmpHeader.m_DataOffset   = bs8[4]._1i();

                    tmpHeader.v16h_28 = bs[10];
                    tmpHeader.v16h_2C = bs[11];
                }
                else
                {
                    tmpHeader.m_MetadataSize = bs[0]._1u();
                    tmpHeader.m_FileSize     = bs[1]._1u();

                    tmpHeader.m_DataOffset = bs[3]._1u();
                    if (ver < 9)
                    {
                    }
                }
            }

            long cur = reader.Length;

            if (tmpHeader.m_MetadataSize >= cur || tmpHeader.m_DataOffset >= cur)
            {
                return(null);
            }


            //if(abhh.resSraw<0)
            //	abhh.resSloc(tmpHeader.m_FileSize);


            if (src == null)
            {
                return(new SerializedFile(reader, tmpHeader, abhh));
            }
            else
            {
                src.Load(reader, tmpHeader, abhh);
                return(src);
            }
        }
Exemplo n.º 6
0
Arquivo: u3d.cs Projeto: Klanly/ncnn
        //static bswap bswapy;
        unsafe void MetaParse(Stream reader, bool isBE)
        {
            int cur = 5;

            byte[] buf = reader.ReadBytes(cur);

            ReaderLE drd;

            if (isBE)
            {
                drd = new ReaderBE(buf);
            }
            else
            {
                drd = new ReaderLE(buf);
            }

            if (Header.m_Version >= 8)
            {
                cur -= 4;
                m_TargetPlatform = (BuildTarget)drd.ri4c();
            }
            if (Header.m_Version >= 13)
            {
                cur -= 1;
                m_EnableTypeTree = (buf[4] > 0);
            }

            if (cur != 0)
            {
                reader.Position -= cur;
            }

            cur = 0;
            buf = reader.ReadBytes((int)(Header.m_MetadataSize + rStart[0] - reader.Position));

            fixed(byte *srcbb = &buf[0])
            {
                drd.Reload(srcbb);

                int typCount = drd.ri4cp();

                m_Types = new SerializedType[typCount];
                for (int i = 0; i < typCount; i++)
                {
                    m_Types[i] = TypeParse(drd);
                }


                int bigIDEnabled = 0;

                if (Header.m_Version >= 7 && Header.m_Version < 14)
                {
                    bigIDEnabled = drd.ri4cp();
                }

                int objectCount = drd.ri4cp();

                rStart[1]  = (int)(reader.Position - buf.Length - rStart[0] + drd.seek);
                cur        = Extensionnyaa.mod4less(rStart[1]);
                drd.seek  += cur;
                rStart[1] += cur;                 // rstart[0]+rstart[1] = abs offset to metas

                long vprs = Header.m_DataOffset;

                if (isAB != null)
                {
                    vprs += isAB.ABHsize;
                }

                int syz = 0x14;

                cur = 0;
                if (Header.m_Version >= 22)
                {
                    syz = 0x18;
                    cur = 2;                     //u20
                }
                else if (Header.m_Version < 16)
                {
                    cur = 1;                     //u4
                }

                byte *du = drd.ReadTcp(0);

                if (cur == 0)
                {
                    for (int i = 0; i < objectCount; i++)
                    {
                        uMetaStruct ynfo = *(uMetaStruct *)du;

                        var meta = GetNewuMeta(ynfo.PathID);

                        meta.Offset  = ynfo.Offset + vprs;
                        meta.Size    = ynfo.Size;
                        meta.MB_type = m_Types[ynfo.TypeID];
                        meta.ClassID = meta.MB_type.classID;

                        du += syz;
                    }
                }
                else
                {
                    for (int i = 0; i < objectCount; i++)
                    {
                        uMetaStruct ynfo = *(uMetaStruct *)du;


                        if (cur == 1)
                        {
                            var meta = GetNewuMeta((long)ynfo.PathID_u4);


                            meta.Offset = ynfo.Offset_u4 + vprs;
                            meta.Size   = ynfo.Size_u4;
                            //meta.MB_type = m_Types[ynfo.TypeID];
                            meta.ClassID = (ClassIDType)ynfo.ClassID_u4;
                        }
                        else if (cur == 2)
                        {
                            var meta = GetNewuMeta(ynfo.PathID);
                            meta.Offset  = ynfo.Offset_u20 + vprs;
                            meta.Size    = ynfo.Size_u20;
                            meta.MB_type = m_Types[ynfo.TypeID_u20];
                            meta.ClassID = meta.MB_type.classID;
                        }


                        du += syz;
                    }
                }

                drd.seek += syz * objectCount;

                if (Header.m_Version >= 11)
                {
                    syz           = 0xc;
                    objectCount   = drd.ri4cp();
                    m_ScriptTypes = new LocalSerializedObjectIdentifierStruct[objectCount];
                    for (int i = 0; i < objectCount; i++)
                    {
                        m_ScriptTypes[i] = *(LocalSerializedObjectIdentifierStruct *)drd.ReadTcp(syz);
                    }

                    drd.seek += syz * objectCount;
                }

                objectCount = drd.ri4cp();

                Dependency = new SerializedFile[objectCount];

                for (int i = 0; i < objectCount; i++)
                {
                    string         nzstr = drd.rStrp();
                    yGUID          yg    = *(yGUID *)drd.ReadTcp(16);
                    int            tpp   = drd.ri4cp();
                    SerializedFile dp    = MakeDependency(drd.rStrp());

                    dp.setLinked(nzstr, tpp, yg);

                    Dependency[i] = dp;
                }
            }
        }