private void FreezeKerbals() { if (!ReadyToFreeze()) //) { FreezerEngaged = false; return; } else { FirstFreeze = true; FreezeTime = Planetarium.GetUniversalTime(); KerbalName = ""; var count = part.protoModuleCrew.Count(); for (int i = count; i-- > 0;) { var c = part.protoModuleCrew[i]; KerbalName += c.name + "|"; var msg = string.Format("{0} has been frozen", c.name); vessel.CrewListSetDirty(); LifeSupportUtilities.RemoveCrewFromPart(c, vessel); c.rosterStatus = ProtoCrewMember.RosterStatus.Missing; c.SetTimeForRespawn(double.MaxValue); part.RemoveCrewmember(c); LifeSupportManager.Instance.UntrackKerbal(KerbalName); ScreenMessages.PostScreenMessage(msg, 5f, ScreenMessageStyle.UPPER_CENTER); } KerbalName = KerbalName.TrimEnd('|'); } SetMenu(); }
public override void OnUpdate() { if (FreezerEngaged) { CryoTime = LifeSupportUtilities.SmartDurationDisplay(Planetarium.GetUniversalTime() - FreezeTime); CryoMargin = String.Format("{0:0.00}%", (1 - CalculateMargin()) * 100); } else { CryoTime = "Not Active"; CryoMargin = String.Format("{0:0.00}%", 100f); } base.OnUpdate(); }
public override void OnUpdate() { Fields["KerbabyCountdown"].guiActive = KolonyGrowthEnabled; // We don't need to update kolony growth hyperactively, once per second is more than sufficient var now = Planetarium.GetUniversalTime(); var elapsedTime = now - _lastCheck; if (elapsedTime >= 1d) { _lastCheck = now; if (KolonyGrowthEnabled && part.CrewCapacity > part.protoModuleCrew.Count) { var hasMale = false; var hasFemale = false; var crew = vessel.GetVesselCrew(); var count = crew.Count; for (int i = 0; i < count; ++i) { var c = crew[i]; if (c.gender == ProtoCrewMember.Gender.Male) { hasMale = true; } if (c.gender == ProtoCrewMember.Gender.Female) { hasFemale = true; } } if (hasMale && hasFemale) { // Grow our Kolony! GrowthTime += (elapsedTime * part.protoModuleCrew.Count); if (GrowthTime >= GestationTime) { GrowthTime -= GestationTime; SpawnKerbal(); } KerbabyCountdown = LifeSupportUtilities.SmartDurationDisplay(GestationTime - GrowthTime); } } } }
public static void Display(Vessel vessel) { var HAB_RANGE = (float)LifeSupportScenario.Instance.settings.GetSettings().HabRange; var vessels = GetKolonyVessels(vessel, HAB_RANGE, true, false).OrderBy(v => v.thisVessel); var kolonyCrew = vessels.Sum(v => v.vessel.GetCrewCount()); var kolonyCrewCapacity = vessels.Sum(v => v.vessel.GetCrewCapacity()); PrintLine(40, "kolonyCrew", String.Format("{0}/{1}", kolonyCrew, kolonyCrewCapacity)); double partsHabTime = 0d; double partsMultiplierBoost = 0d; foreach (var v in vessels) { var vesselLabel = v.thisVessel ? v.name : String.Format("{0} ({1}m away)", v.name, (int)v.distance); PrintLine(40, "In " + vesselLabel); if (v.vessel.GetCrewCapacity() == 0) { PrintLine(50, "No crew capacity, not contributing to hab"); continue; } PrintLine(50, String.Format("Crew: {0}/{1}", v.vessel.GetCrewCount(), v.vessel.GetCrewCapacity())); foreach (var hab in v.vessel.FindPartModulesImplementing <ModuleHabitation>()) { if (hab.BonusList.ContainsKey("SwapBay") && (hab.BonusList["SwapBay"] < float.Epsilon)) { continue; // Not configured } double partHabTime; double partMultiplierBoost; ExplainHabModule(hab, kolonyCrew, out partHabTime, out partMultiplierBoost); partsHabTime += partHabTime; partsMultiplierBoost += partMultiplierBoost; } } var buttonLabel = IsExpanded(_baseSection) ? "<<" : ">>"; GUILayout.BeginHorizontal(); GUILayout.Label("", _labelStyle, GUILayout.Width(60)); GUILayout.Label("Base (non parts)", _labelStyle); if (GUILayout.Button(buttonLabel, GUILayout.ExpandWidth(false))) { Toggle(_baseSection); } GUILayout.EndHorizontal(); var settingsBaseHabTime = LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime; var capacityHabTime = settingsBaseHabTime * kolonyCrewCapacity; var bonusMultiplierBoost = USI_GlobalBonuses.Instance.GetHabBonus(vessel.mainBody.flightGlobalsIndex); if (IsExpanded(_baseSection)) { PrintLine(80, "settingsBaseHabTime", String.Format("{0:0.##}", settingsBaseHabTime), "from settings"); PrintLine(80, "capacityHabTime", String.Format("{0:0.##}", capacityHabTime), "settingsBaseHabTime * kolonyCrewCapacity"); PrintLine(80, "bonus", String.Format("{0:0.###}", bonusMultiplierBoost), "kolonization research bonus progress"); } PrintLine(70, "-->", String.Format("+{0:0.##}K-month", capacityHabTime), String.Format("x{0:0.###}", bonusMultiplierBoost)); var multiplierBoost = partsMultiplierBoost + bonusMultiplierBoost; PrintLine(40, "multiplierBoost", String.Format("x{0:0.##}", multiplierBoost), "sum of(parts + base)"); var multiplier = 1 + multiplierBoost; PrintLine(40, "multiplier", String.Format("x{0:0.##}", multiplier), "1 + multiplierBoost"); var rawHabTime = partsHabTime + capacityHabTime; PrintLine(40, "rawHabTime", String.Format("{0:0.##}", rawHabTime), "sum of(parts + base)"); var settingsMultiplier = LifeSupportScenario.Instance.settings.GetSettings().HabMultiplier; var settingsMultiplierAddendum = ""; if (settingsMultiplier != 1) { PrintLine(40, "settingsMultiplier", String.Format("{0:0.##}", settingsMultiplier), "from settings"); settingsMultiplierAddendum = " * settingsMultiplier"; } var result = (rawHabTime / kolonyCrew) * multiplier * settingsMultiplier; var formattedResult = LifeSupportUtilities.DurationDisplay(result * LifeSupportUtilities.SecondsPerMonth(), LifeSupportUtilities.TimeFormatLength.Short); PrintLine(40, " -> Vessel hab time", String.Format("{0:0.##} months = {1}", result, formattedResult), "(rawHabTime / kolonyCrew) * multiplier" + settingsMultiplierAddendum); }