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); } } }
/// <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}"); } }
/// <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); } } }
/// <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); } } }
/// <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); } }
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); } }
/// <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); }
/// <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); } } }