Skip to content

Commit

Permalink
KSP 1.2 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvanderbeck committed Jan 5, 2017
1 parent 47d4f92 commit 3064dbb
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Failure Bases/TestFlightFailureBase_Avionics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override float DoRepair()
}
public virtual void OnFlyByWire(FlightCtrlState s)
{
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource)
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource != Vessel.ControlLevel.FULL)
{
return;
}
Expand Down
11 changes: 9 additions & 2 deletions Failure Bases/TestFlightFailureBase_Wheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
using System.Linq;
using System.Text;
using TestFlightAPI;
using ModuleWheels;

namespace TestFlight
{
public class TestFlightFailureBase_Wheel : TestFlightFailureBase
{
protected ModuleWheel module;
protected ModuleWheelBase wheelBase;
protected ModuleWheelSteering wheelSteering;
protected ModuleWheelBrakes wheelBrakes;
protected ModuleWheelMotor wheelMotor;

public override void OnStart(StartState state)
{
base.OnStart(state);
this.module = base.part.FindModuleImplementing<ModuleWheel>();
this.wheelBase = base.part.FindModuleImplementing<ModuleWheelBase>();
this.wheelSteering = base.part.FindModuleImplementing<ModuleWheelSteering>();
this.wheelBrakes = base.part.FindModuleImplementing<ModuleWheelBrakes>();
this.wheelMotor = base.part.FindModuleImplementing<ModuleWheelMotor>();
}
}
}
2 changes: 1 addition & 1 deletion Failure Modules/TestFlightFailure_AvionicsTotal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TestFlightFailure_AvionicsTotal : TestFlightFailureBase_Avionics
{
public override void OnFlyByWire(FlightCtrlState s)
{
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource)
if (base.vessel == null || base.vessel != FlightGlobals.ActiveVessel || base.part.isControlSource != Vessel.ControlLevel.FULL)
{
s.pitch = 0;
s.roll = 0;
Expand Down
4 changes: 2 additions & 2 deletions Failure Modules/TestFlightFailure_ResourcePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ private void SetState(PartResource.FlowMode state)
{
List<string> blacklist = this.resourceBlacklist.Split(',').ToList();
List<PartResource> valid = null;
for (int i = 0; i < base.part.Resources.list.Count; i++)
for (int i = 0; i < base.part.Resources.ToList().Count; i++)
{
PartResource res = base.part.Resources.list[i];
PartResource res = base.part.Resources.ToList()[i];
if (!blacklist.Contains(res.resourceName) && res.info.resourceFlowMode != ResourceFlowMode.NO_FLOW)
{
if (this.resourceName == "ALL" || res.resourceName == this.resourceName)
Expand Down
12 changes: 6 additions & 6 deletions Failure Modules/TestFlightFailure_SolarMech.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TestFlight.Failure_Modules
public class TestFlightFailure_SolarMech : TestFlightFailureBase_Solar
{
private ITestFlightCore core = null;
private ModuleDeployableSolarPanel.panelStates panelState;
private ModuleDeployableSolarPanel.DeployState panelState;
private bool failureActive = false;
public override void OnStart(StartState state)
{
Expand All @@ -36,8 +36,8 @@ IEnumerator Attach()
public void Startup()
{

this.panelState = base.module.panelState;
if (this.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED)
this.panelState = base.module.deployState;
if (this.panelState == ModuleDeployableSolarPanel.DeployState.EXTENDED)
{
core.EnableFailure("TestFlightFailure_SolarMechFail");
}
Expand All @@ -48,10 +48,10 @@ public void Startup()
}
public override void OnUpdate()
{
if (this.panelState != base.module.panelState)
if (this.panelState != base.module.deployState)
{
this.panelState = base.module.panelState;
if (TestFlightEnabled && !base.part.ShieldedFromAirstream && (this.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED) != this.failureActive)
this.panelState = base.module.deployState;
if (TestFlightEnabled && !base.part.ShieldedFromAirstream && (this.panelState == ModuleDeployableSolarPanel.DeployState.EXTENDED) != this.failureActive)
{
this.failureActive = !this.failureActive;
if (this.failureActive)
Expand Down
4 changes: 2 additions & 2 deletions Failure Modules/TestFlightFailure_WheelBrake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class TestFlightFailure_WheelBrake : TestFlightFailureBase_Wheel
public override void DoFailure()
{
base.DoFailure();
base.module.Actions["BrakesAction"].active = false;
base.wheelBrakes.Actions["BrakesAction"].active = false;
}
public override float DoRepair()
{
base.DoRepair();
base.module.Actions["BrakesAction"].active = true;
base.wheelBrakes.Actions["BrakesAction"].active = true;
return 0f;
}
}
Expand Down
14 changes: 7 additions & 7 deletions Failure Modules/TestFlightFailure_WheelMotor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public class TestFlightFailure_WheelMotor : TestFlightFailureBase_Wheel
public override void DoFailure()
{
base.DoFailure();
this.state = base.module.motorEnabled;
base.module.motorEnabled = false;
base.module.Events["EnableMotor"].active = false;
base.module.Events["DisableMotor"].active = false;
this.state = base.wheelMotor.motorEnabled;
base.wheelMotor.motorEnabled = false;
base.wheelMotor.Events["EnableMotor"].active = false;
base.wheelMotor.Events["DisableMotor"].active = false;

}
public override float DoRepair()
{
base.DoRepair();
base.module.motorEnabled = state;
base.module.Events["EnableMotor"].active = state;
base.module.Events["DisableMotor"].active = !state;
base.wheelMotor.motorEnabled = state;
base.wheelMotor.Events["EnableMotor"].active = state;
base.wheelMotor.Events["DisableMotor"].active = !state;
return 0f;
}
}
Expand Down
14 changes: 7 additions & 7 deletions Failure Modules/TestFlightFailure_WheelSteer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public class TestFlightFailure_WheelSteer : TestFlightFailureBase_Wheel
public override void DoFailure()
{
base.DoFailure();
this.state = base.module.steeringLocked;
base.module.steeringLocked = true;
base.module.Events["LockSteering"].active = false;
base.module.Events["UnlockSteering"].active = false;
this.state = base.wheelSteering.steeringEnabled;
base.wheelSteering.steeringEnabled = false;
base.wheelSteering.Events["LockSteering"].active = false;
base.wheelSteering.Events["UnlockSteering"].active = false;
}
public override float DoRepair()
{
base.DoRepair();
base.module.steeringLocked = this.state;
base.module.Events["LockSteering"].active = !this.state;
base.module.Events["UnlockSteering"].active = this.state;
base.wheelSteering.steeringEnabled = this.state;
base.wheelSteering.Events["LockSteering"].active = !this.state;
base.wheelSteering.Events["UnlockSteering"].active = this.state;
return 0f;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Flight Recorders/FlightDataRecorder_Solar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public override bool IsPartOperating()
{
return false;
}
if (this.module.panelState == ModuleDeployableSolarPanel.panelStates.BROKEN || this.module.panelState == ModuleDeployableSolarPanel.panelStates.RETRACTED)
if (this.module.deployState == ModuleDeployableSolarPanel.DeployState.BROKEN || this.module.deployState == ModuleDeployableSolarPanel.DeployState.RETRACTED)
{
return false;
}
if (this.module.panelState == ModuleDeployableSolarPanel.panelStates.EXTENDED && this.module.flowRate < 0.01)
if (this.module.deployState == ModuleDeployableSolarPanel.DeployState.EXTENDED && this.module.flowRate < 0.01)
{
return false;
}
Expand Down
28 changes: 14 additions & 14 deletions Flight Recorders/FlightDataRecorder_Wheels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@
using System.Linq;
using System.Text;
using TestFlightAPI;
using ModuleWheels;

namespace TestFlight.Flight_Recorders
{
public class FlightDataRecorder_Wheels : FlightDataRecorderBase
{
private ModuleWheel wheel;
private ModuleWheelSteering wheelSteering;
private ModuleWheelBrakes wheelBrakes;
private ModuleWheelBase wheel;
private ModuleWheelMotor wheelMotor;
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
wheel = base.part.FindModuleImplementing<ModuleWheel>();
wheel = base.part.FindModuleImplementing<ModuleWheelBase>();
wheelSteering = base.part.FindModuleImplementing<ModuleWheelSteering>();
wheelBrakes = base.part.FindModuleImplementing<ModuleWheelBrakes>();
wheelMotor = base.part.FindModuleImplementing<ModuleWheelMotor>();
}
public override void OnAwake()
{
base.OnAwake();
}
public override bool IsPartOperating()
{
bool isGrounded = false;
for (int i = 0; i < this.wheel.wheels.Count; i++)
{
if (this.wheel.wheels[i].whCollider.isGrounded)
{
isGrounded = true;
break;
}
}
bool isGrounded = wheel.isGrounded;

if (!isGrounded)
{
return false;
}

if ((float)base.vessel.horizontalSrfSpeed > 0f)
{
if (!this.wheel.steeringLocked && Math.Abs(this.wheel.steeringInput) > 0f)
if (this.wheelSteering.steeringEnabled && Math.Abs(this.wheelSteering.steeringInput) > 0f)
{
return true;
}
if (this.wheel.brakesEngaged)
if (this.wheelBrakes.brakeInput < 0f)
{
return true;
}
if (wheel.motorEnabled && Math.Abs(wheel.throttleInput) > 0f)
if (wheelMotor.motorEnabled && Math.Abs(wheelMotor.driveOutput) > 0f)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion FlightDataRecorder_Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override bool IsRecordingFlightData()
if (this.part.vessel.situation == Vessel.Situations.PRELAUNCH)
return false;

List<PartResource> partResources = this.part.Resources.list;
List<PartResource> partResources = this.part.Resources.ToList();
foreach (PartResource resource in partResources)
{
if (resource.amount > emptyThreshold)
Expand Down
Binary file modified GameData/TestFlight/Plugins/TestFlight.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightAPI.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightContracts.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightContracts.dll.mdb
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightCore.dll
Binary file not shown.
26 changes: 19 additions & 7 deletions TestFlight.userprefs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Properties StartupItem="TestFlight.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestFlightAPI/TestFlightAPI/TestFlightAPI.cs">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestFlightCore/TestFlightCore/UserSettings.cs">
<Files>
<File FileName="TestFlightCore/TestFlightCore/TestFlight.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightCore.cs" Line="1" Column="1" />
<File FileName="TestFlightAPI/TestFlightAPI/TestFlightAPI.cs" Line="14" Column="13" />
<File FileName="TestFlightAPI/TestFlightAPI/TestFlightAPI.cs" Line="1" Column="1" />
<File FileName="TestFlightContracts/TestFlightContractConfigurator.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightInterface.cs" Line="1" Column="1" />
<File FileName="TestFlightAPI/TestFlightAPI/TestFlightPartData.cs" Line="1" Column="1" />
Expand All @@ -16,7 +16,6 @@
<File FileName="TestFlightFailure_ShutdownEngine.cs" Line="1" Column="1" />
<File FileName="TestFlightAPI/TestFlightAPI/TestFlightFailure.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightWindow.cs" Line="1" Column="1" />
<File FileName="KSPFramework/ConfigNodeStorage.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightRnD.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightEditor.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightHUD.cs" Line="1" Column="1" />
Expand All @@ -28,10 +27,23 @@
<File FileName="TestFlightAPI/TestFlightAPI/TestFlightReliability.cs" Line="1" Column="1" />
<File FileName="TestFlightReliability_EngineCycle.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/TestFlightRnDScenario.cs" Line="1" Column="1" />
<File FileName="TestFlightRF/TestFlightRealFuels.cs" Line="1" Column="1" />
<File FileName="TestFlightRF/Properties/AssemblyInfo.cs" Line="1" Column="1" />
<File FileName="TestFlightFailure_Engine.cs" Line="1" Column="1" />
<File FileName="../../../../../../../../../../Library/Frameworks/Mono.framework/Versions/4.2.4/lib/mono/4.5/Microsoft.Common.targets" Line="1" Column="1" />
<File FileName="TestFlightReliability.cs" Line="1" Column="1" />
<File FileName="TestFlightReliability_TestFail.cs" Line="1" Column="1" />
<File FileName="FlightDataRecorder.cs" Line="1" Column="1" />
<File FileName="FlightDataRecorder_Resources.cs" Line="1" Column="1" />
<File FileName="TestFlightFailure_EnginePerformanceLoss.cs" Line="1" Column="1" />
<File FileName="TestFlightFailure_LockGimbal.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/Framework/ConfigNodeStorage.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/Framework/ExtensionsUnity.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/Framework/SkinsLibrary.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/FrameworkExt/Extensions.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/BodySettings.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/Resources.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/StylesAndSkins.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/UserInterface.cs" Line="1" Column="1" />
<File FileName="TestFlightCore/TestFlightCore/UserSettings.cs" Line="32" Column="60" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down
4 changes: 2 additions & 2 deletions TestFlightFailure_ResourceLeak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ public override void DoFailure()
{
if (part.Resources.Count > 0)
{
List<PartResource> allResources = this.part.Resources.list;
List<PartResource> allResources = this.part.Resources.ToList();
int randomResource = TestFlightUtil.GetCore(this.part, Configuration).RandomGenerator.Next(0, allResources.Count());
resId = allResources[randomResource].info.id;
found = true;
}
}
else
{
List<PartResource> resources = this.part.Resources.list.Where(n => n.resourceName == resourceToLeak).ToList();
List<PartResource> resources = this.part.Resources.ToList().Where(n => n.resourceName == resourceToLeak).ToList();
if (resources != null && resources.Count > 0)
{
resId = resources[0].info.id;
Expand Down

0 comments on commit 3064dbb

Please sign in to comment.