// Monobehaviour methods public void Awake() { DontDestroyOnLoad(this.gameObject); if (g_instance == null) { g_instance = this as CorralRegistration; } // add our config button CorralRegistration.instance.Register("ModCorral", "ModCorralConfig", "Open configuration for Mod Corral", (Action <string>) delegate(string s) { if (ModCorral.ModCorralConfigDialog != null) { ModCorral.ModCorralConfigDialog.ShowOrHide(); } }, "Options", null, "OptionsBase", null, "OptionsHovered", null, "ToolbarIconGroup1Hovered", null, //"OptionsBaseHovered", null, "OptionsPressed", null, "ToolbarIconGroup1Pressed", null //"OptionsBasePressed", null ); Log.Message("Mod Corral is awake and listening for registrations."); }
// constructor gets instantiated before any extensions are called public ModCorral() { try { ModCorralConfig.SetInstance(ModCorralConfig.Deserialize("ModCorralConfig.xml")); // determine if we are enabled or not if (PluginManager.instance == null || PluginManager.instance.GetPluginsInfo() == null) { Log.Message("ModCorral quitting, PluginManager.instance is null."); return; } // the very first thing we need to do is check if we're enabled. This constructor // is called even if we're marked as not to be loaded, so if not enabled, don't do anything PluginManager.PluginInfo myPluginInfo = null; foreach (PluginManager.PluginInfo info in PluginManager.instance.GetPluginsInfo()) { if (info.name == "ModCorral" || info.publishedFileID.AsUInt64 == 419090722) { myPluginInfo = info; break; } } if (myPluginInfo == null) { Log.Error("ModCorral PluginInfo not found, exiting."); return; } //// we need to be notified if our mod is enabled or disabled //PluginManager.instance.eventPluginsChanged += () => { this.EvaluateStatus(); }; //PluginManager.instance.eventPluginsStateChanged += () => { this.EvaluateStatus(); }; if (!myPluginInfo.isEnabled) { Log.Warning("ModCorral is disabled."); return; } Log.Message("ModCorral initializing."); // create our corral monobehaviour UIView uiv = UIView.GetAView(); if (uiv != null && uiv.gameObject != null) { CorralRegistration creg = CorralRegistration.instance; } } catch (Exception ex) { Log.Error("ModCorral() Exception: " + ex.Message); } }