private void Update() { if (!fullyLoaded) { //check if camera is active. if (GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera") != null) { //load mods allModsLoaded = false; fullyLoaded = true; StartLoadingMods(); } } for (int i = 0; i < LoadedMods.Count; i++) { Mod mod = LoadedMods[i]; try { if (mod.LoadInMenu && !mod.isDisabled) { mod.Update(); } else if (Application.loadedLevelName == "GAME" && !mod.isDisabled && allModsLoaded) { mod.Update(); } } catch (Exception e) { if (LogAllErrors) { StackFrame frame = new StackTrace(e, true).GetFrame(0); string errorDetails = string.Format("{2}<b>Details: </b>{0} in <b>{1}</b>", e.Message, frame.GetMethod(), Environment.NewLine); ModConsole.Error(string.Format("Mod <b>{0}</b> throw an error!{1}", mod.ID, errorDetails)); } UnityEngine.Debug.Log(e); } } }
internal void ModUpdate() { for (int i = 0; i < ModMethods[1].Count; i++) { Mod mod = ModMethods[1][i]; try { if (!mod.isDisabled && (allModsLoaded || mod.LoadInMenu)) { mod.Update(); } } catch (Exception e) { System.Console.WriteLine(e); } } }
private void Update() { if (!fullyLoaded) { //check if camera is active. if (GameObject.Find("PLAYER/Pivot/Camera/FPSCamera") != null) { //load mods allModsLoaded = false; fullyLoaded = true; StartLoadingMods(); } } for (int i = 0; i < LoadedMods.Count; i++) { Mod mod = LoadedMods[i]; try { if (mod.LoadInMenu && !mod.isDisabled) { mod.Update(); } else if (Application.loadedLevelName == "GAME" && !mod.isDisabled && allModsLoaded) { mod.Update(); } } catch (Exception e) { if (LogAllErrors) { StackFrame frame = new StackTrace(e, true).GetFrame(0); string errorDetails = string.Format("{2}<b>Details: </b>{0} in <b>{1}</b>", e.Message, frame.GetMethod(), Environment.NewLine); ModConsole.Error(string.Format("Mod <b>{0}</b> throw an error!{1}", mod.ID, errorDetails)); } UnityEngine.Debug.Log(e); if (allModsLoaded && fullyLoaded) { mod.modErrors++; } if (devMode) { if (mod.modErrors == 30) { ModConsole.Error(string.Format("Mod <b>{0}</b> thrown <b>too many errors</b>!", mod.ID)); ModConsole.Error(e.ToString()); } } else { if (mod.modErrors > 30) { mod.isDisabled = true; ModConsole.Error(string.Format("Mod <b>{0}</b> has been <b>disabled!</b> Because it thrown too many errors!{1}Report this problem to mod author.", mod.ID, Environment.NewLine)); } } } } }