Esempio n. 1
0
        public void Load()
        {
            using (new Timing("Loading " + Version.GetFormatedGTAName(true)))
                using (new TempCultureInfo(CultureInfo.InvariantCulture))
                    using (new MemoryCounter())
                        using (var workingFolder = new TempWorkingFolder(Path))
                            using (var progress = new ProgressBar("Loading " + Version.GetFormatedGTAName() + " map", 0, workingFolder, 32))
                                try {
                                    DefaultData  = DataFile.GetMainData(Version);
                                    SpecificData = DataFile.GetVersionSpecificData(Version);

                                    Gta3img = ImgFile.GetMainImg(Version);

                                    IdeCollection = new DefinitionCollection()
                                    {
                                        DefaultData, SpecificData
                                    };
                                    IplCollection = new PlacementCollection()
                                    {
                                        DefaultData, SpecificData, Gta3img
                                    };
                                    TxdCollection = new TextureCollection()
                                    {
                                        DefaultData, SpecificData, Gta3img
                                    };
                                    ModelCollection = new ModelCollection()
                                    {
                                        DefaultData, SpecificData, Gta3img
                                    };

                                    TxdCollection.AddTextureParent(DefaultData);
                                    TxdCollection.AddTextureParent(SpecificData);

                                    //ItemDefinition.TransformModifiers += SetStatic;
                                    progress.Count = IplCollection.AllPlacements.Count();

                                    foreach (var placement in IplCollection)
                                    {
                                        Place(placement, progress);

                                        if (progress.Canceled)
                                        {
                                            return;
                                        }
                                    }

                                    if (!Camera.main.GetComponent <FreeCamera>())
                                    {
                                        Camera.main.gameObject.AddComponent <FreeCamera>();
                                    }
                                    if (!Camera.main.GetComponent <CameraLod>())
                                    {
                                        Camera.main.gameObject.AddComponent <CameraLod>();
                                    }
                                }
                                catch (Exception e) {
                                    Log.Error("FAILED TO LOAD");
                                    Log.Exception(e);
                                }finally {
                ItemDefinition.TransformModifiers -= SetStatic;
                #if UNITY_EDITOR
                UnityEditor.Lightmapping.bakedGI    = false;
                UnityEditor.Lightmapping.realtimeGI = false;
                UnityEditor.EditorApplication.Beep();
                #endif
            }
        }