Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7c626bd30527
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dde29641ffe0
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Aug 23, 2019

  1. hack gravity

    eggrobin committed Aug 23, 2019
    Copy the full SHA
    daa904a View commit details

Commits on Aug 24, 2019

  1. Merge pull request #2296 from eggrobin/gravitational-hacks

    Unmanageable hacks
    eggrobin authored Aug 24, 2019
    Copy the full SHA
    dde2964 View commit details
Showing with 26 additions and 0 deletions.
  1. +26 −0 ksp_plugin_adapter/ksp_plugin_adapter.cs
26 changes: 26 additions & 0 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -142,6 +142,29 @@ private KSP.UI.Screens.SpaceTracking space_tracking {
return space_tracking_;
}
}

private KSP.UI.Screens.DebugToolbar.DebugScreen debug_screen_;
private KSP.UI.Screens.DebugToolbar.Screens.Cheats.HackGravity hack_gravity_;
private KSP.UI.Screens.DebugToolbar.Screens.Cheats.HackGravity hack_gravity {
get {
if (hack_gravity_ == null) {
if (debug_screen_ == null) {
// Force a debug screen to be instantiated, by showing it.
KSP.UI.Screens.DebugToolbar.DebugScreenSpawner.ShowDebugScreen();
debug_screen_ = (KSP.UI.Screens.DebugToolbar.DebugScreen)
FindObjectOfType(typeof(KSP.UI.Screens.DebugToolbar.DebugScreen));
// Now hide it.
debug_screen_.Hide();
}
// Since we have the debug screen, we can restrict our search for the
// gravity-hacking control within it, so as not to slow things down to
// a grind until it is instantiated.
hack_gravity_ = debug_screen_.contentTransform.GetComponentInChildren<
KSP.UI.Screens.DebugToolbar.Screens.Cheats.HackGravity>();
}
return hack_gravity_;
}
}

// TODO(egg): these should be moved to the C++; there it can be made a vector
// because we can test whether we have the part or not. Set in
@@ -400,6 +423,9 @@ private string UnmanageabilityReasons(Vessel vessel) {
if (vessel.isEVA && vessel.evaController?.Ready == false) {
reasons.Add("vessel is an unready Kerbal");
}
if (vessel.loaded && hack_gravity?.toggle.isOn == true) {
reasons.Add("vessel is loaded and gravity is being hacked");
}
if (reasons.Count == 0) {
return null;
} else {