コード例 #1
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}");
            }
        }
コード例 #2
0
        /// <summary>
        /// Send the definition of our own vessel and the secondary vessels.
        /// </summary>
        private void SendVesselDefinition()
        {
            try
            {
                if (ProtoSystemReady)
                {
                    if (FlightGlobals.ActiveVessel.parts.Count != FlightGlobals.ActiveVessel.protoVessel.protoPartSnapshots.Count)
                    {
                        MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel);
                    }

                    foreach (var vessel in VesselCommon.GetSecondaryVessels())
                    {
                        if (vessel.parts.Count != vessel.protoVessel.protoPartSnapshots.Count)
                        {
                            MessageSender.SendVesselMessage(vessel);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LunaLog.LogError($"[LMP]: Error in SendVesselDefinition {e}");
            }
        }
コード例 #3
0
        /// <summary>
        /// Send updates for vessels that we own the update lock.
        /// </summary>
        private void SendSecondaryVesselUpdates()
        {
            var secondaryVesselsToUpdate = VesselCommon.GetSecondaryVessels();

            foreach (var secondryVessel in secondaryVesselsToUpdate)
            {
                SendVesselUpdate(secondryVessel);
            }
        }
コード例 #4
0
 /// <summary>
 /// Send updates for vessels that we own the update lock.
 /// </summary>
 private void SendSecondaryVesselPositionUpdates()
 {
     if (PositionUpdateSystemReady && !VesselCommon.IsSpectating)
     {
         var secondaryVesselsToUpdate = VesselCommon.GetSecondaryVessels();
         foreach (var secondaryVessel in secondaryVesselsToUpdate)
         {
             MessageSender.SendVesselPositionUpdate(secondaryVessel);
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Send updates for vessels that we own the update lock. And also send it for the abandoned ones
        /// </summary>
        private void SendSecondaryVesselPositionUpdates()
        {
            if (PositionUpdateSystemReady && !VesselCommon.IsSpectating)
            {
                SecondaryVesselsToUpdate.Clear();
                SecondaryVesselsToUpdate.AddRange(VesselCommon.GetSecondaryVessels());

                for (var i = 0; i < SecondaryVesselsToUpdate.Count; i++)
                {
                    MessageSender.SendVesselPositionUpdate(SecondaryVesselsToUpdate[i]);
                }
            }
        }
コード例 #6
0
        private void SendSecondaryVesselPartUpdates()
        {
            if (PartSyncSystemReady && !VesselCommon.IsSpectating)
            {
                SecondaryVesselsToUpdate.Clear();
                SecondaryVesselsToUpdate.AddRange(VesselCommon.GetSecondaryVessels());

                for (var i = 0; i < SecondaryVesselsToUpdate.Count; i++)
                {
                    CheckAndSendVesselUpdate(SecondaryVesselsToUpdate[i]);
                }
            }
        }
コード例 #7
0
        private void SendSecondaryVesselFairings()
        {
            if (FairingSystemReady && !VesselCommon.IsSpectating)
            {
                SecondaryVesselsToUpdate.Clear();
                SecondaryVesselsToUpdate.AddRange(VesselCommon.GetSecondaryVessels());

                for (var i = 0; i < SecondaryVesselsToUpdate.Count; i++)
                {
                    CheckAndSendFairingChanges(SecondaryVesselsToUpdate[i]);
                }
            }
        }
コード例 #8
0
 /// <summary>
 /// Send the definition of our own vessel and the secondary vessels.
 /// </summary>
 private void SendVesselDefinition()
 {
     try
     {
         if (ProtoSystemReady)
         {
             MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel, false, false);
             MessageSender.SendVesselMessage(VesselCommon.GetSecondaryVessels());
         }
     }
     catch (Exception e)
     {
         LunaLog.LogError($"[LMP]: Error in SendVesselDefinition {e}");
     }
 }
コード例 #9
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);
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Send updates for vessels that we own the update lock. And also send it for the abandoned ones
        /// </summary>
        private void SendSecondaryVesselPositionUpdates()
        {
            if (PositionUpdateSystemReady && !VesselCommon.IsSpectating)
            {
                SecondaryVesselsToUpdate.Clear();
                SecondaryVesselsToUpdate.AddRange(VesselCommon.GetSecondaryVessels());

                for (var i = 0; i < SecondaryVesselsToUpdate.Count; i++)
                {
                    //This is the case when you've got an update lock from a vessel that was controlled by a player in a future subspace.
                    //You don't need to send position updates for it as you're replaying them from the past
                    if (VesselHavePositionUpdatesQueued(SecondaryVesselsToUpdate[i].id))
                    {
                        continue;
                    }

                    MessageSender.SendVesselPositionUpdate(SecondaryVesselsToUpdate[i]);
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Send updates for vessels that we own the update lock.
        /// </summary>
        private IEnumerator SendSecondaryVesselPositionUpdates()
        {
            var seconds = new WaitForSeconds(SecondaryVesselUpdatesSendSInterval);

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

                if (PositionUpdateSystemReady && ShouldSendPositionUpdate())
                {
                    var secondaryVesselsToUpdate = VesselCommon.GetSecondaryVessels();

                    foreach (var secondaryVessel in secondaryVesselsToUpdate)
                    {
                        MessageSender.SendVesselPositionUpdate(secondaryVessel);
                    }
                }

                yield return(seconds);
            }
        }