internal static void dbg(string msg, params object[] @params) { if (0 != @params.Length) { msg = string.Format(msg, @params); } ScreenMessages.PostScreenMessage(msg, 1, ScreenMessageStyle.UPPER_CENTER, true); if (SettingsInterface.InGameMail()) { UnityEngine.Debug.Log("[MoarKerbals] " + msg); } }
//Checks to make sure there is at least one kerbal as a DNA source and that there is room to store the new kerbal private bool PartHasRoom(Part part) { if (!SettingsInterface.RequireLivingKerbal()) { //ScreenMessages.PostScreenMessage("Kloning does not need a living kerbal", 3.5f, ScreenMessageStyle.UPPER_CENTER); Utilities.msg("Kloning does not need a living kerbal", 3.5f, ScreenMessageStyle.UPPER_CENTER); } else if (part.protoModuleCrew.Count == 0) { Utilities.msg("Kloning requires at least one test subject", 3.5f, ScreenMessageStyle.UPPER_CENTER); //Log.dbg(String.Format("Kloning requires at least one test subject, no one in: {0}", part.name.ToString())); return(false); } // Log.dbg("Crew counts {0} = {1}", part.protoModuleCrew.Count, part.CrewCapacity); if (part.protoModuleCrew.Count == part.CrewCapacity) { Utilities.msg("No room left in Kloning Bay", 3.5f, ScreenMessageStyle.UPPER_CENTER); //Log.dbg("Kloning requires at least one test subject, No room left in: ", part.name); return(false); } return(true); }
private bool GatherResources(Part part) { //Steps through to gather resources for (int i = 0; i < resourceList.Length; i++) { Log.dbg("GlobalScale: {1}", SettingsInterface.globalKloningCostMultiplier()); double available = part.RequestResource(resourceList[i], resourceAmounts[i]); //debug: //Log.dbg("Costs: {1} : resourceAmounts: {2}", res resList[i], resourceList[i]), available, resourceAmounts[i]); if (available != resourceAmounts[i]) { //Upon not having enough of a resource, returns all previously collected part.RequestResource(resourceList[i], -available); for (int j = 0; j < i; j++) { part.RequestResource(resourceList[j], -resourceAmounts[j]); } ScreenMessages.PostScreenMessage("Insufficient " + resourceList[i] + " to start Kloning (" + available.ToString() + "/" + resourceAmounts[i].ToString() + ")", 3.5f, ScreenMessageStyle.UPPER_CENTER); return(false); } } return(true); }
public void ActivateKlone() { if (PartHasRoom(part) && GatherResources(part)) { System.Random rnd = new System.Random(); if (accidentRate <= rnd.Next(1, 100)) { ProtoCrewMember kerbal = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(); part.AddCrewmember(kerbal); //kerbal.type = ProtoCrewMember.KerbalType.Crew; kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned; if (kerbal.seat != null) { kerbal.seat.SpawnCrew(); } Utilities.msg("Kloning Success! " + kerbal.name + "(Lv " + kerbal.experienceLevel.ToString() + " " + kerbal.experienceTrait.Title + ") has joined your space program"); if (SettingsInterface.SoundOn()) { kloning_success.Play(); } } else { int opt = rnd.Next(0, 100); string culprit = part.protoModuleCrew.First().name; int count = part.protoModuleCrew.Count; while (part.protoModuleCrew.Count > 0) { ProtoCrewMember crewman = part.protoModuleCrew.First(); part.RemoveCrewmember(crewman); crewman.Die(); // crewman.rosterStatus = ProtoCrewMember.RosterStatus.Missing; } if (count > 1) { if (opt < 30) { Utilities.msg("A power surge opens a portal to R'lyeh and all your test subjects vanish!"); } else if (opt < 60) { Utilities.msg("Your Kerbals are lost in the Matrix!"); } else if (opt < 85) { Utilities.msg("Radiation turns " + culprit + " into a monstrous creature from the deep who eats your other kerbals before shambling off!"); } else { Utilities.msg("The Kloning process failed. This is going to take some cleaning."); } } else { if (opt < 30) { Utilities.msg(culprit + " comes out with a goatee, yelling something about a Terran Empire."); } else if (opt < 60) { Utilities.msg(culprit + " mutates into a giant fly, but goes on to have a successful movie career."); } else if (opt < 80) { Utilities.msg("You find the bay empty, a note pinned to the wall 'Gone back to the future'"); } else { Utilities.msg("The Kloning process failed. You lost " + culprit + ", but at least you have pizza now."); } } if (SettingsInterface.SoundOn()) { overload.Play(); } } } GameEvents.onVesselChange.Fire(FlightGlobals.ActiveVessel); }
//Checks to make sure there is at least one kerbal as a DNA source and that there is room to store the new kerbal private bool PartHasRoom(Part part) { if ((part.protoModuleCrew.Count < part.CrewCapacity) && ((part.protoModuleCrew.Count > 0) || SettingsInterface.RequireLivingKerbal())) { return(true); } else { if (part.protoModuleCrew.Count == 0) { ScreenMessages.PostScreenMessage("Kloning requires a test subject Kerbal", 3.5f, ScreenMessageStyle.UPPER_CENTER); } else if (part.protoModuleCrew.Count == part.CrewCapacity) { ScreenMessages.PostScreenMessage("No room left in Kloning Bay", 3.5f, ScreenMessageStyle.UPPER_CENTER); } return(false); } }
IEnumerator SlowUpdate() { while (true) { yield return(new WaitForSeconds((float)SettingsInterface.slowUpdateTime())); if (!readyToKuddle) { Events["ActivateKuddling"].guiActive = false; } if (hasMatingPair && KuddleShackEnabled) { if (GatherResources(part, (float)SettingsInterface.slowUpdateTime() / SettingsInterface.kuddleTimeNeeded())) { int t = (int)(Planetarium.GetUniversalTime() - startMatingTimer); if (t > 1f) { int days = t / SECS_IN_DAY; int hours = (t - days * SECS_IN_DAY) / SECS_IN_HOUR; int minutes = (t - days * SECS_IN_DAY - hours * SECS_IN_HOUR) / SECS_IN_MINUTE; int seconds = t - days * SECS_IN_DAY - hours * SECS_IN_HOUR - minutes * SECS_IN_MINUTE; string time = ""; if (t >= SECS_IN_DAY) { time += days + " days"; } if (t >= SECS_IN_HOUR) { if (time.Length > 0) { time += ", "; } time += hours + " hours"; } if (t >= SECS_IN_MINUTE) { if (time.Length > 0) { time += ", "; } time += minutes + " minutes"; } if (time.Length > 0) { time += ", "; } time += seconds + " seconds"; Logging.Msg(Localizer.Format("#MOAR-Kuddle-01", time.ToString())); timeRemaining = $" {time}"; } if (Planetarium.GetUniversalTime() - startMatingTimer >= SettingsInterface.kuddleTimeNeeded()) { readyToKuddle = true; Events["ActivateKuddling"].guiActive = true; Logging.Msg(s: Localizer.Format("#MOAR-Kuddle-02")); // "Minimum Kuddle Time Reached" } } else { readyToKuddle = false; } } } }