/// <summary> /// Called when user Enable the plugin. /// </summary> public void OnEnabled() { BotMain.OnStart += TrinityBotStart; BotMain.OnStop += TrinityBotStop; // Set up the pause button // rrrix: removing for next DB beta... //Application.Current.Dispatcher.Invoke(PaintMainWindowButtons()); SetWindowTitle(); if (!Directory.Exists(FileManager.PluginPath)) { DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "Fatal Error - cannot enable plugin. Invalid path: {0}", FileManager.PluginPath); DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "Please check you have installed the plugin to the correct location, and then restart DemonBuddy and re-enable the plugin."); DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, @"Plugin should be installed to \<DemonBuddyFolder>\Plugins\Trinity\"); } else { HasMappedPlayerAbilities = false; IsPluginEnabled = true; // Settings are available after this... LoadConfiguration(); Navigator.PlayerMover = new PlayerMover(); SetUnstuckProvider(); GameEvents.OnPlayerDied += TrinityOnDeath; GameEvents.OnGameJoined += TrinityOnJoinGame; GameEvents.OnGameLeft += TrinityOnLeaveGame; GameEvents.OnItemSold += TrinityOnItemSold; GameEvents.OnItemSalvaged += TrinityOnItemSalvaged; GameEvents.OnItemStashed += TrinityOnItemStashed; GameEvents.OnGameChanged += GameEvents_OnGameChanged; if (NavProvider == null) { NavProvider = new DefaultNavigationProvider(); } // enable or disable process exit events //ZetaDia.Memory.Process.EnableRaisingEvents = false; CombatTargeting.Instance.Provider = new BlankCombatProvider(); LootTargeting.Instance.Provider = new BlankLootProvider(); ObstacleTargeting.Instance.Provider = new BlankObstacleProvider(); if (Settings.Loot.ItemFilterMode != global::GilesTrinity.Settings.Loot.ItemFilterMode.DemonBuddy) { ItemManager.Current = new TrinityItemManager(); } NavHelper.UpdateSearchGridProvider(); // Safety check incase DB "OnStart" event didn't fire properly if (BotMain.IsRunning) { TrinityBotStart(null); if (ZetaDia.IsInGame) { TrinityOnJoinGame(null, null); } } SetBotTPS(); TrinityPowerManager.LoadLegacyDelays(); DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "*******************TRINITY*****************", Description);; DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "ATIVADO: {0} carregado - mod by WAR!", Description);; DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "*******************TRINITY*****************", Description);; } if (StashRule != null) { // reseting stash rules StashRule.reset(); } }
/// <summary> /// Called when user Enable the plugin. /// </summary> public void OnEnabled() { try { Logger.Log("OnEnable start"); DateTime dateOnEnabledStart = DateTime.UtcNow; BotMain.OnStart += TrinityBotStart; BotMain.OnStop += TrinityBotStop; SetWindowTitle(); if (!Directory.Exists(FileManager.PluginPath)) { Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Fatal Error - cannot enable plugin. Invalid path: {0}", FileManager.PluginPath); Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Please check you have installed the plugin to the correct location, and then restart DemonBuddy and re-enable the plugin."); Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, @"Plugin should be installed to \<DemonBuddyFolder>\Plugins\Trinity\"); } else { PluginCheck.Start(); HasMappedPlayerAbilities = false; _isPluginEnabled = true; // Settings are available after this... LoadConfiguration(); Navigator.PlayerMover = new PlayerMover(); BotManager.SetUnstuckProvider(); GameEvents.OnPlayerDied += TrinityOnDeath; GameEvents.OnGameJoined += TrinityOnJoinGame; GameEvents.OnGameLeft += TrinityOnLeaveGame; GameEvents.OnItemSold += ItemEvents.TrinityOnItemSold; GameEvents.OnItemSalvaged += ItemEvents.TrinityOnItemSalvaged; GameEvents.OnItemStashed += ItemEvents.TrinityOnItemStashed; GameEvents.OnItemIdentificationRequest += ItemEvents.TrinityOnOnItemIdentificationRequest; GameEvents.OnGameChanged += GameEvents_OnGameChanged; GameEvents.OnWorldChanged += GameEvents_OnWorldChanged; CombatTargeting.Instance.Provider = new BlankCombatProvider(); LootTargeting.Instance.Provider = new BlankLootProvider(); ObstacleTargeting.Instance.Provider = new BlankObstacleProvider(); if (Settings.Loot.ItemFilterMode != Config.Loot.ItemFilterMode.DemonBuddy) { ItemManager.Current = new TrinityItemManager(); } // Safety check incase DB "OnStart" event didn't fire properly if (BotMain.IsRunning) { TrinityBotStart(null); if (ZetaDia.IsInGame) { TrinityOnJoinGame(null, null); } } BeginInvoke(BotManager.SetBotTicksPerSecond); UI.UILoader.PreLoadWindowContent(); Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "ENABLED: {0} now in action!", Description); } if (StashRule != null) { // reseting stash rules BeginInvoke(() => StashRule.reset()); } Logger.LogDebug("OnEnable took {0}ms", DateTime.UtcNow.Subtract(dateOnEnabledStart).TotalMilliseconds); } catch (Exception ex) { Logger.LogError("Error in OnEnable: " + ex); } }