Beispiel #1
0
        public TypeTreeDataBase Merage(TypeTreeDataBase dataBase)
        {
            TypeTreeDataBase ret = new TypeTreeDataBase();

            int[] allVersion = dataBase.GetAllVersion();
            foreach (int version in allVersion)
            {
                var allType = dataBase.GetAllType(version);
                foreach (var kv in allType)
                {
                    var classID = kv.Key;
                    var type    = kv.Value;
                    ret.Put(version, classID, type);
                }
            }
            allVersion = GetAllVersion();
            foreach (int version in allVersion)
            {
                var allType = GetAllType(version);
                foreach (var kv in allType)
                {
                    var classID = kv.Key;
                    var type    = kv.Value;
                    ret.Put(version, classID, type);
                }
            }
            ret.regiserDefaultTypetyess();
            return(ret);
        }
Beispiel #2
0
        public static void SaveTypeTreeDataBase(string path, TypeTreeDataBase db)
        {
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);

            db.Serialize(fs);
            fs.Flush();
            fs.Dispose();
        }
Beispiel #3
0
 public void Extract(Asset asset, TypeTreeDataBase typeTreeDB, string outputPath, ExtractMode mode = ExtractMode.Auto)
 {
     foreach (var objinfo in asset.ObjectInfos)
     {
         string className = AssetToolUtility.ClassIDToClassName(objinfo.classID);
         var    path      = outputPath + "/Class " + objinfo.classID + " " + className + "/";
         var    typeTree  = typeTreeDB.GetType(asset.AssetVersion, objinfo.classID);
         ExtractObjct(objinfo, typeTree, outputPath, mode);
     }
 }
Beispiel #4
0
        public static TypeTreeDataBase LoadTypeTreeDataBase(string path)
        {
            TypeTreeDataBase db = new TypeTreeDataBase();

            try {
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read);
                db.DeSerialize(fs);
                fs.Dispose();
            } catch (Exception e) {
            }
            return(db);
        }
Beispiel #5
0
        static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV09 asset)
        {
            TypeTreeDataBase DB = new TypeTreeDataBase();

            foreach (var typetree in asset.typeTrees)
            {
                var tree = GenerateTypeTreeV9(typetree.rootType);
                DB.Put(9, typetree.ClassID, tree);
                //Console.WriteLine(tree);
            }
            return(DB);
        }
 public TypeTreeDataBase Merage(TypeTreeDataBase dataBase)
 {
     TypeTreeDataBase ret = new TypeTreeDataBase();
     int[] allVersion = dataBase.GetAllVersion();
     foreach (int version in allVersion) {
         var allType = dataBase.GetAllType(version);
         foreach (var kv in allType) {
             var classID = kv.Key;
             var type = kv.Value;
             ret.Put(version, classID, type);
         }
     }
     allVersion = GetAllVersion();
     foreach (int version in allVersion) {
         var allType = GetAllType(version);
         foreach (var kv in allType) {
             var classID = kv.Key;
             var type = kv.Value;
             ret.Put(version, classID, type);
         }
     }
     ret.regiserDefaultTypetyess();
     return ret;
 }
Beispiel #7
0
        static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset)
        {
            TypeTreeDataBase         DB            = new TypeTreeDataBase();
            Dictionary <int, string> typeNameTable = new Dictionary <int, string>();
            //一个共享的类型字符串表
            string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15");
            var    typeStrArray   = defaultTypeStr.Split('\n');
            int    startOffset    = 1 << 31;

            for (int i = 0; i < typeStrArray.Length; i++)
            {
                typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length - 1);
                startOffset += typeStrArray[i].Length;
            }

            foreach (var baseClass in asset.classes)
            {
                if (baseClass.stringTable == null)
                {
                    continue;
                }
                Dictionary <int, string> onwerStrTable = new Dictionary <int, string>();
                MemoryStream             ms            = new MemoryStream(baseClass.stringTable);
                DataReader data     = new DataReader(ms);
                TypeTree   rootType = new TypeTree();
                TypeTree   nodePrev = null;

                Dictionary <TypeTree, int> typeLevelDic = new Dictionary <TypeTree, int>();
                foreach (var field in baseClass.types)
                {
                    string name = "";
                    string type = "";
                    if (field.nameOffset < 0)
                    {
                        if (typeNameTable.ContainsKey(field.nameOffset))
                        {
                            name = typeNameTable[field.nameOffset];
                        }
                    }
                    else
                    {
                        data.position = field.nameOffset;
                        name          = data.ReadStringNull();
                    }

                    if (field.typeOffset < 0)
                    {
                        if (typeNameTable.ContainsKey(field.typeOffset))
                        {
                            type = typeNameTable[field.typeOffset];
                        }
                    }
                    else
                    {
                        data.position = field.typeOffset;
                        type          = data.ReadStringNull();
                    }

                    if (nodePrev == null)
                    {
                        rootType.name          = name;
                        rootType.type          = type;
                        rootType.metaFlag      = field.metaFlag;
                        nodePrev               = rootType;
                        typeLevelDic[nodePrev] = field.treeLevel;
                        continue;
                    }
                    TypeTree nodeCurr = new TypeTree();
                    nodeCurr.name          = name;
                    nodeCurr.type          = type;
                    nodeCurr.metaFlag      = field.metaFlag;
                    typeLevelDic[nodeCurr] = field.treeLevel;
                    int levels = typeLevelDic[nodePrev] - field.treeLevel;
                    if (levels >= 0)
                    {
                        for (int i = 0; i < levels; i++)
                        {
                            nodePrev = nodePrev.parent;
                        }
                        nodePrev.parent.AddChild(nodeCurr);
                    }
                    else
                    {
                        nodePrev.AddChild(nodeCurr);
                    }
                    nodePrev = nodeCurr;
                }
                DB.Put(15, baseClass.ClassID, rootType);
                Console.Write(rootType);
                data.Close();
                ms.Close();
            }
            return(DB);
        }
 public void Extract(Asset asset, TypeTreeDataBase typeTreeDB, string outputPath, ExtractMode mode = ExtractMode.Auto)
 {
     foreach (var objinfo in asset.ObjectInfos) {
         string className = AssetToolUtility.ClassIDToClassName(objinfo.classID);
         var path = outputPath + "/Class " +objinfo.classID+" "+ className+"/";
         var typeTree = typeTreeDB.GetType(asset.AssetVersion, objinfo.classID);
         ExtractObjct(objinfo, typeTree, outputPath, mode);
     }     
 }
 public static void SaveTypeTreeDataBase(string path, TypeTreeDataBase db)
 {
     FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
     db.Serialize(fs);
     fs.Flush();
     fs.Dispose();
 }
        public static TypeTreeDataBase LoadTypeTreeDataBase(string path)
        {
            TypeTreeDataBase db = new TypeTreeDataBase();
            try {
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read);
                db.DeSerialize(fs);
                fs.Dispose();
            } catch (Exception e) {

            }
            return db;
        }
 static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV09 asset)
 {
     TypeTreeDataBase DB = new TypeTreeDataBase();
     foreach (var typetree in asset.typeTrees) {
         var tree = GenerateTypeTreeV9(typetree.rootType);
         DB.Put(9, typetree.ClassID, tree);
         //Console.WriteLine(tree);     
     }
     return DB;
 }
        static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset)
        {

            TypeTreeDataBase DB = new TypeTreeDataBase();
            Dictionary<int, string> typeNameTable = new Dictionary<int, string>();
            //一个共享的类型字符串表
            string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15");
            var typeStrArray = defaultTypeStr.Split('\n');
            int startOffset = 1 << 31;
            for (int i = 0; i < typeStrArray.Length; i++) {
                typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length-1);
                startOffset += typeStrArray[i].Length;
            }

            foreach (var baseClass in asset.classes) {
                if (baseClass.stringTable == null) continue;
                Dictionary<int, string> onwerStrTable = new Dictionary<int, string>();
                MemoryStream ms = new MemoryStream(baseClass.stringTable);
                DataReader data = new DataReader(ms);
                TypeTree rootType = new TypeTree();
                TypeTree nodePrev = null;
                
                Dictionary<TypeTree, int> typeLevelDic = new Dictionary<TypeTree, int>();
                foreach (var field in baseClass.types) {
                    string name = "";
                    string type = "";
                    if (field.nameOffset < 0) {
                        if (typeNameTable.ContainsKey(field.nameOffset)) {
                            name = typeNameTable[field.nameOffset];
                        }
                    } else {
                        data.position = field.nameOffset;
                        name = data.ReadStringNull();
                    }

                    if (field.typeOffset < 0) {
                        if (typeNameTable.ContainsKey(field.typeOffset)) {
                            type = typeNameTable[field.typeOffset];
                        }
                    } else {
                        data.position = field.typeOffset;
                        type = data.ReadStringNull();
                    }

                    if (nodePrev == null) {
                        rootType.name = name;
                        rootType.type = type;
                        rootType.metaFlag = field.metaFlag;
                        nodePrev = rootType;
                        typeLevelDic[nodePrev] = field.treeLevel;
                        continue;
                    }
                    TypeTree nodeCurr = new TypeTree();
                    nodeCurr.name = name;
                    nodeCurr.type = type;
                    nodeCurr.metaFlag = field.metaFlag;
                    typeLevelDic[nodeCurr] = field.treeLevel;
                    int levels = typeLevelDic[nodePrev] - field.treeLevel;
                    if (levels >= 0) {
                        for (int i = 0; i < levels; i++) {
                            nodePrev = nodePrev.parent;
                        }
                        nodePrev.parent.AddChild(nodeCurr);
                    } else {
                        nodePrev.AddChild(nodeCurr);
                    }
                    nodePrev = nodeCurr;
                }
                DB.Put(15, baseClass.ClassID, rootType);
                Console.Write(rootType);
                data.Close();
                ms.Close();
            }
            return DB;
        }