コード例 #1
0
        private IEnumerator SendFlightState()
        {
            var seconds    = new WaitForSeconds(FlightStateSendSInterval);
            var secondsFar = new WaitForSeconds(FlightStateSendLowSInterval);

            while (true)
            {
                if (!Enabled)
                {
                    break;
                }

                if (FlightStateSystemReady && VesselCommon.PlayerVesselsNearby())
                {
                    MessageSender.SendCurrentFlightState();
                }

                if (VesselCommon.IsSomeoneSpectatingUs)
                {
                    yield return(seconds);
                }
                else
                {
                    yield return(secondsFar);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Send the definition of our own vessel and the secondary vessels. We only send them after an interval specified.
        /// If the other player vessels are far we don't send them very often.
        /// </summary>
        private void SendVesselDefinition()
        {
            try
            {
                if (ProtoSystemReady)
                {
                    if (!VesselCommon.ActiveVesselIsInSafetyBubble())
                    {
                        MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel);
                    }

                    foreach (var vessel in VesselCommon.GetSecondaryVessels())
                    {
                        MessageSender.SendVesselMessage(vessel);
                    }

                    ChangeRoutineExecutionInterval("SendVesselDefinition",
                                                   VesselCommon.PlayerVesselsNearby()
                            ? SettingsSystem.ServerSettings.VesselDefinitionSendMsInterval
                            : SettingsSystem.ServerSettings.VesselDefinitionSendFarMsInterval);
                }
            }
            catch (Exception e)
            {
                LunaLog.LogError($"[LMP]: Error in SendVesselDefinition {e}");
            }
        }
コード例 #3
0
        /// <summary>
        /// Send the updates of our own vessel and the secondary vessels. We only send them after an interval specified.
        /// If the other player vessels are far we don't send them very often.
        /// </summary>
        private IEnumerator SendVesselUpdates()
        {
            var seconds    = new WaitForSeconds(VesselUpdatesSendSInterval);
            var secondsFar = new WaitForSeconds(VesselUpdatesSendFarSInterval);

            while (true)
            {
                try
                {
                    if (!Enabled)
                    {
                        break;
                    }

                    if (UpdateSystemReady && !VesselCommon.IsSpectating)
                    {
                        SendVesselUpdate(FlightGlobals.ActiveVessel);
                        SendSecondaryVesselUpdates();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"[LMP]: Coroutine error in SendVesselUpdates {e}");
                }

                if (VesselCommon.PlayerVesselsNearby())
                {
                    yield return(seconds);
                }
                else
                {
                    yield return(secondsFar);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Send control state, clamps, decouplers and dock ports of our vessel
        /// </summary>
        private IEnumerator SendVesselUpdates()
        {
            var seconds    = new WaitForSeconds(_updateSendSInterval);
            var secondsFar = new WaitForSeconds(_updateLowSendSInterval);

            while (true)
            {
                if (!Enabled)
                {
                    break;
                }

                if (UpdateSystemReady)
                {
                    MessageSender.SendVesselUpdate();
                }

                if (VesselCommon.PlayerVesselsNearby())
                {
                    yield return(seconds);
                }
                else
                {
                    yield return(secondsFar);
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Send control state, clamps, decouplers and dock ports of our vessel
 /// </summary>
 private void SendVesselUpdates()
 {
     if (Enabled && UpdateSystemReady)
     {
         MessageSender.SendVesselUpdate();
         ChangeRoutineExecutionInterval("SendVesselUpdates",
                                        VesselCommon.PlayerVesselsNearby()
                  ? UpdateNearbySendMsInterval
                  : UpdateSendMsInterval);
     }
 }
コード例 #6
0
        private void SendFlightState()
        {
            if (Enabled && FlightStateSystemReady && VesselCommon.PlayerVesselsNearby())
            {
                //TODO: Don't we want to send the current flight state even if nobody is nearby--on some infrequent interval?
                MessageSender.SendCurrentFlightState();
            }

            if (Enabled)
            {
                ChangeRoutineExecutionInterval("SendFlightState", VesselCommon.IsSomeoneSpectatingUs ? 100 : 1000);
            }
        }
コード例 #7
0
        /// <summary>
        /// Check if we must send a message or not based on the fixed time that has passed.
        /// Note that when no vessels are nearby or we are not in KSC the time is multiplied by 10
        /// </summary>
        private static bool ShouldSendPositionUpdate()
        {
            if (VesselCommon.IsSpectating)
            {
                return(false);
            }

            var secSinceLastSend = Time.fixedTime - _lastSentTime;

            if (VesselCommon.PlayerVesselsNearby() || VesselCommon.IsNearKsc(20000))
            {
                return(secSinceLastSend > VesselUpdatesSendSInterval);
            }

            return(secSinceLastSend > VesselUpdatesSendSInterval * 10);
        }
コード例 #8
0
        /// <summary>
        /// Send the definition of our own vessel and the secondary vessels. We only send them after an interval specified.
        /// If the other player vessels are far we don't send them very often.
        /// </summary>
        private IEnumerator SendVesselDefinition()
        {
            var seconds    = new WaitForSeconds(VesselDefinitionSendSInterval);
            var secondsFar = new WaitForSeconds(VesselDefinitionSendFarSInterval);

            while (true)
            {
                try
                {
                    if (!Enabled)
                    {
                        break;
                    }

                    if (ProtoSystemReady)
                    {
                        if (!VesselCommon.ActiveVesselIsInSafetyBubble())
                        {
                            MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel);
                        }

                        foreach (var vessel in VesselCommon.GetSecondaryVessels())
                        {
                            MessageSender.SendVesselMessage(vessel);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"[LMP]: Coroutine error in SendVesselDefinition {e}");
                }

                if (VesselCommon.PlayerVesselsNearby())
                {
                    yield return(seconds);
                }
                else
                {
                    yield return(secondsFar);
                }
            }
        }