public void EmergencyHarvest() { // disable for dead eva kerbals Vessel v = FlightGlobals.ActiveVessel; if (v == null || EVA.IsDead(v)) { return; } // calculate reduced harvest size double reduced_harvest = crop_size * growth * 0.5; // produce reduced quantity of food, proportional to current growth ResourceCache.Produce(vessel, crop_resource, reduced_harvest, "greenhouse"); // reset growth growth = 0.0; // show message Message.Post(Lib.BuildString("On <color=ffffff>", vessel.vesselName, "</color> emergency harvest produced <color=ffffff>", reduced_harvest.ToString("F0"), " ", crop_resource, "</color>")); // record first harvest if (!Lib.Landed(vessel)) { DB.landmarks.space_harvest = true; } }
[KSPEvent(guiActive = true, guiActiveUnfocused = true, guiName = "#KERBALISM_Greenhouse_Harvest", active = false, groupName = "Greenhouse", groupDisplayName = "#KERBALISM_Group_Greenhouse")] //Greenhouse public void Harvest() { // disable for dead eva kerbals Vessel v = FlightGlobals.ActiveVessel; if (v == null || EVA.IsDead(v)) { return; } // produce reduced quantity of food, proportional to current growth ResourceCache.Produce(vessel, crop_resource, crop_size, ResourceBroker.Greenhouse); // reset growth growth = 0.0; // show message Message.Post(Lib.BuildString(Local.Greenhouse_msg_1.Format("<color=ffffff>" + vessel.vesselName + "</color> "), Local.Greenhouse_msg_2.Format("<color=ffffff>" + crop_size.ToString("F0") + " " + crop_resource + "</color>"))); //"On <<1>>""harvest produced <<1>>", // record first harvest if (!Lib.Landed(vessel)) { DB.landmarks.space_harvest = true; } }
public static void manageRescueMission(Vessel v) { // true if we detected this was a rescue mission vessel bool detected = false; // deal with rescue missions foreach (ProtoCrewMember c in Lib.CrewList(v)) { // get kerbal data KerbalData kd = DB.Kerbal(c.name); // flag the kerbal as not rescue at prelaunch if (v.situation == Vessel.Situations.PRELAUNCH) { kd.rescue = false; } // if the kerbal belong to a rescue mission if (kd.rescue) { // remember it detected = true; // flag the kerbal as non-rescue // note: enable life support mechanics for the kerbal kd.rescue = false; // show a message Message.Post(Lib.BuildString("We found <b>", c.name, "</b>"), Lib.BuildString((c.gender == ProtoCrewMember.Gender.Male ? "He" : "She"), "'s still alive!")); } } // gift resources if (detected) { var reslib = PartResourceLibrary.Instance.resourceDefinitions; var parts = Lib.GetPartsRecursively(v.rootPart); // give the vessel some propellant usable on eva string monoprop_name = Lib.EvaPropellantName(); double monoprop_amount = Lib.EvaPropellantCapacity(); foreach (var part in parts) { if (part.CrewCapacity > 0 || part.FindModuleImplementing <KerbalEVA>() != null) { if (Lib.Capacity(part, monoprop_name) <= double.Epsilon) { Lib.AddResource(part, monoprop_name, 0.0, monoprop_amount); } break; } } ResourceCache.Produce(v, monoprop_name, monoprop_amount); // give the vessel some supplies Profile.SetupRescue(v); } }
public static void ProcessResources(Vessel v, List <KeyValuePair <string, double> > resources, string title) { foreach (var p in resources) { if (p.Value < 0) { ResourceCache.Consume(v, p.Key, -p.Value, title); } else { ResourceCache.Produce(v, p.Key, p.Value, title); } } }
public void EmergencyHarvest() { // calculate reduced harvest size double reduced_harvest = harvest_size * growth * 0.5; // produce reduced quantity of food, proportional to current growth ResourceCache.Produce(vessel, resource_name, reduced_harvest); // reset growth growth = 0.0; // show message Message.Post(Lib.BuildString("On <color=FFFFFF>", vessel.vesselName, "</color> an emergency harved produced <color=FFFFFF>", reduced_harvest.ToString("F0"), " ", resource_name, "</color>")); // record first harvest if (!Lib.Landed(vessel) && DB.Ready()) DB.Landmarks().space_harvest = 1; }
public void SetupRescue(Vessel v) { // do nothing if no resource on rescue if (on_rescue <= double.Epsilon) return; // if the vessel has no capacity if (ResourceCache.Info(v, resource).capacity <= double.Epsilon) { // find the first useful part Part p = v.parts.Find(k => k.CrewCapacity > 0 || k.FindModuleImplementing<KerbalEVA>() != null); // add capacity Lib.AddResource(p, resource, 0.0, on_rescue); } // add resource to the vessel ResourceCache.Produce(v, resource, on_rescue); }
void manageResqueMission(Vessel v) { // true if we detected this was a resque mission vessel bool detected = false; // deal with resque missions foreach (ProtoCrewMember c in v.GetVesselCrew()) { // get kerbal data kerbal_data kd = DB.KerbalData(c.name); // flag the kerbal as not resque at prelaunch if (v.situation == Vessel.Situations.PRELAUNCH) { kd.resque = 0; } // if the kerbal belong to a resque mission if (kd.resque == 1) { // remember it detected = true; // flag the kerbal as non-resque // note: enable life support mechanics for the kerbal kd.resque = 0; // show a message Message.Post(Lib.BuildString("We found <b>", c.name, "</b>"), Lib.BuildString((c.gender == ProtoCrewMember.Gender.Male ? "He" : "She"), "'s still alive!")); } } // gift resources if (detected) { var reslib = PartResourceLibrary.Instance.resourceDefinitions; var parts = Lib.GetPartsRecursively(v.rootPart); // give the vessel some monoprop string monoprop_name = v.isEVA ? "EVA Propellant" : detected_mods.RealFuels ? "Hydrazine" : "MonoPropellant"; foreach (var part in parts) { if (part.CrewCapacity > 0 || part.FindModuleImplementing <KerbalEVA>() != null) { if (part.Resources.list.Find(k => k.resourceName == monoprop_name) == null) { Lib.SetupResource(part, monoprop_name, 0.0, Settings.MonoPropellantOnResque); } break; } } ResourceCache.Produce(v, monoprop_name, Settings.MonoPropellantOnResque); // give the vessel some supplies foreach (Rule r in rules) { if (r.resource_name.Length == 0 || r.on_resque <= double.Epsilon || !reslib.Contains(r.resource_name)) { continue; } foreach (var part in parts) { if (part.CrewCapacity > 0 || part.FindModuleImplementing <KerbalEVA>() != null) { if (part.Resources.list.Find(k => k.resourceName == r.resource_name) == null) { Lib.SetupResource(part, r.resource_name, 0.0, r.on_resque); } break; } } ResourceCache.Produce(v, r.resource_name, r.on_resque); } } }
public static void ProduceResource(Vessel v, string resource_name, double quantity, string title) { ResourceCache.Produce(v, resource_name, quantity, title); }
public static void ProduceResource(Vessel v, string resource_name, double quantity, string title) { ResourceCache.Produce(v, resource_name, quantity, ResourceBroker.GetOrCreate(title)); }