Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Award DU upon engine ignition #285

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions TestFlightAPI/TestFlightAPI/TestFlightFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class TestFlightFailureBase : PartModule, ITestFlightFailure
[KSPField]
public float duFail = 0f;
[KSPField]
public float duSucceed = 0f;
[KSPField]
public float duRepair = 0f;
[KSPField]
public bool oneShot = false;
Expand Down Expand Up @@ -163,6 +165,7 @@ public virtual void SetActiveConfig(string alias)
currentConfig.TryGetValue("weight", ref weight);
currentConfig.TryGetValue("failureTitle", ref failureTitle);
currentConfig.TryGetValue("duFail", ref duFail);
currentConfig.TryGetValue("duSucceed", ref duSucceed);
currentConfig.TryGetValue("duRepair", ref duRepair);
currentConfig.TryGetValue("oneShot", ref oneShot);
currentConfig.TryGetValue("awardDuInPreLaunch", ref awardDuInPreLaunch);
Expand Down
14 changes: 14 additions & 0 deletions TestFlightFailure_IgnitionFail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public override void OnUpdate()
}
else
{
OnIgnition();
engineData.hasBeenRun = true;
}
}
Expand Down Expand Up @@ -648,6 +649,19 @@ private void ShowRestartWindowPenaltyInfo(string sPenaltyPercent)
TestFlightGameSettings tfSettings = HighLogic.CurrentGame.Parameters.CustomParams<TestFlightGameSettings>();
tfSettings.restartWindowPenaltyReminderShown = restartWindowPenaltyReminderShown = true;
}

private void OnIgnition()
{
if (core.GetFlightData() == core.GetInitialFlightData() && (vessel.situation != Vessel.Situations.PRELAUNCH || awardDuInPreLaunch)) //Only award DU on the first ignition of each flight, and only when not attached to launch clamps.
{
float ignitionDU = Mathf.Max(duSucceed, core.GetMaximumData() / 40);
if (verboseDebugging)
{
Log($"IgnitionFail: Awarding successful ignition DU: {ignitionDU:F4}");
}
core.ModifyFlightData(ignitionDU, true); //Award DU for first successful ignition
}
}
}
}