Exemplo n.º 1
0
 public static LoadedContentItem <T> LoadItem(VirtualFile file)
 {
     try
     {
         if (typeof(T) == typeof(string))
         {
             return(new LoadedContentItem <T>(file, (T)(object)file.ReadAllText()));
         }
         if (typeof(T) == typeof(Texture2D))
         {
             return(new LoadedContentItem <T>(file, (T)(object)LoadTexture(file)));
         }
         if (typeof(T) == typeof(AudioClip))
         {
             if (Prefs.LogVerbose)
             {
                 DeepProfiler.Start("Loading file " + file);
             }
             IDisposable extraDisposable = null;
             T           val;
             try
             {
                 string uri = GenFilePaths.SafeURIForUnityWWWFromPath(file.FullPath);
                 using UnityWebRequest unityWebRequest = UnityWebRequestMultimedia.GetAudioClip(uri, GetAudioTypeFromURI(uri));
                 unityWebRequest.SendWebRequest();
                 while (!unityWebRequest.isDone)
                 {
                     Thread.Sleep(1);
                 }
                 if (unityWebRequest.error != null)
                 {
                     throw new InvalidOperationException(unityWebRequest.error);
                 }
                 val = (T)(object)DownloadHandlerAudioClip.GetContent(unityWebRequest);
             }
             finally
             {
                 if (Prefs.LogVerbose)
                 {
                     DeepProfiler.End();
                 }
             }
             UnityEngine.Object @object = val as UnityEngine.Object;
             if (@object != null)
             {
                 @object.name = Path.GetFileNameWithoutExtension(file.Name);
             }
             return(new LoadedContentItem <T>(file, val, extraDisposable));
         }
     }
     catch (Exception ex)
     {
         Log.Error(string.Concat("Exception loading ", typeof(T), " from file.\nabsFilePath: ", file.FullPath, "\nException: ", ex.ToString()));
     }
     if (typeof(T) == typeof(Texture2D))
     {
         return((LoadedContentItem <T>)(object) new LoadedContentItem <Texture2D>(file, BaseContent.BadTex));
     }
     return(null);
 }
Exemplo n.º 2
0
 private static void ExecuteToExecuteWhenFinished()
 {
     if (executingToExecuteWhenFinished)
     {
         Log.Warning("Already executing.");
         return;
     }
     executingToExecuteWhenFinished = true;
     if (toExecuteWhenFinished.Count > 0)
     {
         DeepProfiler.Start("ExecuteToExecuteWhenFinished()");
     }
     for (int i = 0; i < toExecuteWhenFinished.Count; i++)
     {
         DeepProfiler.Start(toExecuteWhenFinished[i].Method.DeclaringType.ToString() + " -> " + toExecuteWhenFinished[i].Method.ToString());
         try
         {
             toExecuteWhenFinished[i]();
         }
         catch (Exception arg)
         {
             Log.Error("Could not execute post-long-event action. Exception: " + arg);
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     if (toExecuteWhenFinished.Count > 0)
     {
         DeepProfiler.End();
     }
     toExecuteWhenFinished.Clear();
     executingToExecuteWhenFinished = false;
 }
Exemplo n.º 3
0
 public static void GenerateContentsIntoMap(IEnumerable <GenStepDef> genStepDefs, Map map)
 {
     Rand.Seed = Gen.HashCombineInt(Find.World.info.Seed, map.Tile);
     MapGenerator.data.Clear();
     RockNoises.Init(map);
     foreach (GenStepDef current in from x in genStepDefs
              orderby x.order, x.index
              select x)
     {
         DeepProfiler.Start("GenStep - " + current);
         try
         {
             current.genStep.Generate(map);
         }
         catch (Exception arg)
         {
             Log.Error("Error in GenStep: " + arg);
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     Rand.RandomizeStateFromTime();
     RockNoises.Reset();
     MapGenerator.data.Clear();
 }
Exemplo n.º 4
0
        private void LoadPatches()
        {
            DeepProfiler.Start("Loading all patches");
            patches          = new List <PatchOperation>();
            loadedAnyPatches = false;
            List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(this, "Patches/").ToList();

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement documentElement = list[i].xmlDoc.DocumentElement;
                if (documentElement.Name != "Patch")
                {
                    Log.Error($"Unexpected document element in patch XML; got {documentElement.Name}, expected 'Patch'");
                    continue;
                }
                foreach (XmlNode childNode in documentElement.ChildNodes)
                {
                    if (childNode.NodeType == XmlNodeType.Element)
                    {
                        if (childNode.Name != "Operation")
                        {
                            Log.Error($"Unexpected element in patch XML; got {childNode.Name}, expected 'Operation'");
                            continue;
                        }
                        PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(childNode, doPostLoad: false);
                        patchOperation.sourceFile = list[i].FullFilePath;
                        patches.Add(patchOperation);
                        loadedAnyPatches = true;
                    }
                }
            }
            DeepProfiler.End();
        }
        public bool Apply(XmlDocument xml)
        {
            if (DeepProfiler.enabled)
            {
                DeepProfiler.Start(GetType().FullName + " Worker");
            }
            bool flag = ApplyWorker(xml);

            if (DeepProfiler.enabled)
            {
                DeepProfiler.End();
            }
            if (success == Success.Always)
            {
                flag = true;
            }
            else if (success == Success.Never)
            {
                flag = false;
            }
            else if (success == Success.Invert)
            {
                flag = !flag;
            }
            if (flag)
            {
                neverSucceeded = false;
            }
            return(flag);
        }
Exemplo n.º 6
0
        public static List <LoadableXmlAsset> LoadModXML()
        {
            List <LoadableXmlAsset> list = new List <LoadableXmlAsset>();

            for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
            {
                ModContentPack modContentPack = LoadedModManager.runningMods[i];
                DeepProfiler.Start("Loading " + modContentPack);
                try
                {
                    list.AddRange(modContentPack.LoadDefs());
                }
                catch (Exception ex)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Could not load defs for mod ",
                        modContentPack.Identifier,
                        ": ",
                        ex
                    }), false);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            return(list);
        }
 public static void ResolveAllWantedCrossReferences(FailMode failReportMode)
 {
     DeepProfiler.Start("ResolveAllWantedCrossReferences");
     try
     {
         HashSet <WantedRef> resolvedRefs = new HashSet <WantedRef>();
         object resolvedRefsLock          = new object();
         DeepProfiler.enabled = false;
         GenThreading.ParallelForEach(wantedRefs, delegate(WantedRef wantedRef)
         {
             if (wantedRef.TryResolve(failReportMode))
             {
                 lock (resolvedRefsLock)
                 {
                     resolvedRefs.Add(wantedRef);
                 }
             }
         });
         foreach (WantedRef item in resolvedRefs)
         {
             item.Apply();
         }
         wantedRefs.RemoveAll((WantedRef x) => resolvedRefs.Contains(x));
         DeepProfiler.enabled = true;
     }
     finally
     {
         DeepProfiler.End();
     }
 }
Exemplo n.º 8
0
 public static LoadedContentItem <T> LoadItem(VirtualFile file)
 {
     try
     {
         if (typeof(T) == typeof(string))
         {
             return(new LoadedContentItem <T>(file, (T)(object)file.ReadAllText()));
         }
         if (typeof(T) == typeof(Texture2D))
         {
             return(new LoadedContentItem <T>(file, (T)(object)LoadTexture(file)));
         }
         if (typeof(T) == typeof(AudioClip))
         {
             if (Prefs.LogVerbose)
             {
                 DeepProfiler.Start("Loading file " + file);
             }
             IDisposable extraDisposable = null;
             T           val;
             try
             {
                 bool   doStream = ShouldStreamAudioClipFromFile(file);
                 Stream stream   = file.CreateReadStream();
                 try
                 {
                     val = (T)(object)RuntimeAudioClipLoader.Manager.Load(stream, GetFormat(file.Name), file.Name, doStream);
                 }
                 catch (Exception)
                 {
                     stream.Dispose();
                     throw;
                 }
                 extraDisposable = stream;
             }
             finally
             {
                 if (Prefs.LogVerbose)
                 {
                     DeepProfiler.End();
                 }
             }
             UnityEngine.Object @object = val as UnityEngine.Object;
             if (@object != null)
             {
                 @object.name = Path.GetFileNameWithoutExtension(file.Name);
             }
             return(new LoadedContentItem <T>(file, val, extraDisposable));
         }
     }
     catch (Exception ex2)
     {
         Log.Error("Exception loading " + typeof(T) + " from file.\nabsFilePath: " + file.FullPath + "\nException: " + ex2.ToString());
     }
     if (typeof(T) == typeof(Texture2D))
     {
         return((LoadedContentItem <T>)(object) new LoadedContentItem <Texture2D>(file, BaseContent.BadTex));
     }
     return(null);
 }
        public static void LoadGameFromSaveFile(string fileName)
        {
            string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods
                                             select mod.ToString(), true);

            Log.Message("Loading game from file " + fileName + " with mods " + str);
            DeepProfiler.Start("Loading game from file " + fileName);
            Current.Game = new Game();
            DeepProfiler.Start("InitLoading (read file)");
            Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName));
            DeepProfiler.End();
            ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true);
            if (Scribe.EnterNode("game"))
            {
                Current.Game = new Game();
                Current.Game.LoadGame();
                PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName);
                DeepProfiler.End();
            }
            else
            {
                Log.Error("Could not find game XML node.");
                Scribe.ForceStop();
            }
        }
Exemplo n.º 10
0
 public static void Start(string label = null)
 {
     if (Prefs.LogVerbose)
     {
         DeepProfiler.Get().Start(label);
     }
 }
Exemplo n.º 11
0
        public static void InitializeMods()
        {
            int num = 0;

            foreach (ModMetaData item2 in ModsConfig.ActiveModsInLoadOrder.ToList())
            {
                DeepProfiler.Start("Initializing " + item2);
                try
                {
                    if (!item2.RootDir.Exists)
                    {
                        ModsConfig.SetActive(item2.PackageId, active: false);
                        Log.Warning("Failed to find active mod " + item2.Name + "(" + item2.PackageIdPlayerFacing + ") at " + item2.RootDir);
                    }
                    else
                    {
                        ModContentPack item = new ModContentPack(item2.RootDir, item2.PackageId, item2.PackageIdPlayerFacing, num, item2.Name);
                        num++;
                        runningMods.Add(item);
                    }
                }
                catch (Exception arg)
                {
                    Log.Error("Error initializing mod: " + arg);
                    ModsConfig.SetActive(item2.PackageId, active: false);
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
        }
Exemplo n.º 12
0
        public static void LoadGameFromSaveFileNow(string fileName)
        {
            string str = (from mod in LoadedModManager.RunningMods
                          select mod.ToString()).ToCommaList();

            Log.Message("Loading game from file " + fileName + " with mods " + str);
            DeepProfiler.Start("Loading game from file " + fileName);
            Current.Game = new Game();
            DeepProfiler.Start("InitLoading (read file)");
            Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName));
            DeepProfiler.End();
            try
            {
                ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true);
                if (!Scribe.EnterNode("game"))
                {
                    Log.Error("Could not find game XML node.");
                    Scribe.ForceStop();
                    return;
                }
                Current.Game = new Game();
                Current.Game.LoadGame();
            }
            catch (Exception)
            {
                Scribe.ForceStop();
                throw;
            }
            PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName);
            DeepProfiler.End();
        }
Exemplo n.º 13
0
        public static IEnumerable <LoadedContentItem <T> > LoadAllForMod(ModContentPack mod)
        {
            string        contentDirPath = Path.Combine(mod.RootDir, GenFilePaths.ContentPath <T>());
            DirectoryInfo contentDir     = new DirectoryInfo(contentDirPath);

            if (contentDir.Exists)
            {
                DeepProfiler.Start(string.Concat(new object[]
                {
                    "Loading assets of type ",
                    typeof(T),
                    " for mod ",
                    mod
                }));
                FileInfo[] files = contentDir.GetFiles("*.*", SearchOption.AllDirectories);
                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file = files[i];
                    if (ModContentLoader <T> .IsAcceptableExtension(file.Extension))
                    {
                        LoadedContentItem <T> loadedItem = ModContentLoader <T> .LoadItem(file.FullName, contentDirPath);

                        if (loadedItem != null)
                        {
                            yield return(loadedItem);
                        }
                    }
                }
                DeepProfiler.End();
            }
        }
Exemplo n.º 14
0
 public static void End()
 {
     if (Prefs.LogVerbose)
     {
         DeepProfiler.Get().End();
     }
 }
Exemplo n.º 15
0
 public static void LoadModContent()
 {
     for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
     {
         ModContentPack modContentPack = LoadedModManager.runningMods[i];
         DeepProfiler.Start("Loading " + modContentPack + " content");
         try
         {
             modContentPack.ReloadContent();
         }
         catch (Exception ex)
         {
             Log.Error(string.Concat(new object[]
             {
                 "Could not reload mod content for mod ",
                 modContentPack.Identifier,
                 ": ",
                 ex
             }), false);
         }
         finally
         {
             DeepProfiler.End();
         }
     }
 }
 public static T TryResolveDef <T>(string defName, FailMode failReportMode, object debugWanterInfo = null)
 {
     DeepProfiler.Start("TryResolveDef");
     try
     {
         T val = (T)(object)GenDefDatabase.GetDefSilentFail(typeof(T), defName);
         if (val != null)
         {
             return(val);
         }
         if (failReportMode == FailMode.LogErrors)
         {
             string text = string.Concat("Could not resolve cross-reference to ", typeof(T), " named ", defName);
             if (debugWanterInfo != null)
             {
                 text = text + " (wanter=" + debugWanterInfo.ToStringSafe() + ")";
             }
             Log.Error(text);
         }
         return(default(T));
     }
     finally
     {
         DeepProfiler.End();
     }
 }
Exemplo n.º 17
0
        public static IEnumerable <LoadedContentItem <T> > LoadAllForMod(ModContentPack mod)
        {
            string        contentDirPath = Path.Combine(mod.RootDir, GenFilePaths.ContentPath <T>());
            DirectoryInfo contentDir     = new DirectoryInfo(contentDirPath);

            if (contentDir.Exists)
            {
                DeepProfiler.Start("Loading assets of type " + typeof(T) + " for mod " + mod);
                FileInfo[] files = contentDir.GetFiles("*.*", SearchOption.AllDirectories);
                foreach (FileInfo file in files)
                {
                    if (IsAcceptableExtension(file.Extension))
                    {
                        LoadedContentItem <T> loadedItem = LoadItem(file.FullName, contentDirPath);
                        if (loadedItem != null)
                        {
                            yield return(loadedItem);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
                DeepProfiler.End();
            }
        }
        public static void InitializeMods()
        {
            int num = 0;

            foreach (ModMetaData modMetaData in ModsConfig.ActiveModsInLoadOrder.ToList <ModMetaData>())
            {
                DeepProfiler.Start("Initializing " + modMetaData);
                if (!modMetaData.RootDir.Exists)
                {
                    ModsConfig.SetActive(modMetaData.Identifier, false);
                    Log.Warning(string.Concat(new object[]
                    {
                        "Failed to find active mod ",
                        modMetaData.Name,
                        "(",
                        modMetaData.Identifier,
                        ") at ",
                        modMetaData.RootDir
                    }), false);
                    DeepProfiler.End();
                }
                else
                {
                    ModContentPack item = new ModContentPack(modMetaData.RootDir, num, modMetaData.Name);
                    num++;
                    LoadedModManager.runningMods.Add(item);
                    DeepProfiler.End();
                }
            }
        }
Exemplo n.º 19
0
 public static void ResolveAllReferences(bool onlyExactlyMyType = true, bool parallel = false)
 {
     DeepProfiler.Start("SetIndices");
     try
     {
         SetIndices();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("ResolveAllReferences " + typeof(T).FullName);
     try
     {
         Action <T> action = delegate(T def)
         {
             if (!onlyExactlyMyType || !(def.GetType() != typeof(T)))
             {
                 DeepProfiler.Start("Resolver call");
                 try
                 {
                     def.ResolveReferences();
                 }
                 catch (Exception ex)
                 {
                     Log.Error("Error while resolving references for def " + def + ": " + ex);
                 }
                 finally
                 {
                     DeepProfiler.End();
                 }
             }
         };
         if (parallel)
         {
             GenThreading.ParallelForEach(defsList, action);
         }
         else
         {
             for (int i = 0; i < defsList.Count; i++)
             {
                 action(defsList[i]);
             }
         }
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("SetIndices");
     try
     {
         SetIndices();
     }
     finally
     {
         DeepProfiler.End();
     }
 }
Exemplo n.º 20
0
 public static void End()
 {
     if (!Prefs.LogVerbose)
     {
         return;
     }
     DeepProfiler.Get().End();
 }
Exemplo n.º 21
0
        public static LoadedContentItem <T> LoadItem(string absFilePath, string contentDirPath = null)
        {
            string text = absFilePath;

            if (contentDirPath != null)
            {
                text = text.Substring(contentDirPath.ToString().Length);
            }
            text = text.Substring(0, text.Length - Path.GetExtension(text).Length);
            text = text.Replace('\\', '/');
            try
            {
                if (typeof(T) == typeof(string))
                {
                    return(new LoadedContentItem <T>(text, (T)(object)GenFile.TextFromRawFile(absFilePath)));
                }
                if (typeof(T) == typeof(Texture2D))
                {
                    return(new LoadedContentItem <T>(text, (T)(object)ModContentLoader <T> .LoadPNG(absFilePath)));
                }
                if (typeof(T) == typeof(AudioClip))
                {
                    if (Prefs.LogVerbose)
                    {
                        DeepProfiler.Start("Loading file " + text);
                    }
                    T val = default(T);
                    try
                    {
                        bool doStream = ModContentLoader <T> .ShouldStreamAudioClipFromPath(absFilePath);

                        val = (T)(object)Manager.Load(absFilePath, doStream, true, true);
                    }
                    finally
                    {
                        if (Prefs.LogVerbose)
                        {
                            DeepProfiler.End();
                        }
                    }
                    UnityEngine.Object @object = ((object)val) as UnityEngine.Object;
                    if (@object != (UnityEngine.Object)null)
                    {
                        @object.name = Path.GetFileNameWithoutExtension(new FileInfo(absFilePath).Name);
                    }
                    return(new LoadedContentItem <T>(text, val));
                }
            }
            catch (Exception ex)
            {
                Log.Error("Exception loading " + typeof(T) + " from file.\nabsFilePath: " + absFilePath + "\ncontentDirPath: " + contentDirPath + "\nException: " + ex.ToString());
            }
            if (typeof(T) == typeof(Texture2D))
            {
                return((LoadedContentItem <T>) new LoadedContentItem <Texture2D>(absFilePath, BaseContent.BadTex));
            }
            return(null);
        }
Exemplo n.º 22
0
        public void FinalizeLoading()
        {
            List <Thing> list = this.compressor.ThingsToSpawnAfterLoad().ToList <Thing>();

            this.compressor = null;
            DeepProfiler.Start("Merge compressed and non-compressed thing lists");
            List <Thing> list2 = new List <Thing>(this.loadedFullThings.Count + list.Count);

            foreach (Thing item in this.loadedFullThings.Concat(list))
            {
                list2.Add(item);
            }
            this.loadedFullThings.Clear();
            DeepProfiler.End();
            DeepProfiler.Start("Spawn everything into the map");
            foreach (Thing thing in list2)
            {
                if (!(thing is Building))
                {
                    try
                    {
                        GenSpawn.Spawn(thing, thing.Position, this, thing.Rotation, WipeMode.FullRefund, true);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Exception spawning loaded thing ",
                            thing.ToStringSafe <Thing>(),
                            ": ",
                            ex
                        }), false);
                    }
                }
            }
            foreach (Building building in from t in list2.OfType <Building>()
                     orderby t.def.size.Magnitude
                     select t)
            {
                try
                {
                    GenSpawn.SpawnBuildingAsPossible(building, this, true);
                }
                catch (Exception ex2)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Exception spawning loaded thing ",
                        building.ToStringSafe <Building>(),
                        ": ",
                        ex2
                    }), false);
                }
            }
            DeepProfiler.End();
            this.FinalizeInit();
        }
        public static void LoadAllActiveMods()
        {
            XmlInheritance.Clear();
            int num = 0;

            foreach (ModMetaData item2 in ModsConfig.ActiveModsInLoadOrder.ToList())
            {
                DeepProfiler.Start("Initializing " + item2);
                if (!item2.RootDir.Exists)
                {
                    ModsConfig.SetActive(item2.Identifier, false);
                    Log.Warning("Failed to find active mod " + item2.Name + "(" + item2.Identifier + ") at " + item2.RootDir);
                    DeepProfiler.End();
                }
                else
                {
                    ModContentPack item = new ModContentPack(item2.RootDir, num, item2.Name);
                    num++;
                    LoadedModManager.runningMods.Add(item);
                    DeepProfiler.End();
                }
            }
            for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
            {
                ModContentPack modContentPack = LoadedModManager.runningMods[i];
                DeepProfiler.Start("Loading " + modContentPack + " content");
                modContentPack.ReloadContent();
                DeepProfiler.End();
            }
            foreach (Type item3 in typeof(Mod).InstantiableDescendantsAndSelf())
            {
                if (!LoadedModManager.runningModClasses.ContainsKey(item3))
                {
                    ModContentPack modContentPack2 = (from modpack in LoadedModManager.runningMods
                                                      where modpack.assemblies.loadedAssemblies.Contains(item3.Assembly)
                                                      select modpack).FirstOrDefault();
                    LoadedModManager.runningModClasses[item3] = (Mod)Activator.CreateInstance(item3, modContentPack2);
                }
            }
            for (int j = 0; j < LoadedModManager.runningMods.Count; j++)
            {
                ModContentPack modContentPack3 = LoadedModManager.runningMods[j];
                DeepProfiler.Start("Loading " + modContentPack3);
                modContentPack3.LoadDefs(LoadedModManager.runningMods.SelectMany((ModContentPack rm) => rm.Patches));
                DeepProfiler.End();
            }
            foreach (ModContentPack runningMod in LoadedModManager.runningMods)
            {
                foreach (PatchOperation patch in runningMod.Patches)
                {
                    patch.Complete(runningMod.Name);
                }
                runningMod.ClearPatchesCache();
            }
            XmlInheritance.Clear();
        }
 public static void LoadModContent()
 {
     for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
     {
         ModContentPack modContentPack = LoadedModManager.runningMods[i];
         DeepProfiler.Start("Loading " + modContentPack + " content");
         modContentPack.ReloadContent();
         DeepProfiler.End();
     }
 }
Exemplo n.º 25
0
 public static void LoadAllPlayData(bool recovering = false)
 {
     if (PlayDataLoader.loadedInt)
     {
         Log.Error("Loading play data when already loaded. Call ClearAllPlayData first.");
     }
     else
     {
         DeepProfiler.Start("LoadAllPlayData");
         try
         {
             PlayDataLoader.DoPlayLoad();
         }
         catch (Exception arg)
         {
             if (!Prefs.ResetModsConfigOnCrash)
             {
                 throw;
             }
             if (recovering)
             {
                 Log.Warning("Could not recover from errors loading play data. Giving up.");
                 throw;
             }
             IEnumerable <ModMetaData> activeModsInLoadOrder = ModsConfig.ActiveModsInLoadOrder;
             if (activeModsInLoadOrder.Count() == 1 && activeModsInLoadOrder.First().IsCoreMod)
             {
                 throw;
             }
             Log.Warning("Caught exception while loading play data but there are active mods other than Core. Resetting mods config and trying again.\nThe exception was: " + arg);
             try
             {
                 PlayDataLoader.ClearAllPlayData();
             }
             catch
             {
                 Log.Warning("Caught exception while recovering from errors and trying to clear all play data. Ignoring it.\nThe exception was: " + arg);
             }
             ModsConfig.Reset();
             DirectXmlCrossRefLoader.Clear();
             PlayDataLoader.LoadAllPlayData(true);
             return;
         }
         finally
         {
             DeepProfiler.End();
         }
         PlayDataLoader.loadedInt = true;
         if (recovering)
         {
             Log.Message("Successfully recovered from errors and loaded play data.");
             DelayedErrorWindowRequest.Add("RecoveredFromErrorsText".Translate(), "RecoveredFromErrorsDialogTitle".Translate());
         }
     }
 }
 private static void <DoPlayLoad> m__0()
 {
     DeepProfiler.Start("Load backstories.");
     try
     {
         BackstoryDatabase.ReloadAllBackstories();
     }
     finally
     {
         DeepProfiler.End();
     }
 }
Exemplo n.º 27
0
 public virtual void Start()
 {
     try
     {
         CultureInfoUtility.EnsureEnglish();
         Current.Notify_LoadedSceneChanged();
         CheckGlobalInit();
         Action action = delegate
         {
             DeepProfiler.Start("Misc Init (InitializingInterface)");
             try
             {
                 soundRoot = new SoundRoot();
                 if (GenScene.InPlayScene)
                 {
                     uiRoot = new UIRoot_Play();
                 }
                 else if (GenScene.InEntryScene)
                 {
                     uiRoot = new UIRoot_Entry();
                 }
                 uiRoot.Init();
                 Messages.Notify_LoadedLevelChanged();
                 if (Current.SubcameraDriver != null)
                 {
                     Current.SubcameraDriver.Init();
                 }
             }
             finally
             {
                 DeepProfiler.End();
             }
         };
         if (!PlayDataLoader.Loaded)
         {
             Application.runInBackground = true;
             LongEventHandler.QueueLongEvent(delegate
             {
                 PlayDataLoader.LoadAllPlayData();
             }, null, doAsynchronously: true, null);
             LongEventHandler.QueueLongEvent(action, "InitializingInterface", doAsynchronously: false, null);
         }
         else
         {
             action();
         }
     }
     catch (Exception arg)
     {
         Log.Error("Critical error in root Start(): " + arg);
     }
 }
 public static void Clear()
 {
     DeepProfiler.Start("Clear");
     try
     {
         wantedRefs.Clear();
         wantedListDictRefs.Clear();
     }
     finally
     {
         DeepProfiler.End();
     }
 }
 public static void RegisterObjectWantsCrossRef(object wanter, FieldInfo fi, string targetDefName, string mayRequireMod = null, Type assumeFieldType = null)
 {
     DeepProfiler.Start("RegisterObjectWantsCrossRef (object, FieldInfo, string)");
     try
     {
         WantedRefForObject item = new WantedRefForObject(wanter, fi, targetDefName, mayRequireMod, assumeFieldType);
         wantedRefs.Add(item);
     }
     finally
     {
         DeepProfiler.End();
     }
 }
 public static void RegisterObjectWantsCrossRef(object wanter, string fieldName, string targetDefName, string mayRequireMod = null, Type overrideFieldType = null)
 {
     DeepProfiler.Start("RegisterObjectWantsCrossRef (object,string,string)");
     try
     {
         WantedRefForObject item = new WantedRefForObject(wanter, wanter.GetType().GetField(fieldName), targetDefName, mayRequireMod, overrideFieldType);
         wantedRefs.Add(item);
     }
     finally
     {
         DeepProfiler.End();
     }
 }