Skip to content

Commit 3064dbb

Browse files
committed
KSP 1.2 updates
1 parent 47d4f92 commit 3064dbb

18 files changed

+73
-54
lines changed

Failure Bases/TestFlightFailureBase_Avionics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override float DoRepair()
5151
}
5252
public virtual void OnFlyByWire(FlightCtrlState s)
5353
{
54-
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource)
54+
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource != Vessel.ControlLevel.FULL)
5555
{
5656
return;
5757
}

Failure Bases/TestFlightFailureBase_Wheel.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33
using System.Linq;
44
using System.Text;
55
using TestFlightAPI;
6+
using ModuleWheels;
67

78
namespace TestFlight
89
{
910
public class TestFlightFailureBase_Wheel : TestFlightFailureBase
1011
{
11-
protected ModuleWheel module;
12+
protected ModuleWheelBase wheelBase;
13+
protected ModuleWheelSteering wheelSteering;
14+
protected ModuleWheelBrakes wheelBrakes;
15+
protected ModuleWheelMotor wheelMotor;
1216

1317
public override void OnStart(StartState state)
1418
{
1519
base.OnStart(state);
16-
this.module = base.part.FindModuleImplementing<ModuleWheel>();
20+
this.wheelBase = base.part.FindModuleImplementing<ModuleWheelBase>();
21+
this.wheelSteering = base.part.FindModuleImplementing<ModuleWheelSteering>();
22+
this.wheelBrakes = base.part.FindModuleImplementing<ModuleWheelBrakes>();
23+
this.wheelMotor = base.part.FindModuleImplementing<ModuleWheelMotor>();
1724
}
1825
}
1926
}

Failure Modules/TestFlightFailure_AvionicsTotal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class TestFlightFailure_AvionicsTotal : TestFlightFailureBase_Avionics
99
{
1010
public override void OnFlyByWire(FlightCtrlState s)
1111
{
12-
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource)
12+
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource != Vessel.ControlLevel.FULL)
1313
{
1414
s.pitch = 0;
1515
s.roll = 0;

Failure Modules/TestFlightFailure_ResourcePump.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ private void SetState(PartResource.FlowMode state)
2727
{
2828
List<string> blacklist = this.resourceBlacklist.Split(',').ToList();
2929
List<PartResource> valid = null;
30-
for (int i = 0; i < base.part.Resources.list.Count; i++)
30+
for (int i = 0; i < base.part.Resources.ToList().Count; i++)
3131
{
32-
PartResource res = base.part.Resources.list[i];
32+
PartResource res = base.part.Resources.ToList()[i];
3333
if (!blacklist.Contains(res.resourceName) && res.info.resourceFlowMode != ResourceFlowMode.NO_FLOW)
3434
{
3535
if (this.resourceName == "ALL" || res.resourceName == this.resourceName)

Failure Modules/TestFlightFailure_SolarMech.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace TestFlight.Failure_Modules
1212
public class TestFlightFailure_SolarMech : TestFlightFailureBase_Solar
1313
{
1414
private ITestFlightCore core = null;
15-
private ModuleDeployableSolarPanel.panelStates panelState;
15+
private ModuleDeployableSolarPanel.DeployState panelState;
1616
private bool failureActive = false;
1717
public override void OnStart(StartState state)
1818
{
@@ -36,8 +36,8 @@ IEnumerator Attach()
3636
public void Startup()
3737
{
3838

39-
this.panelState = base.module.panelState;
40-
if (this.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED)
39+
this.panelState = base.module.deployState;
40+
if (this.panelState == ModuleDeployableSolarPanel.DeployState.EXTENDED)
4141
{
4242
core.EnableFailure("TestFlightFailure_SolarMechFail");
4343
}
@@ -48,10 +48,10 @@ public void Startup()
4848
}
4949
public override void OnUpdate()
5050
{
51-
if (this.panelState != base.module.panelState)
51+
if (this.panelState != base.module.deployState)
5252
{
53-
this.panelState = base.module.panelState;
54-
if (TestFlightEnabled && !base.part.ShieldedFromAirstream && (this.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED) != this.failureActive)
53+
this.panelState = base.module.deployState;
54+
if (TestFlightEnabled && !base.part.ShieldedFromAirstream && (this.panelState == ModuleDeployableSolarPanel.DeployState.EXTENDED) != this.failureActive)
5555
{
5656
this.failureActive = !this.failureActive;
5757
if (this.failureActive)

Failure Modules/TestFlightFailure_WheelBrake.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public class TestFlightFailure_WheelBrake : TestFlightFailureBase_Wheel
1010
public override void DoFailure()
1111
{
1212
base.DoFailure();
13-
base.module.Actions["BrakesAction"].active = false;
13+
base.wheelBrakes.Actions["BrakesAction"].active = false;
1414
}
1515
public override float DoRepair()
1616
{
1717
base.DoRepair();
18-
base.module.Actions["BrakesAction"].active = true;
18+
base.wheelBrakes.Actions["BrakesAction"].active = true;
1919
return 0f;
2020
}
2121
}

Failure Modules/TestFlightFailure_WheelMotor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ public class TestFlightFailure_WheelMotor : TestFlightFailureBase_Wheel
1111
public override void DoFailure()
1212
{
1313
base.DoFailure();
14-
this.state = base.module.motorEnabled;
15-
base.module.motorEnabled = false;
16-
base.module.Events["EnableMotor"].active = false;
17-
base.module.Events["DisableMotor"].active = false;
14+
this.state = base.wheelMotor.motorEnabled;
15+
base.wheelMotor.motorEnabled = false;
16+
base.wheelMotor.Events["EnableMotor"].active = false;
17+
base.wheelMotor.Events["DisableMotor"].active = false;
1818

1919
}
2020
public override float DoRepair()
2121
{
2222
base.DoRepair();
23-
base.module.motorEnabled = state;
24-
base.module.Events["EnableMotor"].active = state;
25-
base.module.Events["DisableMotor"].active = !state;
23+
base.wheelMotor.motorEnabled = state;
24+
base.wheelMotor.Events["EnableMotor"].active = state;
25+
base.wheelMotor.Events["DisableMotor"].active = !state;
2626
return 0f;
2727
}
2828
}

Failure Modules/TestFlightFailure_WheelSteer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ public class TestFlightFailure_WheelSteer : TestFlightFailureBase_Wheel
1111
public override void DoFailure()
1212
{
1313
base.DoFailure();
14-
this.state = base.module.steeringLocked;
15-
base.module.steeringLocked = true;
16-
base.module.Events["LockSteering"].active = false;
17-
base.module.Events["UnlockSteering"].active = false;
14+
this.state = base.wheelSteering.steeringEnabled;
15+
base.wheelSteering.steeringEnabled = false;
16+
base.wheelSteering.Events["LockSteering"].active = false;
17+
base.wheelSteering.Events["UnlockSteering"].active = false;
1818
}
1919
public override float DoRepair()
2020
{
2121
base.DoRepair();
22-
base.module.steeringLocked = this.state;
23-
base.module.Events["LockSteering"].active = !this.state;
24-
base.module.Events["UnlockSteering"].active = this.state;
22+
base.wheelSteering.steeringEnabled = this.state;
23+
base.wheelSteering.Events["LockSteering"].active = !this.state;
24+
base.wheelSteering.Events["UnlockSteering"].active = this.state;
2525
return 0f;
2626
}
2727
}

Flight Recorders/FlightDataRecorder_Solar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public override bool IsPartOperating()
2020
{
2121
return false;
2222
}
23-
if (this.module.panelState == ModuleDeployableSolarPanel.panelStates.BROKEN || this.module.panelState == ModuleDeployableSolarPanel.panelStates.RETRACTED)
23+
if (this.module.deployState == ModuleDeployableSolarPanel.DeployState.BROKEN || this.module.deployState == ModuleDeployableSolarPanel.DeployState.RETRACTED)
2424
{
2525
return false;
2626
}
27-
if (this.module.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED && this.module.flowRate < 0.01)
27+
if (this.module.deployState == ModuleDeployableSolarPanel.DeployState.EXTENDED && this.module.flowRate < 0.01)
2828
{
2929
return false;
3030
}

Flight Recorders/FlightDataRecorder_Wheels.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
using System.Linq;
44
using System.Text;
55
using TestFlightAPI;
6+
using ModuleWheels;
67

78
namespace TestFlight.Flight_Recorders
89
{
910
public class FlightDataRecorder_Wheels : FlightDataRecorderBase
1011
{
11-
private ModuleWheel wheel;
12+
private ModuleWheelSteering wheelSteering;
13+
private ModuleWheelBrakes wheelBrakes;
14+
private ModuleWheelBase wheel;
15+
private ModuleWheelMotor wheelMotor;
1216
public override void OnStart(PartModule.StartState state)
1317
{
1418
base.OnStart(state);
15-
wheel = base.part.FindModuleImplementing<ModuleWheel>();
19+
wheel = base.part.FindModuleImplementing<ModuleWheelBase>();
20+
wheelSteering = base.part.FindModuleImplementing<ModuleWheelSteering>();
21+
wheelBrakes = base.part.FindModuleImplementing<ModuleWheelBrakes>();
22+
wheelMotor = base.part.FindModuleImplementing<ModuleWheelMotor>();
1623
}
1724
public override void OnAwake()
1825
{
1926
base.OnAwake();
2027
}
2128
public override bool IsPartOperating()
2229
{
23-
bool isGrounded = false;
24-
for (int i = 0; i < this.wheel.wheels.Count; i++)
25-
{
26-
if (this.wheel.wheels[i].whCollider.isGrounded)
27-
{
28-
isGrounded = true;
29-
break;
30-
}
31-
}
30+
bool isGrounded = wheel.isGrounded;
31+
3232
if (!isGrounded)
3333
{
3434
return false;
3535
}
3636

3737
if ((float)base.vessel.horizontalSrfSpeed > 0f)
3838
{
39-
if (!this.wheel.steeringLocked && Math.Abs(this.wheel.steeringInput) > 0f)
39+
if (this.wheelSteering.steeringEnabled && Math.Abs(this.wheelSteering.steeringInput) > 0f)
4040
{
4141
return true;
4242
}
43-
if (this.wheel.brakesEngaged)
43+
if (this.wheelBrakes.brakeInput < 0f)
4444
{
4545
return true;
4646
}
47-
if (wheel.motorEnabled && Math.Abs(wheel.throttleInput) > 0f)
47+
if (wheelMotor.motorEnabled && Math.Abs(wheelMotor.driveOutput) > 0f)
4848
{
4949
return true;
5050
}

0 commit comments

Comments
 (0)