protected override void Startup() { lock (this._classLock) { // Make sure startup hasn't been called on a second plugin instance if (_instance != null && _instance != this) { WrapperDebugWriter.WriteToStaticLog("RT", ""); WrapperDebugWriter.WriteToStaticLog("RT", "*****************WARNING********************"); WrapperDebugWriter.WriteToStaticLog("RT", "Startup has been called on an RTPlugin instance, while a different instance is currently the active singleton instance"); WrapperDebugWriter.WriteToStaticLog("RT", "Startup of this instance will return immediately and NOT attached to game events"); WrapperDebugWriter.WriteToStaticLog("RT", "*****************WARNING********************"); WrapperDebugWriter.WriteToStaticLog("RT", ""); return; } _instance = this; // My attempt to try and resolve the mutiple active instances after reloggging issue // Start up was called aready, but at least this instance is already the singleton. So it should be okay to ignore this if (this._startupComplete) { WrapperDebugWriter.WriteToStaticLog("RT", "Skipping start up. Already Complete"); return; } this.CoreManager.CharacterFilter.LoginComplete += CharacterFilter_LoginComplete; this.CoreManager.PluginInitComplete += CoreManager_PluginInitComplete; this.CoreManager.CharacterFilter.Logoff += CharacterFilter_Logoff; Mine.MyUtilities.Init(); this._startupComplete = true; // Reset the shutdown flag this._shutdownComplete = false; } }
protected override void Shutdown() { lock (this._classLock) { // If we've already shutdown, then return if (this._shutdownComplete) { WrapperDebugWriter.WriteToStaticLog("RT", "Skipping Shutdown. Already Complete"); return; } //WrapperDebugWriter.WriteToStaticLog("RT", "In Shutdown"); //this.CoreManager.CharacterFilter.LoginComplete -= CharacterFilter_LoginComplete; //this.CoreManager.CharacterFilter.Logoff -= CharacterFilter_Logoff; this.CoreManager.PluginInitComplete -= CoreManager_PluginInitComplete; try { this.InvokeOperationSafely(() => { // Attempt to fix relog bug : try and CloseDown again. Maybe we missed the logoff event? this.CloseDown(); }); } catch (Exception) { // If invoke failed to log an error, there is not much we could do here aside from let the game crash. } this._shutdownComplete = true; // Reset the start up flag this._startupComplete = false; _instance = null; } }