Exemple #1
0
        internal static void Communicate()
        {
            var working = true;

            while (working)
            {
                try
                {
                    Thread.Sleep(Math.Max(25, Settings.Network.UpdateInterval));

                    if (!AutoFollow.Enabled)
                    {
                        Server.ShutdownServer();
                        Client.ShutdownClient();
                        continue;
                    }

                    if (!BotMain.IsRunning || BotMain.IsPausedForStateExecution)
                    {
                        continue;
                    }

                    if (!IsConnected)
                    {
                        Connect(ConnectionMode);
                    }

                    if (OnUpdatePreview != null)
                    {
                        OnUpdatePreview.Invoke();
                    }

                    if (ConnectionMode == ConnectionMode.Server)
                    {
                        Server.ServerUpdate();
                    }
                    else
                    {
                        Client.ClientUpdate();
                    }

                    if (OnUpdated != null)
                    {
                        OnUpdated.Invoke();
                    }
                }
                catch (ThreadAbortException e)
                {
                    Thread.ResetAbort();
                    working = false;
                }
                catch (Exception ex)
                {
                    Log.Info("Error in Communicate Thread: {0}", ex);
                }
            }
        }
Exemple #2
0
        public void Update(Controller controller)
        {
            switch (StatusGame)
            {
            case StatusGame.Play: OnUpdateGame(controller); break;

            case StatusGame.Preview: OnUpdatePreview?.Invoke(controller); break;

            case StatusGame.Over: OnUpdateOver?.Invoke(controller); break;
            }
        }