public override void OnUpdate() { bool receiver_on = false; if (has_receiver) { if (part_receiver.isActive()) { receiver_on = true; } } Events["ActivateTransmitter"].active = !IsEnabled && !relay && !receiver_on; Events["DeactivateTransmitter"].active = IsEnabled && !relay; Events["ActivateRelay"].active = !IsEnabled && !relay && !receiver_on; Events["DeactivateRelay"].active = IsEnabled && relay; Fields["beamedpower"].guiActive = IsEnabled && !relay; Fields["transmitPower"].guiActive = IsEnabled && !relay; if (IsEnabled) { if (relay) { statusStr = "Relay Active"; } else { statusStr = "Transmitter Active"; } } else { statusStr = "Inactive."; } double inputPower = nuclear_power + displayed_solar_power; if (inputPower > 1000) { if (inputPower > 1e6) { beamedpower = (inputPower / 1e6).ToString("0.000") + " GW"; } else { beamedpower = (inputPower / 1000).ToString("0.000") + " MW"; } } else { beamedpower = inputPower.ToString("0.000") + " KW"; } }
public void Update() { if (!HighLogic.LoadedSceneIsFlight) { power_capacity = maximumPower * powerMult; return; } UpdateRelayWavelength(); totalAbsorptionPercentage = atmosphericAbsorptionPercentage + waterAbsorptionPercentage; atmosphericAbsorption = totalAbsorptionPercentage / 100; bool vesselInSpace = (vessel.situation == Vessel.Situations.ORBITING || vessel.situation == Vessel.Situations.ESCAPING || vessel.situation == Vessel.Situations.SUB_ORBITAL); bool receiver_on = part_receiver != null && part_receiver.isActive(); canBeActive = CanBeActive; if (anim != null && !canBeActive && IsEnabled && part.vessel.isActiveVessel && !CheatOptions.UnbreakableJoints) { if (relay) { var message = "Disabled relay because of static pressure atmosphere"; ScreenMessages.PostScreenMessage(message, 5f, ScreenMessageStyle.UPPER_CENTER); Debug.Log("KSPI - " + message); DeactivateRelay(); } else { var message = "Disabled transmitter because of static pressure atmosphere"; ScreenMessages.PostScreenMessage(message, 5f, ScreenMessageStyle.UPPER_CENTER); Debug.Log("KSPI - " + message); DeactivateTransmitter(); } } var canOperateInCurrentEnvironment = this.canFunctionOnSurface || vesselInSpace; var vesselCanTransmit = canTransmit && canOperateInCurrentEnvironment; Events["ActivateTransmitter"].active = activeBeamGenerator != null && vesselCanTransmit && !IsEnabled && !relay && !receiver_on && canBeActive; Events["DeactivateTransmitter"].active = IsEnabled; canRelay = this.hasLinkedReceivers && canOperateInCurrentEnvironment; Events["ActivateRelay"].active = canRelay && !IsEnabled && !relay && !receiver_on && canBeActive; Events["DeactivateRelay"].active = relay; mergingBeams = IsEnabled && canRelay && isBeamMerger; bool isTransmitting = IsEnabled && !relay; Fields["apertureDiameter"].guiActive = isTransmitting; Fields["beamedpower"].guiActive = isTransmitting && canBeActive; Fields["transmitPower"].guiActive = isTransmitting; Fields["displayed_solar_power"].guiActive = isTransmitting && displayed_solar_power > 0; bool isLinkedForRelay = part_receiver != null && part_receiver.linkedForRelay; bool receiverNotInUse = !isLinkedForRelay && !receiver_on && !IsRelay; Fields["moistureModifier"].guiActive = receiverNotInUse; Fields["totalAbsorptionPercentage"].guiActive = receiverNotInUse; Fields["wavelength"].guiActive = receiverNotInUse; Fields["wavelengthName"].guiActive = receiverNotInUse; if (IsEnabled) { statusStr = "Transmitter Active"; } else if (relay) { statusStr = "Relay Active"; } else { if (isLinkedForRelay) { statusStr = "Is Linked For Relay"; } else if (receiver_on) { statusStr = "Receiver active"; } else if (canRelay) { statusStr = "Is ready for relay"; } else if (beamGenerators.Count == 0) { statusStr = "No beam generator found"; } else { statusStr = "Inactive."; } } if (activeBeamGenerator == null) { var wavelegthField = Fields["wavelength"]; wavelegthField.guiActive = false; wavelegthField.guiActiveEditor = false; var atmosphericAbsorptionPercentageField = Fields["atmosphericAbsorptionPercentage"]; atmosphericAbsorptionPercentageField.guiActive = false; atmosphericAbsorptionPercentageField.guiActiveEditor = false; var waterAbsorptionPercentageField = Fields["waterAbsorptionPercentage"]; waterAbsorptionPercentageField.guiActive = false; waterAbsorptionPercentageField.guiActiveEditor = false; return; } wavelength = activeBeamGenerator.wavelength; wavelengthText = WavelenthToText(wavelength); atmosphericAbsorptionPercentage = activeBeamGenerator.atmosphericAbsorptionPercentage; waterAbsorptionPercentage = activeBeamGenerator.waterAbsorptionPercentage * moistureModifier; double inputPower = nuclear_power + displayed_solar_power; if (inputPower > 1000) { if (inputPower > 1e6) { beamedpower = (inputPower / 1e6).ToString("0.000") + " GW"; } else { beamedpower = (inputPower / 1000).ToString("0.000") + " MW"; } } else { beamedpower = inputPower.ToString("0.000") + " KW"; } }
public void Update() { if (!HighLogic.LoadedSceneIsFlight) { return; } UpdateRelayWavelength(); //Debug.Log("[KSP Interstellar] UpdateFromGUI updated wave data"); totalAbsorptionPercentage = atmosphericAbsorptionPercentage + waterAbsorptionPercentage; atmosphericAbsorption = totalAbsorptionPercentage / 100; bool vesselInSpace = (vessel.situation == Vessel.Situations.ORBITING || vessel.situation == Vessel.Situations.ESCAPING || vessel.situation == Vessel.Situations.SUB_ORBITAL); bool receiver_on = part_receiver != null && part_receiver.isActive(); canBeActive = CanBeActive; if (anim != null && !canBeActive && IsEnabled) { if (relay) { DeactivateRelay(); } else { DeactivateTransmitter(); } } var canOperateInCurrentEnvironment = this.canFunctionOnSurface || vesselInSpace; var vesselCanTransmit = canTransmit && canOperateInCurrentEnvironment; Events["ActivateTransmitter"].active = activeBeamGenerator != null && vesselCanTransmit && !IsEnabled && !relay && !receiver_on && canBeActive; Events["DeactivateTransmitter"].active = activeBeamGenerator != null && vesselCanTransmit && IsEnabled && !relay; var transmitterCanRelay = this.hasLinkedReceivers && canOperateInCurrentEnvironment; Events["ActivateRelay"].active = transmitterCanRelay && !IsEnabled && !relay && !receiver_on && canBeActive; Events["DeactivateRelay"].active = transmitterCanRelay && IsEnabled && relay; bool isTransmitting = IsEnabled && !relay; Fields["apertureDiameter"].guiActive = isTransmitting; Fields["beamedpower"].guiActive = isTransmitting && canBeActive; Fields["transmitPower"].guiActive = isTransmitting; Fields["solarPowertransmission"].guiActive = isTransmitting; Fields["displayed_solar_power"].guiActive = isTransmitting && displayed_solar_power > 0; if (IsEnabled) { if (relay) { statusStr = "Relay Active"; } else { statusStr = "Transmitter Active"; } } else { statusStr = "Inactive."; } if (activeBeamGenerator == null) { var wavelegthField = Fields["wavelength"]; wavelegthField.guiActive = false; wavelegthField.guiActiveEditor = false; var atmosphericAbsorptionPercentageField = Fields["atmosphericAbsorptionPercentage"]; atmosphericAbsorptionPercentageField.guiActive = false; atmosphericAbsorptionPercentageField.guiActiveEditor = false; var waterAbsorptionPercentageField = Fields["waterAbsorptionPercentage"]; waterAbsorptionPercentageField.guiActive = false; waterAbsorptionPercentageField.guiActiveEditor = false; return; } wavelength = activeBeamGenerator.wavelength; atmosphericAbsorptionPercentage = activeBeamGenerator.atmosphericAbsorptionPercentage; waterAbsorptionPercentage = activeBeamGenerator.waterAbsorptionPercentage * moistureModifier; double inputPower = nuclear_power + displayed_solar_power; if (inputPower > 1000) { if (inputPower > 1e6) { beamedpower = (inputPower / 1e6).ToString("0.000") + " GW"; } else { beamedpower = (inputPower / 1000).ToString("0.000") + " MW"; } } else { beamedpower = inputPower.ToString("0.000") + " KW"; } }