Example #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
            {
            }
        }
Example #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);
            }
        }
Example #3
0
        private void GameEvents_OnGameLeft(object sender, EventArgs e)
        {
            SharedComposites.OutOfGameHookReplaced = false;
            SharedComposites.CheckReplaceOutOfGameHook();
            LeaderService.LeaderOutOfGameUpdate();

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

            ServiceBase.Communicate();
        }
Example #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();
            }
        }
Example #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();
        }
Example #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();
        }
Example #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();
     }
 }
Example #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();
     }
 }