Skip to content

Commit 02a0ba6

Browse files
Add new misc option of stopping time wrap upon reconnection
1 parent 13c4a83 commit 02a0ba6

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

GameData/RemoteTech/Default_Settings.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RemoteTechSettings
1616
MultipleAntennaMultiplier = 0
1717
ThrottleTimeWarp = True
1818
ThrottleZeroOnNoConnection = True
19+
StopTimeWrapOnReConnection = False
1920
HideGroundStationsBehindBody = True
2021
ControlAntennaWithoutConnection = False
2122
UpgradeableMissionControlAntennas = True

GameData/RemoteTech/Localization/en-us.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Localization
9898
#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection = Throttle to zero on loss of connection
9999
#RT_OptionWindow_Miscellaneous_NoThrottleZeroOnNoConnection = Throttle unaffected by loss of connection
100100
#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection_text = ON: The flight computer cuts the thrust if you lose connection to Mission Control.\nOFF: The throttle is not adjusted automatically.
101+
102+
#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection = Stop time wrap on reconnection
103+
#RT_OptionWindow_Miscellaneous_NoStopTimeWrapOnReConnection = Time wrap uninterrupted by reconnection
104+
#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection_text = ON: The flight computer will automatically stop time warp when a connection is found. \nOFF: The time wrap will not be stopped when a connection is found.
101105

102106
#RT_OptionWindow_Miscellaneous_UpgradeableMissionControl = Mission Control antennas are upgradeable
103107
#RT_OptionWindow_Miscellaneous_NoUpgradeableMissionControl = Mission Control antennas are not upgradeable

GameData/RemoteTech/Localization/zh-cn.cfg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ Localization
9898
#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection = 连接断开时节流阀降至零
9999
#RT_OptionWindow_Miscellaneous_NoThrottleZeroOnNoConnection = 节流阀不受连接断开的影响
100100
#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection_text = 开:如果失去与任务控制中心的连接,飞行计算机会切断飞船的推力。\n关:节流阀不会自动调整.
101-
101+
102+
#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection = Stop time wrap on reconnection
103+
#RT_OptionWindow_Miscellaneous_NoStopTimeWrapOnReConnection = Time wrap uninterrupted by reconnection
104+
#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection_text = ON: The flight computer will automatically stop time warp when a connection is found. \nOFF: The time wrap will not be stopped when a connection is found.
105+
102106
#RT_OptionWindow_Miscellaneous_UpgradeableMissionControl = 任务控制中心天线可升级
103107
#RT_OptionWindow_Miscellaneous_NoUpgradeableMissionControl = 任务控制中心天线不可升级
104108
#RT_OptionWindow_Miscellaneous_UpgradeableMissionControlText = 打开:任务控制中心天线范围在升级跟踪中心时升级。\n关闭:任务控制天线范围不可升级。

src/RemoteTech/FlightComputer/FlightComputer.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public State Status
9696
/// <summary>Returns the last known position of throttle prior to connection loss.</summary>
9797
public float LockedThrottlePositionNoConnect = 0f;
9898

99+
/// <summary>Returns true to set the time wrap factor to 1 upon a connection reestablished, otherwise false</summary>
100+
public bool StopTimeWrapOnReconnect => RTSettings.Instance.StopTimeWrapOnReConnection;
101+
/// <summary>Returns true to indicate whether a connection loss occurs</summary>
102+
private bool TimeWrapConnectionLoss = false;
103+
99104
/// <summary>Gets or sets the total delay which is the usual light speed delay + any manual delay.</summary>
100105
public double TotalDelay { get; set; }
101106
/// <summary>The target (<see cref="TargetCommand.Target"/>) of a <see cref="TargetCommand"/>.</summary>
@@ -290,6 +295,7 @@ public void OnUpdate()
290295
if (RTCore.Instance == null) return;
291296
if (!SignalProcessor.IsMaster) return;
292297
PopCommand();
298+
ExecuteConnectionStatusActions();
293299
}
294300

295301
/// <summary>Called by the <see cref="ModuleSPU.OnFixedUpdate"/> method during the "Physics" engine phase.</summary>
@@ -734,5 +740,31 @@ public void RemoveManeuverCommandByNode(ManeuverNode node)
734740
}
735741
}
736742
}
743+
744+
/// <summary>
745+
/// Execute actions depending on connection status
746+
/// </summary>
747+
private void ExecuteConnectionStatusActions()
748+
{
749+
//stop time wrap if re-connection occurred
750+
if (StopTimeWrapOnReconnect && TimeWarp.CurrentRate > 1.0f)
751+
{
752+
if (!RTCore.Instance.Satellites[SignalProcessor.VesselId].Connections.Any()) // no connection
753+
{
754+
TimeWrapConnectionLoss = true;
755+
}
756+
else // working connection
757+
{
758+
if (TimeWrapConnectionLoss)
759+
{
760+
TimeWrapConnectionLoss = false;
761+
762+
var message = new ScreenMessage(Localizer.Format("#RT_FC_msg1"), 4.0f, ScreenMessageStyle.UPPER_LEFT);//"[Flight Computer]: Throttling back time warp..."
763+
TimeWarp.SetRate(0, false); //gentle stopping
764+
ScreenMessages.PostScreenMessage(message);
765+
}
766+
}
767+
}
768+
}
737769
}
738770
}

src/RemoteTech/RTSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class Settings
5656
[Persistent] public double MultipleAntennaMultiplier;
5757
[Persistent] public bool ThrottleTimeWarp;
5858
[Persistent] public bool ThrottleZeroOnNoConnection;
59+
[Persistent] public bool StopTimeWrapOnReConnection;
5960
[Persistent] public bool HideGroundStationsBehindBody;
6061
[Persistent] public bool ControlAntennaWithoutConnection;
6162
[Persistent] public bool UpgradeableMissionControlAntennas;

src/RemoteTech/UI/OptionWindow.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ private void drawMiscellaneousContent()
418418
this.mSettings.ThrottleZeroOnNoConnection = GUILayout.Toggle(this.mSettings.ThrottleZeroOnNoConnection, (this.mSettings.ThrottleZeroOnNoConnection) ? Localizer.Format("#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection") : Localizer.Format("#RT_OptionWindow_Miscellaneous_NoThrottleZeroOnNoConnection"));//"Throttle to zero on loss of connection""Throttle unaffected by loss of connection"
419419
GUILayout.Label(Localizer.Format("#RT_OptionWindow_Miscellaneous_ThrottleZeroOnNoConnection_text"), this.mGuiHintText);//"ON: The flight computer cuts the thrust if you lose connection to Mission Control.\nOFF: The throttle is not adjusted automatically."
420420

421+
this.mSettings.StopTimeWrapOnReConnection = GUILayout.Toggle(this.mSettings.StopTimeWrapOnReConnection, (this.mSettings.StopTimeWrapOnReConnection) ? Localizer.Format("#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection") : Localizer.Format("#RT_OptionWindow_Miscellaneous_NoStopTimeWrapOnReConnection"));//"Stop time wrap on reconnection""Time wrap uninterrupted by reconnection"
422+
GUILayout.Label(Localizer.Format("#RT_OptionWindow_Miscellaneous_StopTimeWrapOnReConnection_text"), this.mGuiHintText);//"ON: The flight computer will automatically stop time warp when a connection is found. \nOFF: The time wrap will not be stopped when a connection is found."
423+
421424
this.mSettings.UpgradeableMissionControlAntennas = GUILayout.Toggle(this.mSettings.UpgradeableMissionControlAntennas, (this.mSettings.UpgradeableMissionControlAntennas) ? Localizer.Format("#RT_OptionWindow_Miscellaneous_UpgradeableMissionControl") : Localizer.Format("#RT_OptionWindow_Miscellaneous_NoUpgradeableMissionControl"));//"Mission Control antennas are upgradeable""Mission Control antennas are not upgradeable"
422425
GUILayout.Label(Localizer.Format("#RT_OptionWindow_Miscellaneous_UpgradeableMissionControlText"), this.mGuiHintText);//"ON: Mission Control antenna range is upgraded when the Tracking Center is upgraded.\nOFF: Mission Control antenna range isn't upgradeable."
423426

0 commit comments

Comments
 (0)