Beispiel #1
0
        public void OnEnabled()
        {
            if (IsEnabled || !Application.Current.CheckAccess())
            {
                return;
            }

            Core.Init();
            TrinitySettings.InitializeSettings();
            SkillUtils.UpdateActiveSkills();
            TabUi.InstallTab();
            SetupDemonBuddy();
            UILoader.PreLoadWindowContent();
            ModuleManager.Enable();
            Core.Logger.Log($"is now ENABLED: {Description} - now in action!");
            IsEnabled = true;
        }
Beispiel #2
0
        public void OnEnabled()
        {
            using (ZetaDia.Memory.AcquireFrame())
            {
                if (IsEnabled || !Application.Current.CheckAccess())
                {
                    return;
                }

                Core.Init();
                BotMain.OnStart += OnStart;
                BotMain.OnStop  += OnStop;
                TrinitySettings.InitializeSettings();
                SkillUtils.UpdateActiveSkills();
                HookManager.CheckHooks();
                TabUi.InstallTab();
                SetupDemonBuddy();
                UILoader.PreLoadWindowContent();
                ModuleManager.Enable();
                s_logger.Information($@"{Name} v{Version} is now ENABLED.
{Description}");
                IsEnabled = true;
            }
        }
Beispiel #3
0
        /// <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();
                TabUi.InstallTab();

                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
                {
                    _isPluginEnabled = true;

                    PluginCheck.Start();

                    // 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.OnItemDropped  += ItemEvents.TrinityOnItemDropped;
                    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 != 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);
                        }
                    }

                    BotManager.SetBotTicksPerSecond();

                    UILoader.PreLoadWindowContent();

                    Events.OnCacheUpdated += Enemies.Update;

                    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);
            }
        }