Esempio n. 1
0
        public sealed override void UpdateBeforeSimulation()
        {
            _frameCounter100++;
            _frameCounter1000++;

            if (!_isInitialized)
            {
                return;
            }

            if (_delayedConnectionRequest)
            {
                ClientLogger.WriteInfo("Delayed Connection Request");
                _delayedConnectionRequest = false;
                PullConnectionRequest.SendMessage(ModCommunicationVersion, PrivateCommunicationKey);
            }

            if (!_calledFirstFrame && IsConnected)
            {
                _calledFirstFrame = true;
                FirstFrame();
            }

            UpdateBeforeFrame();
            ChatCommandService.UpdateBeforeSimulation();

            if (_frameCounter100 >= 100)
            {
                _frameCounter100 = 0;
                UpdateBeforeFrame100();
                ChatCommandService.UpdateBeforeSimulation100();
            }

            if (_frameCounter1000 >= 1000)
            {
                _frameCounter1000 = 0;
                UpdateBeforeFrame1000();
                ChatCommandService.UpdateBeforeSimulation1000();
            }
        }
Esempio n. 2
0
        private void InitClient()
        {
            _isClientRegistered = true;
            ClientLogger.Init(ClientLogFileName, ClientLoggingLevel, false, MyAPIGateway.Session.IsSinglePlayerOffline() ? 0 : 5); // comment this out if logging is not required for the Client.
            ClientLogger.WriteInfo($"{ModName} Client Log Started");
            ClientLogger.WriteInfo($"{ModName} Client Version {ModCommunicationVersion}");
            //if (ClientLogger.IsActive) // TODO: determine is this is needed any more?
            TextLogger.WriteGameLog($"##Mod## {ModName} Client Logging File: {ClientLogger.LogFile}");

            MyAPIGateway.Utilities.MessageEntered += ChatMessageEntered;

            ClientLogger.WriteStart("RegisterMessageHandler");
            MyAPIGateway.Multiplayer.RegisterMessageHandler(ClientConnectionId, _clientMessageHandler);

            // Offline connections can be re-attempted quickly. Online games needs to wait longer.
            DelayedConnectionRequestTimer          = new Timer(MyAPIGateway.Session.IsSinglePlayerOffline() ? 500 : 10000);
            DelayedConnectionRequestTimer.Elapsed += DelayedConnectionRequestTimer_Elapsed;
            DelayedConnectionRequestTimer.Start();

            // let the server know we are ready for connections
            PullConnectionRequest.SendMessage(ModCommunicationVersion, PrivateCommunicationKey);

            ClientLogger.Flush();
        }