Ejemplo n.º 1
0
        public void OnDisabled()
        {
            Logr.Log("Plugin disabled! ");
            Enabled = false;

            BotMain.OnStart                   -= BotMain_OnStart;
            BotMain.OnStop                    -= BotMain_OnStop;
            GameEvents.OnGameLeft             -= GameEvents_OnGameLeft;
            GameEvents.OnGameJoined           -= GameEvents_OnGameJoined;
            GameEvents.OnWorldTransferStart   -= GameEvents_OnWorldTransferStart;
            GameEvents.OnWorldChanged         -= GameEvents_OnWorldChanged;
            TreeHooks.Instance.OnHooksCleared -= OnHooksCleared;

            ServiceBase.Initialized = false;
            SharedComposites.CheckReplaceOutOfGameHook();

            try
            {
                if (ServiceBase.Host != null)
                {
                    ServiceBase.Host.Close();
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the Follower connection to the Leader
        /// </summary>
        private static void StartClient()
        {
            try
            {
                if (!Initialized && Enabled)
                {
                    int serverPort = Settings.Instance.ServerPort;
                    ServerUri = new Uri(ServerUri.AbsoluteUri.Replace(BasePort.ToString(), serverPort.ToString()));

                    SharedComposites.CheckReplaceOutOfGameHook();

                    Logr.Log("Initializing Client Service connection to {0}", ServerUri.AbsoluteUri + "Follow");

                    BasicHttpBinding binding = new BasicHttpBinding
                    {
                        OpenTimeout  = TimeSpan.FromMilliseconds(5000),
                        SendTimeout  = TimeSpan.FromMilliseconds(5000),
                        CloseTimeout = TimeSpan.FromMilliseconds(5000)
                    };

                    EndpointAddress endPointAddress = new EndpointAddress(ServerUri.AbsoluteUri + "Follow");

                    HttpFactory = new ChannelFactory <IFollowService>(binding, endPointAddress);

                    HttpProxy = HttpFactory.CreateChannel();

                    Initialized = true;
                }
            }
            catch (Exception ex)
            {
                Logr.Log("Exception in ClientInitialize() {0}", ex);
            }
        }
Ejemplo n.º 3
0
        private void GameEvents_OnGameLeft(object sender, EventArgs e)
        {
            SharedComposites.OutOfGameHookReplaced = false;
            SharedComposites.CheckReplaceOutOfGameHook();
            LeaderService.LeaderOutOfGameUpdate();

            ServiceBase.Communicate();
        }
Ejemplo n.º 4
0
        private void GameEvents_OnGameJoined(object sender, EventArgs e)
        {
            SimpleFollow.LastJoinedGame = DateTime.Now;
            SharedComposites.CheckReplaceOutOfGameHook();
            LeaderService.LeaderOutOfGameUpdate();

            ServiceBase.Communicate();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles bot-start
        /// </summary>
        /// <param name="bot"></param>
        private void BotMain_OnStart(IBot bot)
        {
            LeaderComposite.ReplaceBotBehavior();
            if (Enabled)
            {
                Logr.Log("Bot Starting");
                SharedComposites.OutOfGameHookReplaced = false;
                SharedComposites.CheckReplaceOutOfGameHook();
                LeaderService.LeaderOutOfGameUpdate();

                ServiceBase.Communicate();
            }
        }
Ejemplo n.º 6
0
        public static void Pulse()
        {
            try
            {
                LeaderService.CleanExpiredFollowers();
                ServiceBase.Communicate();

                LeaderService.PulseInbox();

                SharedComposites.CheckReplaceOutOfGameHook();
            }
            catch (Exception ex)
            {
                Logr.Log("Exception thrown on Pulse: {0}", ex.ToString());
            }

            GameUI.SafeCheckClickButtons();
        }
Ejemplo n.º 7
0
        public void OnEnabled()
        {
            Logr.Log("Plugin v{0} Enabled", Version);
            Enabled = true;

            BotMain.OnStart                   += BotMain_OnStart;
            BotMain.OnStop                    += BotMain_OnStop;
            GameEvents.OnGameLeft             += GameEvents_OnGameLeft;
            GameEvents.OnGameJoined           += GameEvents_OnGameJoined;
            GameEvents.OnWorldTransferStart   += GameEvents_OnWorldTransferStart;
            GameEvents.OnWorldChanged         += GameEvents_OnWorldChanged;
            TreeHooks.Instance.OnHooksCleared += OnHooksCleared;

            SharedComposites.OutOfGameHookReplaced = false;
            SharedComposites.CheckReplaceOutOfGameHook();
            LeaderService.LeaderOutOfGameUpdate();

            ServiceBase.Communicate();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Pulsing this will update both the follower and leader messages.
 /// </summary>
 internal static void Communicate()
 {
     if (Enabled)
     {
         if (!IsFollower)
         {
             LeaderService.BehaviorWatcher();
             LeaderService.ServerUpdate();
         }
         else
         {
             FollowerService.AsyncClientUpdate();
         }
     }
     else
     {
         Logr.Log("Error - Main pulsed but plugin is disabled!");
         SharedComposites.CheckReplaceOutOfGameHook();
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Called by leader through Communicate()
 /// </summary>
 internal static void ServerUpdate()
 {
     if (!Enabled)
     {
         return;
     }
     // Need to initialize server service
     if (Host == null || (Host != null && Host.State != CommunicationState.Opened))
     {
         StartServer();
     }
     // Server service initialized, lets update
     if (Leader.GetMillisecondsSinceLastUpdate() >= 500)
     {
         Leader = Message.GetMessage();
         if (Followers.Any())
         {
             Leader.HighestTeamRiftKey = Followers.Min(f => f.Value.HighestLevelTieredRiftKey);
         }
         SharedComposites.CheckReplaceOutOfGameHook();
     }
 }