private void updateDisplayState() { KSPWheelState wheelState = controller.wheelState; KSPWheelWearType wearType = HighLogic.CurrentGame.Parameters.CustomParams <KSPWheelSettings>().wearType; Events[nameof(repairWheel)].guiActiveUnfocused = wheelState == KSPWheelState.BROKEN || wearType == KSPWheelWearType.ADVANCED; Fields[nameof(loadStress)].guiActive = wearType != KSPWheelWearType.NONE; Fields[nameof(stressTime)].guiActive = wearType != KSPWheelWearType.NONE; Fields[nameof(displayStatus)].guiActive = wearType != KSPWheelWearType.NONE; Fields[nameof(wheelWear)].guiActive = wearType == KSPWheelWearType.ADVANCED; Fields[nameof(motorWear)].guiActive = wearType == KSPWheelWearType.ADVANCED; Fields[nameof(suspensionWear)].guiActive = wearType == KSPWheelWearType.ADVANCED; Fields[nameof(maxSafeSpeed)].guiActive = Fields[nameof(maxSafeSpeed)].guiActiveEditor = wearType != KSPWheelWearType.NONE; Fields[nameof(maxSafeLoad)].guiActive = Fields[nameof(maxSafeLoad)].guiActiveEditor = wearType != KSPWheelWearType.NONE; switch (wheelState) { case KSPWheelState.RETRACTED: case KSPWheelState.RETRACTING: case KSPWheelState.DEPLOYED: case KSPWheelState.DEPLOYING: displayStatus = "Operational"; break; case KSPWheelState.BROKEN: displayStatus = "Broken"; break; default: break; } }
public void repairWheel() { KSPWheelWearType wearType = HighLogic.CurrentGame.Parameters.CustomParams <KSPWheelSettings>().wearType; if (controller.wheelState == KSPWheelState.BROKEN || (controller.wheelState == KSPWheelState.DEPLOYED && wearType == KSPWheelWearType.ADVANCED)) { MonoBehaviour.print("Repairing wheel!"); switch (wearType) { case KSPWheelWearType.NONE: break; case KSPWheelWearType.SIMPLE: changeWheelState(KSPWheelState.DEPLOYED); invulnerableTime += 5f; controller.wheelRepairTimer = 0.0001f; MonoBehaviour.print("Repaired wheel Simple"); break; case KSPWheelWearType.ADVANCED: if (HighLogic.CurrentGame.Parameters.CustomParams <GameParameters.AdvancedParams>().KerbalExperienceEnabled(HighLogic.CurrentGame.Mode) && FlightGlobals.ActiveVessel.VesselValues.RepairSkill.value < repairLevel) { ScreenMessages.PostScreenMessage("Crew member has insufficient repair skill to fix this " + controller.wheelType.ToLower() + "\nLevel " + repairLevel + " or higher is required."); return; } changeWheelState(KSPWheelState.DEPLOYED); motorWear = 0f; wheelWear = 0f; suspensionWear = 0f; invulnerableTime += 5f; controller.wheelRepairTimer = 0.0001f; MonoBehaviour.print("Repaired wheel. Damage: " + motorWear + " : " + wheelWear + " : " + suspensionWear); //TODO -- add a delay before repairing based on how damaged things were break; default: break; } changeWheelState(KSPWheelState.DEPLOYED); updateWheelMeshes(controller.wheelState); updateDisplayState(); } }