public override void OnLevelUnloading() { // do base processing base.OnLevelUnloading(); try { try { // remove Harmony patches HarmonyPatcher.RemovePatches(); } catch (System.IO.FileNotFoundException ex) { // ignore missing Harmony, rethrow all others if (!ex.FileName.ToUpper().Contains("HARMONY")) { throw ex; } } // deinitialize user interface EOCVUserInterface.Deinitialize(); } catch (Exception ex) { Debug.LogException(ex); } }
public override void OnLevelLoaded(LoadMode mode) { // do base processing base.OnLevelLoaded(mode); try { // check for new or loaded game if (mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario || mode == LoadMode.LoadGame) { // determine if Exclude Mail mod is enabled foreach (PluginManager.PluginInfo mod in PluginManager.instance.GetPluginsInfo()) { // ignore builtin mods and camera script if (!mod.isBuiltin && !mod.isCameraScript) { // check against the Exclude Mail workshop ID if (mod.publishedFileID.AsUInt64 == 2093019121) { if (mod.isEnabled) { // create dialog panel ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage( "Enhanced Outside Connections View", "The Enhanced Outside Connections View mod supersedes the Exclude Mail mod. \n\n" + "Please unsubscribe from the Exclude Mail mod.", false); // do not initialize this mod return; } // found it, but not enabled break; } } } // initialize user interface if (!EOCVUserInterface.Initialize()) { return; } // create the Harmony patches if (!HarmonyPatcher.CreatePatches()) { return; } } } catch (Exception ex) { Debug.LogException(ex); } }
/// <summary> /// create patch for OutsideConnectionsInfoViewPanel.UpdatePanel /// </summary> public static bool CreateUpdatePanelPatch() { // patch with the postfix routine return(HarmonyPatcher.CreatePostfixPatch(typeof(OutsideConnectionsInfoViewPanel), "UpdatePanel", BindingFlags.Instance | BindingFlags.NonPublic, typeof(OCIVPPatch), "OutsideConnectionsInfoViewPanelUpdatePanel")); }
/// <summary> /// create a patch of the GetColor method for the specified vehicle AI type /// </summary> private static bool CreateGetColorPatch <T>() where T : VehicleAI { // same routine is used for all vehicle AI types return(HarmonyPatcher.CreatePrefixPatchVehicleAI(typeof(T), "GetColor", typeof(VehicleAIPatch), "VehicleAIGetColor")); }