示例#1
0
文件: Loader.cs 项目: CyberSys/UTA
        private void Awake()
        {
            if (HasLoaded)
            {
                return;
            }

            var archivePaths = Config.GetPaths("archive_paths");

            IArchive[] archives;
            using (Utilities.Profiler.Start("Archive load time")) {
                archives = archivePaths.Select(x =>
                                               File.Exists(x) ? (IArchive)ArchiveManager.LoadImageArchive(x)
                    : Directory.Exists(x) ? ArchiveManager.LoadLooseArchive(x)
                    : null).Where(x => x != null).ToArray();
            }

            using (Utilities.Profiler.Start("Collision load time")) {
                foreach (var archive in archives)
                {
                    foreach (var colFile in archive.GetFileNamesWithExtension(".col"))
                    {
                        CollisionFile.Load(colFile);
                    }
                }
            }

            using (Utilities.Profiler.Start("Item info load time")) {
                foreach (var path in Config.GetPaths("item_paths"))
                {
                    var ext = Path.GetExtension(path).ToLower();
                    switch (ext)
                    {
                    case ".dat":
                        Item.ReadLoadList(path); break;

                    case ".ide":
                        Item.ReadIde(path); break;

                    case ".ipl":
                        Item.ReadIpl(path); break;
                    }
                }
            }

            using (Utilities.Profiler.Start("Handling info load time")) {
                Handling.Load(Config.GetPath("handling_path"));
            }

            using (Utilities.Profiler.Start("Animation group info load time")) {
                foreach (var path in Config.GetPaths("anim_groups_paths"))
                {
                    AnimationGroup.Load(path);
                }
            }

            using (Utilities.Profiler.Start("Car color info load time")) {
                CarColors.Load(Config.GetPath("car_colors_path"));
            }

            HasLoaded = true;
        }
示例#2
0
 private static void StepLoadCarColors()
 {
     CarColors.Load(ArchiveManager.PathToCaseSensitivePath(Config.GetPath("car_colors_path")));
 }
示例#3
0
        static void StaticUpdate()
        {
            if (HasLoaded)
            {
                return;
            }

            switch (loadingStatus)
            {
            case 0:
                Debug.Log("Started loading GTA.");
                archivePaths = Config.GetPaths("archive_paths");
                break;

            case 1:
                using (Utilities.Profiler.Start("Archive load time")) {
                    List <IArchive> listArchives = new List <IArchive> ();
                    foreach (var path in archivePaths)
                    {
                        if (File.Exists(path))
                        {
                            listArchives.Add(ArchiveManager.LoadImageArchive(path));
                        }
                        else if (Directory.Exists(path))
                        {
                            listArchives.Add(ArchiveManager.LoadLooseArchive(path));
                        }
                        else
                        {
                            Debug.Log("Archive not found: " + path);
                        }
                    }
                    archives = listArchives.FindAll(a => a != null).ToArray();
                }
                break;

            case 2:
                using (Utilities.Profiler.Start("Collision load time")) {
                    int numCollisionFiles = 0;
                    foreach (var archive in archives)
                    {
                        foreach (var colFile in archive.GetFileNamesWithExtension(".col"))
                        {
                            CollisionFile.Load(colFile);
                            numCollisionFiles++;
                        }
                    }
                    Debug.Log("Number of collision files " + numCollisionFiles);
                }
                break;

            case 3:
                using (Utilities.Profiler.Start("Item info load time")) {
                    foreach (var path in Config.GetPaths("item_paths"))
                    {
                        var ext = Path.GetExtension(path).ToLower();
                        switch (ext)
                        {
                        case ".dat":
                            Item.ReadLoadList(path);
                            break;

                        case ".ide":
                            Item.ReadIde(path);
                            break;

                        case ".ipl":
                            Item.ReadIpl(path);
                            break;
                        }
                    }
                }
                break;

            case 4:
                using (Utilities.Profiler.Start("Handling info load time")) {
                    Handling.Load(Config.GetPath("handling_path"));
                }
                break;

            case 5:
                using (Utilities.Profiler.Start("Animation group info load time")) {
                    foreach (var path in Config.GetPaths("anim_groups_paths"))
                    {
                        AnimationGroup.Load(path);
                    }
                }
                break;

            case 6:
                using (Utilities.Profiler.Start("Car color info load time")) {
                    CarColors.Load(Config.GetPath("car_colors_path"));
                }
                break;

            case 7:
                using (Utilities.Profiler.Start("special texture load time")) {
                    MiniMap.loadTextures();

                    // Load mouse cursor texture
                    Texture2D mouse    = TextureDictionary.Load("fronten_pc").GetDiffuse("mouse").Texture;
                    Texture2D mouseFix = new Texture2D(mouse.width, mouse.height);
                    for (int x = 0; x < mouse.width; x++)
                    {
                        for (int y = 0; y < mouse.height; y++)
                        {
                            mouseFix.SetPixel(x, mouse.height - y - 1, mouse.GetPixel(x, y));
                        }
                    }
                    mouseFix.Apply();
                    Cursor.SetCursor(mouseFix, Vector2.zero, CursorMode.Auto);
                }
                HasLoaded = true;
                Debug.Log("GTA loading finished.");
                break;
            }

            loadingStatus++;
        }
示例#4
0
 private static void StepLoadCarColors()
 {
     CarColors.Load(Config.GetPath("car_colors_path"));
 }
示例#5
0
        static void StaticUpdate()
        {
                        #if UNITY_EDITOR
            if (!EditorApplication.isPlaying && !HasLoaded)
            {
                // display loading progress in editor
            }
                        #endif

            if (HasLoaded)
            {
                return;
            }


            switch (loadingStatus)
            {
            case 0:

                Debug.Log("Started loading GTA.");

                archivePaths = Config.GetPaths("archive_paths");

                break;

            case 1:

                using (Utilities.Profiler.Start("Archive load time")) {
                    List <IArchive> listArchives = new List <IArchive> ();
                    foreach (var path in archivePaths)
                    {
                        if (File.Exists(path))
                        {
                            listArchives.Add(ArchiveManager.LoadImageArchive(path));
                        }
                        else if (Directory.Exists(path))
                        {
                            listArchives.Add(ArchiveManager.LoadLooseArchive(path));
                        }
                        else
                        {
                            Debug.Log("Archive not found: " + path);
                        }
                    }
                    archives = listArchives.FindAll(a => a != null).ToArray();
                }

                break;

            case 2:

                using (Utilities.Profiler.Start("Collision load time")) {
                    int numCollisionFiles = 0;
                    foreach (var archive in archives)
                    {
                        foreach (var colFile in archive.GetFileNamesWithExtension(".col"))
                        {
                            CollisionFile.Load(colFile);
                            numCollisionFiles++;
                        }
                    }
                    Debug.Log("Number of collision files " + numCollisionFiles);
                }

                break;

            case 3:

                using (Utilities.Profiler.Start("Item info load time")) {
                    foreach (var path in Config.GetPaths("item_paths"))
                    {
                        var ext = Path.GetExtension(path).ToLower();
                        switch (ext)
                        {
                        case ".dat":
                            Item.ReadLoadList(path);
                            break;

                        case ".ide":
                            Item.ReadIde(path);
                            break;

                        case ".ipl":
                            Item.ReadIpl(path);
                            break;
                        }
                    }
                }

                break;

            case 4:

                using (Utilities.Profiler.Start("Handling info load time")) {
                    Handling.Load(Config.GetPath("handling_path"));
                }

                break;

            case 5:

                using (Utilities.Profiler.Start("Animation group info load time")) {
                    foreach (var path in Config.GetPaths("anim_groups_paths"))
                    {
                        AnimationGroup.Load(path);
                    }
                }

                break;

            case 6:

                using (Utilities.Profiler.Start("Car color info load time")) {
                    CarColors.Load(Config.GetPath("car_colors_path"));
                }

                HasLoaded = true;

                Debug.Log("GTA loading finished.");

                break;
            }

            loadingStatus++;
        }