diff --git a/Source/MASFlightComputerProxy2.cs b/Source/MASFlightComputerProxy2.cs
index b6ffdd9f..88e22ed4 100644
--- a/Source/MASFlightComputerProxy2.cs
+++ b/Source/MASFlightComputerProxy2.cs
@@ -4022,6 +4022,141 @@ public double ToggleRCSTranslate()
return 1.0;
}
}
+
+ /// 1 if any RCS thrusters are configured to allow pitch control, 0 otherwise.
+ public double GetRCSPitchEnabled()
+ {
+ return (vc.anyRcsPitch) ? 1.0 : 0.0;
+ }
+
+ /// 1 if any RCS thrusters are configured to allow yaw control, 0 otherwise.
+ public double GetRCSYawEnabled()
+ {
+ return (vc.anyRcsYaw) ? 1.0 : 0.0;
+ }
+
+ /// 1 if any RCS thrusters are configured to allow roll control, 0 otherwise.
+ public double GetRCSRollEnabled()
+ {
+ return (vc.anyRcsRoll) ? 1.0 : 0.0;
+ }
+
+ ///
+ /// Enable or disable RCS pitch control.
+ ///
+ /// Whether RCS should be used for pitch.
+ /// The number of RCS modules updated.
+ public double SetRCSPitchEnabled(bool active)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enablePitch = active;
+ }
+
+ return vc.moduleRcs.Length;
+ }
+
+ ///
+ /// Enable or disable RCS yaw control.
+ ///
+ /// Whether RCS should be used for yaw.
+ /// The number of RCS modules updated.
+ public double SetRCSYawEnabled(bool active)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableYaw = active;
+ }
+
+ return vc.moduleRcs.Length;
+ }
+
+ ///
+ /// Enable or disable RCS roll control.
+ ///
+ /// Whether RCS should be used for roll.
+ /// The number of RCS modules updated.
+ public double SetRCSRollEnabled(bool active)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableRoll = active;
+ }
+
+ return vc.moduleRcs.Length;
+ }
+
+ ///
+ /// Toggle RCS pitch control.
+ ///
+ /// 1 if pitch is now on, 0 otherwise.
+ public double ToggleRCSPitch()
+ {
+ if (vc.anyRcsPitch)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enablePitch = false;
+ }
+ return 0.0;
+ }
+ else
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enablePitch = true;
+ }
+ return 1.0;
+ }
+ }
+
+ ///
+ /// Toggle RCS yaw control.
+ ///
+ /// 1 if yaw is now on, 0 otherwise.
+ public double ToggleRCSYaw()
+ {
+ if (vc.anyRcsYaw)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableYaw = false;
+ }
+ return 0.0;
+ }
+ else
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableYaw = true;
+ }
+ return 1.0;
+ }
+ }
+
+ ///
+ /// Toggle RCS roll control.
+ ///
+ /// 1 if roll is now on, 0 otherwise.
+ public double ToggleRCSRoll()
+ {
+ if (vc.anyRcsRoll)
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableRoll = false;
+ }
+ return 0.0;
+ }
+ else
+ {
+ for (int i = vc.moduleRcs.Length - 1; i >= 0; --i)
+ {
+ vc.moduleRcs[i].enableRoll = true;
+ }
+ return 1.0;
+ }
+ }
#endregion RCS
///
diff --git a/Source/MASVesselComputerModules.cs b/Source/MASVesselComputerModules.cs
index bd4ebb16..d067e85d 100644
--- a/Source/MASVesselComputerModules.cs
+++ b/Source/MASVesselComputerModules.cs
@@ -828,6 +828,9 @@ private void UpdateProceduralFairing()
internal bool anyRcsFiring = false;
internal bool anyRcsRotate = false;
internal bool anyRcsTranslate = false;
+ internal bool anyRcsPitch = false;
+ internal bool anyRcsYaw = false;
+ internal bool anyRcsRoll = false;
internal float rcsWeightedThrustLimit;
internal float rcsActiveThrustPercent;
private void UpdateRcs()
@@ -836,6 +839,9 @@ private void UpdateRcs()
anyRcsFiring = false;
anyRcsRotate = false;
anyRcsTranslate = false;
+ anyRcsPitch = false;
+ anyRcsYaw = false;
+ anyRcsRoll = false;
float netThrust = 0.0f;
rcsWeightedThrustLimit = 0.0f;
rcsActiveThrustPercent = 0.0f;
@@ -843,36 +849,35 @@ private void UpdateRcs()
for (int i = moduleRcs.Length - 1; i >= 0; --i)
{
- if (moduleRcs[i].rcsEnabled == false)
+ var rcsModule = moduleRcs[i];
+
+ if (rcsModule.rcsEnabled == false)
{
anyRcsDisabled = true;
}
else
{
- if (moduleRcs[i].enableX || moduleRcs[i].enableY || moduleRcs[i].enableZ)
+ anyRcsTranslate = anyRcsTranslate || rcsModule.enableX || rcsModule.enableY || rcsModule.enableZ;
+ anyRcsPitch = anyRcsPitch || rcsModule.enablePitch;
+ anyRcsYaw = anyRcsYaw || rcsModule.enableYaw;
+ anyRcsRoll = anyRcsRoll || rcsModule.enableRoll;
+
+ if (rcsModule.rcs_active)
{
- anyRcsTranslate = true;
- }
- if (moduleRcs[i].enableRoll || moduleRcs[i].enableYaw || moduleRcs[i].enablePitch)
- {
- anyRcsRotate = true;
- }
- if (moduleRcs[i].rcs_active)
- {
- for (int q = 0; q < moduleRcs[i].thrustForces.Length; ++q)
+ for (int q = 0; q < rcsModule.thrustForces.Length; ++q)
{
- if (moduleRcs[i].thrustForces[q] > 0.0f)
+ if (rcsModule.thrustForces[q] > 0.0f)
{
- rcsActiveThrustPercent += moduleRcs[i].thrustForces[q] / moduleRcs[i].thrusterPower;
+ rcsActiveThrustPercent += rcsModule.thrustForces[q] / rcsModule.thrusterPower;
numActiveThrusters += 1.0f;
anyRcsFiring = true;
}
}
}
- netThrust += moduleRcs[i].thrusterPower;
- rcsWeightedThrustLimit += moduleRcs[i].thrusterPower * moduleRcs[i].thrustPercentage;
+ netThrust += rcsModule.thrusterPower;
+ rcsWeightedThrustLimit += rcsModule.thrusterPower * rcsModule.thrustPercentage;
- List propellants = moduleRcs[i].GetConsumedResources();
+ List propellants = rcsModule.GetConsumedResources();
for (int res = propellants.Count - 1; res >= 0; --res)
{
MarkActiveRcsPropellant(propellants[res].id);
@@ -880,6 +885,8 @@ private void UpdateRcs()
}
}
+ anyRcsRotate = anyRcsPitch || anyRcsYaw || anyRcsRoll;
+
if (numActiveThrusters > 0.0f)
{
rcsActiveThrustPercent /= numActiveThrusters;