public void Update() { // in flight if (Lib.IsFlight()) { // get info from cache Vessel_Info vi = Cache.VesselInfo(vessel); // do nothing if vessel is invalid if (!vi.is_valid) { return; } // update ui bool has_operator = operator_cs.Check(vessel); Events["Toggle"].guiName = Lib.StatusToggle(exp_name, !recording ? "stopped" : issue.Length == 0 ? "recording" : Lib.BuildString("<color=#ffff00>", issue, "</color>")); } // in the editor else if (Lib.IsEditor()) { // update ui Events["Toggle"].guiName = Lib.StatusToggle(exp_name, recording ? "recording" : "stopped"); } }
public override void Update() { if (Lib.IsFlight() && Features.Deploy) { // Check if it is transmitting if (!Features.Science && Features.Signal) { if (antenna != null) { isTransmitting = antenna.stream.Transmitting(); } } else if (Features.Science) { // get info from the cache Vessel_Info vi = Cache.VesselInfo(vessel); // consume ec if data is transmitted or relayed if (vi == null) { isTransmitting = false; } else { isTransmitting = (vi.transmitting.Length > 0 || vi.relaying.Length > 0); } } base.Update(); if (isTransmitting && isConsuming && !isAnimation) { if (Features.Signal) { actualECCost = antenna.cost; } else if (Features.KCommNet) { NetworkAdaptor adap = part.FindModuleImplementing <NetworkAdaptor>(); if (adap != null) { actualECCost = adap.ecCost; } else { actualECCost = 0; } } // Kerbalism already has logic to consume EC when it is transmitting isConsuming = false; } } }
protected override void OnUpdate() { foreach (Vessel v in FlightGlobals.Vessels) { Vessel_Info vi = Cache.VesselInfo(v); if (!vi.is_valid) { continue; } bool manned = vi.crew_count > 0; bool in_orbit = Sim.Apoapsis(v) > v.mainBody.atmosphereDepth && Sim.Periapsis(v) > v.mainBody.atmosphereDepth; bool for_30days = v.missionTime > 60.0 * 60.0 * Lib.HoursInDay() * 30.0; if (manned && in_orbit && for_30days) { SetComplete(); DB.landmarks.manned_orbit = true; //< remember that contract was completed break; } } }
public static void Config(this Panel p, Vessel v) { // avoid corner-case when this is called in a lambda after scene changes v = FlightGlobals.FindVessel(v.id); // if vessel doesn't exist anymore, leave the panel empty if (v == null) { return; } // get info from the cache Vessel_Info vi = Cache.VesselInfo(v); // if not a valid vessel, leave the panel empty if (!vi.is_valid) { return; } // set metadata p.Title(Lib.BuildString(Lib.Ellipsis(v.vesselName, 20), " <color=#cccccc>VESSEL CONFIG</color>")); // time-out simulation if (p.Timeout(vi)) { return; } // get data from db VesselData vd = DB.Vessel(v); // toggle rendering string tooltip; if (Features.Signal || Features.Reliability) { p.SetSection("RENDERING"); } if (Features.Signal) { tooltip = "Render the connection line\nin mapview and tracking station"; p.SetContent("show links", string.Empty, tooltip); p.SetIcon(vd.cfg_showlink ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_showlink)); } if (Features.Reliability) { tooltip = "Highlight failed components"; p.SetContent("highlight malfunctions", string.Empty, tooltip); p.SetIcon(vd.cfg_highlights ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_highlights)); } // toggle messages p.SetSection("MESSAGES"); tooltip = "Receive a message when\nElectricCharge level is low"; p.SetContent("battery", string.Empty, tooltip); p.SetIcon(vd.cfg_ec ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_ec)); if (Features.Supplies) { tooltip = "Receive a message when\nsupply resources level is low"; p.SetContent("supply", string.Empty, tooltip); p.SetIcon(vd.cfg_supply ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_supply)); } if (Features.Signal || Features.KCommNet) { tooltip = "Receive a message when signal is lost or obtained"; p.SetContent("signal", string.Empty, tooltip); p.SetIcon(vd.cfg_signal ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_signal)); } if (Features.Reliability) { tooltip = "Receive a message\nwhen a component fail"; p.SetContent("reliability", string.Empty, tooltip); p.SetIcon(vd.cfg_malfunction ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_malfunction)); } if (Features.SpaceWeather) { tooltip = "Receive a message\nduring CME events"; p.SetContent("storm", string.Empty, tooltip); p.SetIcon(vd.cfg_storm ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_storm)); } if (Features.Automation) { tooltip = "Receive a message when\nscripts are executed"; p.SetContent("script", string.Empty, tooltip); p.SetIcon(vd.cfg_script ? Icons.toggle_green : Icons.toggle_red, tooltip, () => p.Toggle(ref vd.cfg_script)); } }
public static void BackgroundUpdate(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot antenna, Vessel_Info vi, Resource_Info ec, double elapsed_s) { if (Features.Deploy) { bool isDeploy; bool has_ec = ec.amount > double.Epsilon; ProtoPartModuleSnapshot deployModule = p.FindModule("AntennaDeploy"); ProtoPartModuleSnapshot anim; if (deployModule == null) { Lib.Debug("AntennaDeploy is null. Load vessel to try fix it"); return; } // if it is transmitting, leave with Kerbalism if (Features.Science && (vi.transmitting.Length > 0 || vi.relaying.Length > 0)) { return; } if (has_ec) { if (Features.Signal) { anim = p.FindModule("ModuleAnimationGroup"); if (anim != null) { isDeploy = Lib.Proto.GetBool(anim, "isDeployed"); } else { isDeploy = true; } if (!Settings.ExtendedAntenna || isDeploy) { Lib.Proto.Set(antenna, "extended", true); ec.Consume(Lib.Proto.GetDouble(deployModule, "ecCost") * elapsed_s); } } else if (Features.KCommNet) { anim = p.FindModule("ModuleDeployableAntenna"); if (anim != null) { isDeploy = Lib.Proto.GetString(anim, "deployState") == "EXTENDED"; } else { isDeploy = true; } if (isDeploy) { Lib.Proto.Set(antenna, "canComm", true); ec.Consume(Lib.Proto.GetDouble(deployModule, "ecCost") * elapsed_s); } } } else { if (Features.Signal) { Lib.Proto.Set(antenna, "extended", false); } else if (Features.KCommNet) { Lib.Proto.Set(antenna, "canComm", false); } } } }