-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to permanently kill avionics (#2402)
- Loading branch information
Showing
5 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using CommNet; | ||
using HarmonyLib; | ||
|
||
namespace RP0.Harmony | ||
{ | ||
[HarmonyPatch(typeof(Vessel))] | ||
internal class PatchVessel | ||
{ | ||
[HarmonyPatch("GetControlLevel")] | ||
internal static bool Prefix_GetControlLevel(Vessel __instance, ref Vessel.ControlLevel __result) | ||
{ | ||
if (__instance.isEVA && __instance.crew.Count > 0) | ||
{ | ||
if (!__instance.crew[0].inactive) | ||
{ | ||
__result = Vessel.ControlLevel.PARTIAL_MANNED; | ||
return false; | ||
} | ||
__result = Vessel.ControlLevel.NONE; | ||
return false; | ||
} | ||
|
||
if (__instance.connection != null && CommNetScenario.Instance != null && CommNetScenario.CommNetEnabled) | ||
{ | ||
__result = __instance.connection.GetControlLevel(); | ||
if (__result == Vessel.ControlLevel.NONE) return false; | ||
} | ||
|
||
var controlLevel = Vessel.ControlLevel.NONE; | ||
int count = __instance.parts.Count; | ||
while (count-- > 0) | ||
{ | ||
Part part = __instance.parts[count]; | ||
if (part.isControlSource > controlLevel) | ||
{ | ||
controlLevel = part.isControlSource; | ||
} | ||
} | ||
|
||
if (controlLevel < __result) __result = controlLevel; | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters