fBaseXtensions.HookHandler.HookBehaviorTree C# (CSharp) Method

HookBehaviorTree() static private method

static private HookBehaviorTree ( ) : void
return void
        internal static void HookBehaviorTree()
        {
            Logger.DBLog.InfoFormat("[Funky] Treehooks..");
            #region TreeHooks

            #region OutOfGame
            CanRunDecoratorDelegate shouldPreformOutOfGameBehavior = OutOfGame.OutOfGameOverlord;
            ActionDelegate actionDelgateOOGBehavior = OutOfGame.OutOfGameBehavior;
            Sequence sequenceOOG = new Sequence(
                    new Action(actionDelgateOOGBehavior)
            );
            var OutOfGameInsert = new Decorator(shouldPreformOutOfGameBehavior, sequenceOOG);
            SetHookValue(HookType.OutOfGame, 0, OutOfGameInsert, true);
            Logger.DBLog.DebugFormat("Out of game tree hooked");
            #endregion

            #region Death
            Logger.DBLog.DebugFormat("Death...");
            //Insert Death Tally Counter At Beginning!
            CanRunDecoratorDelegate deathTallyDecoratorDelegate = DeathBehavior.TallyDeathCanRunDecorator;
            ActionDelegate actionDelegatedeathTallyAction = DeathBehavior.TallyDeathAction;
            Action deathTallyAction = new Action(actionDelegatedeathTallyAction);
            Decorator deathTallyDecorator = new Decorator(deathTallyDecoratorDelegate, deathTallyAction);

            //Death Wait..
            CanRunDecoratorDelegate deathWaitDecoratorDelegate = DeathBehavior.DeathShouldWait;
            ActionDelegate deathWaitActionDelegate = DeathBehavior.DeathWaitAction;
            Action deathWaitAction = new Action(deathWaitActionDelegate);
            Decorator deathWaitDecorator = new Decorator(deathWaitDecoratorDelegate, deathWaitAction);

            Sequence DeathSequence = new Sequence
            (
                deathTallyDecorator,
                deathWaitDecorator
            );
            SetHookValue(HookType.Death, 0, DeathSequence, true);
            //hook.Value.Add(deathTallyActionReset);
            Logger.DBLog.DebugFormat("Death tree hooked");
            #endregion

            if (RoutineManager.Current.Name == "Funky")
            {
                CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = CombatHandler.GlobalOverlord;
                ActionDelegate actionDelegateCoreTarget = CombatHandler.HandleTarget;
                Sequence sequencecombat = new Sequence
                (
                    new Action(actionDelegateCoreTarget)
                );
                var NewCombatComposite = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);
                SetHookValue(HookType.Combat, 0, NewCombatComposite);

                CanRunDecoratorDelegate canRunDelegateBlank = BlankDecorator;
                ActionDelegate actionDelegateBlank = BlankAction;
                Sequence sequenceblank = new Sequence(
                        new Action(actionDelegateBlank)
                        );

                var NewLootComposite = new Decorator(canRunDelegateBlank, sequenceblank);
                SetHookValue(HookType.Loot, 0, NewLootComposite);
            }

            #endregion

            initTreeHooks = true;
        }

Usage Example

Exemplo n.º 1
0
        internal static void OnBotStart(IBot bot)
        {
            if (ZetaDia.IsInGame)
            {
                CheckGameIDChange();
            }

            HookHandler.StoreTreeHooks();

            //Logger.DBLog.InfoFormat("fBaseXtensions is enabled == {0}", FunkyBaseExtension.PluginIsEnabled);
            if (FunkyBaseExtension.PluginIsEnabled)
            {
                if (FunkyBaseExtension.Settings.Debugging.DebuggingData)
                {
                    Logger.DBLog.Debug("Loading Debugging Data from Xml");
                    ObjectCache.DebuggingData = new DebugData();
                }

                if (RoutineManager.Current.Name == "Funky")
                {
                    Navigator.PlayerMover               = new Navigation.PlayerMover();
                    Navigator.StuckHandler              = new Navigation.PluginStuckHandler();
                    CombatTargeting.Instance.Provider   = new PluginCombatTargeting();
                    LootTargeting.Instance.Provider     = new PluginLootTargeting();
                    ObstacleTargeting.Instance.Provider = new PluginObstacleTargeting();
                }

                FunkyGame.Reset();

                //Hotbar.OnSkillsChanged += PlayerClass.HotbarSkillsChangedHandler;
                GoldInactivity.LastCoinageUpdate     = DateTime.Now;
                GoldInactivity.OnGoldTimeoutTripped += GameCache.GoldInactivityTimerTrippedHandler;
                Equipment.OnEquippedItemsChanged    += Equipment.EquippmentChangedHandler;

                if (!HookHandler.initTreeHooks)
                {
                    HookHandler.HookBehaviorTree();
                }

                if (FunkyGame.CurrentStats == null)
                {
                    FunkyGame.CurrentStats = new Stats.Stats();
                }
                else if (FunkyGame.CurrentStats.Hero != FunkyGame.CurrentHeroName)
                {
                    //Switched heroes!
                }
            }

            HookEvents();
        }