Example #1
0
        private void RemoveHook()
        {
            if (s_hook == null)
            {
                return;
            }
            TreeHooks.Instance.RemoveHook("Combat_Main", s_hook);
            Navigator.NavigationProvider = s_prevNavigator;

            // Make sure maps for the previous navigator are up-to-date
            var meshNav = Navigator.NavigationProvider as MeshNavigator;

            if (meshNav != null)
            {
                meshNav.UpdateMaps();
            }

            s_prevNavigator = null;
            s_hook          = null;
            foreach (var kv in s_avoidDictionary)
            {
                AvoidanceManager.RemoveAvoid(kv.Value);
                QBCLog.DeveloperInfo("Removed the \"{0}\" avoidance definition", kv.Key);
            }
            s_avoidDictionary.Clear();
            BotEvents.OnPulse      -= BotEvents_OnPulse;
            BotEvents.OnBotStopped -= BotEvents_OnBotStopped;
            BotEvents.Profile.OnNewOuterProfileLoaded  -= Profile_OnNewOuterProfileLoaded;
            LootTargeting.Instance.RemoveTargetsFilter -= Instance_RemoveTargetsFilter;
            QBCLog.Info("Uninstalled avoidance system");
        }
Example #2
0
        public override void OnStart()
        {
            // Acquisition and checking of any sub-elements go here.
            // A common example:
            //     HuntingGrounds = HuntingGroundsType.GetOrCreate(Element, "HuntingGrounds", HuntingGroundCenter);
            //     IsAttributeProblem |= HuntingGrounds.IsAttributeProblem;

            // Let QuestBehaviorBase do basic initialization of the behavior, deal with bad or deprecated attributes,
            // capture configuration state, install BT hooks, etc.  This will also update the goal text.
            var isBehaviorShouldRun = OnStart_QuestBehaviorCore();

            if (isBehaviorShouldRun)
            {
                if (Command == CommandType.Remove)
                {
                    if (s_avoidDictionary.ContainsKey(AvoidName))
                    {
                        QBCLog.DeveloperInfo("Removing \"{0}\" avoid", AvoidName);
                        var avoidInfo = s_avoidDictionary[AvoidName];
                        s_avoidDictionary.Remove(AvoidName);
                        AvoidanceManager.RemoveAvoid(avoidInfo);
                    }
                }
                else if (Command == CommandType.Add)
                {
                    AvoidInfo avoidInfo = BuildAvoidInfo();
                    QBCLog.DeveloperInfo("Adding \"{0}\" avoid - Radius: {1}, ObjectId: ({2}), ObjectType: {3}",
                                         AvoidName, Radius, string.Join(", ", ObjectIds), ObjectType);
                    s_avoidDictionary[AvoidName] = avoidInfo;
                    AvoidanceManager.AddAvoid(avoidInfo);
                }
            }

            if (s_hook == null && s_avoidDictionary.Any())
            {
                InstallHook();
            } // remove hook if no avoid definitions are active
            else if (s_hook != null && !s_avoidDictionary.Any())
            {
                RemoveHook();
            }
            BehaviorDone();
        }