Ejemplo n.º 1
0
        /// <summary>
        ///     Runs this game mode client.
        /// </summary>
        /// <returns>true if shut down by the game mode, false otherwise.</returns>
        /// <exception cref="Exception">Thrown if a game mode is already running.</exception>
        public bool Run()
        {
            if (InternalStorage.RunningClient != null)
            {
                throw new Exception("A game mode is already running!");
            }

            InternalStorage.RunningClient = this;

            // Prepare the syncronization context
            var queue = new SemaphoreMessageQueue();

            _syncronizationContext = new SampSharpSyncronizationContext(queue);
            _messagePump           = new MessagePump(queue);

            SynchronizationContext.SetSynchronizationContext(_syncronizationContext);

            // Initialize the game mode and start the main routine
            Initialize();

            // Pump new tasks
            _messagePump.Pump(e => OnUnhandledException(new UnhandledExceptionEventArgs(e)));

            // Clean up
            InternalStorage.RunningClient = null;
            CommunicationClient.Disconnect();

            return(_shuttingDown);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Runs this game mode client.
        /// </summary>
        /// <returns>true if shut down by the game mode, false otherwise.</returns>
        /// <exception cref="Exception">Thrown if a game mode is already running.</exception>
        public bool Run()
        {
            if (InternalStorage.RunningClient != null)
            {
                throw new Exception("A game mode is already running!");
            }

            InternalStorage.RunningClient = this;

            // Prepare the syncronization context
            _syncronizationContext = new SampSharpSyncronizationContext();
            _messagePump           = _syncronizationContext.MessagePump;

            SynchronizationContext.SetSynchronizationContext(_syncronizationContext);

            // Initialize the game mode and start the main routine
            Initialize();

            // Pump new tasks
            _messagePump.Pump();

            // Clean up
            InternalStorage.RunningClient = null;
            CommunicationClient.Disconnect();

            return(_shuttingDown);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Runs the game mode of this runner.
        /// </summary>
        /// <returns>true if shut down by the game mode, false otherwise.</returns>
        /// <exception cref="Exception">Thrown if a game mode is already running.</exception>
        public bool Run()
        {
            InternalStorage.RunningClient = this;

            // Prepare the syncronization context
            _messageQueue          = new NoWaitMessageQueue();
            _syncronizationContext = new SampSharpSyncronizationContext(_messageQueue);

            SynchronizationContext.SetSynchronizationContext(_syncronizationContext);

            _mainThread = Thread.CurrentThread.ManagedThreadId;
            _running    = true;

            CoreLog.Log(CoreLogLevel.Initialisation, "SampSharp GameMode Client");
            CoreLog.Log(CoreLogLevel.Initialisation, "-------------------------");
            CoreLog.Log(CoreLogLevel.Initialisation, $"v{CoreVersion.Version.ToString(3)}, (C)2014-2019 Tim Potze");
            CoreLog.Log(CoreLogLevel.Initialisation, "");

            // TODO: Verify plugin version

            _gameModeProvider.Initialize(this);

            return(true);
        }