示例#1
0
        public void Attach(IWowActionExecutor wowActionExecutor, IPathfindingClient wowPathfindingClient, IWowEventAdapter wowEventAdapter, IMovementProvider movementProvider, ISpellStrategy spellStrategy, IItemComparator itemComparator = null)
        {
            Attached             = true;
            WowPathfindingClient = wowPathfindingClient;

            if (itemComparator == null)
            {
                itemComparator = new BasicItemLevelComparator(WowDataAdapter);
            }

            WowDataAdapter?.StartObjectUpdates();
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tStarted ObjectUpdates...");

            WowActionExecutor = wowActionExecutor;
            WowActionExecutor.IsWorldLoaded = true;
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tStarted ActionExecutor...");

            WowEventAdapter = wowEventAdapter;
            //WowEventAdapter?.Start();
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tStarted EventAdapter...");

            WowEventAdapter?.Subscribe(WowEvents.PARTY_INVITE_REQUEST, OnPartyInvitation);
            WowEventAdapter?.Subscribe(WowEvents.LOOT_OPENED, OnLootWindowOpened);
            WowEventAdapter?.Subscribe(WowEvents.RESURRECT_REQUEST, OnResurrectRequest);
            WowEventAdapter?.Subscribe(WowEvents.CONFIRM_SUMMON, OnSummonRequest);
            WowEventAdapter?.Subscribe(WowEvents.LOOT_BIND_CONFIRM, OnConfirmBindOnPickup);
            WowEventAdapter?.Subscribe(WowEvents.CONFIRM_LOOT_ROLL, OnConfirmBindOnPickup);
            WowEventAdapter?.Subscribe(WowEvents.READY_CHECK, OnReadyCheck);
            WowEventAdapter?.Subscribe(WowEvents.DELETE_ITEM_CONFIRM, OnConfirmDeleteItem);
            WowEventAdapter?.Subscribe(WowEvents.ITEM_PUSH, OnNewItemReceived);
            WowEventAdapter?.Subscribe(WowEvents.COMBAT_LOG_EVENT_UNFILTERED, OnCombatLogEvent);

            StateMachine = new AmeisenBotStateMachine(WowDataAdapter, WowActionExecutor, WowPathfindingClient, movementProvider, spellStrategy);
            StateMachine?.Start();
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tStarted StateMachine...");

            CharacterManager = new WowCharacterManager(WowDataAdapter, WowActionExecutor, itemComparator);
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tStarted CharacterManager...");

            CharacterManager?.UpdateFullCharacter();
            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tUpdated Character...");

            AmeisenBotLogger.Instance.Log($"[{Process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tAmeisenBot attached...");
        }
        public AmeisenBotStateMachine(IWowDataAdapter dataAdapter, IWowActionExecutor wowActionExecutor, IPathfindingClient pathfindingClient, IMovementProvider movementProvider, ISpellStrategy spellStrategy, int stateUpdateInterval = 100)
        {
            MovementProvider = movementProvider;
            SpellStrategy    = spellStrategy;

            BotStates = new Dictionary <Type, BotState> {
                { typeof(BotStateIdle), new BotStateIdle(this) },
                { typeof(BotStateFollow), new BotStateFollow(this) },
                { typeof(BotStateCombat), new BotStateCombat(this) },
                { typeof(BotStateDead), new BotStateDead(this) },
                { typeof(BotStateGhost), new BotStateGhost(this) }
            };

            PathfindingClient = pathfindingClient;
            WowActionExecutor = wowActionExecutor;
            WowDataAdapter    = dataAdapter;

            CurrentState = BotStates[typeof(BotStateIdle)];
            CurrentState.Start();

            StateMachineTimer          = new Timer(stateUpdateInterval);
            StateMachineTimer.Elapsed += CStateMachineUpdate;
        }