void VesselRecovered(ProtoVessel pv, bool b) { // note: this is called multiple times when a vessel is recovered // for each crew member foreach (ProtoCrewMember c in pv.GetVesselCrew()) { // avoid creating kerbal data in db again, // as this function may be called multiple times if (!DB.ContainsKerbal(c.name)) { continue; } // set roster status of eva dead kerbals if (DB.Kerbal(c.name).eva_dead) { c.rosterStatus = ProtoCrewMember.RosterStatus.Dead; } // reset kerbal data of recovered kerbals DB.RecoverKerbal(c.name); } DB.vessels.Remove(Lib.VesselID(pv)); // purge the caches ResourceCache.Purge(pv); Drive.Purge(pv); Cache.PurgeObjects(pv); }
void FromEVA(GameEvents.FromToAction <Part, Part> data) { String prop_name = Lib.EvaPropellantName(); // for each resource in the eva kerbal for (int i = 0; i < data.from.Resources.Count; ++i) { // get the resource PartResource res = data.from.Resources[i]; // add leftovers to the vessel data.to.RequestResource(res.resourceName, -res.amount); } // merge drives data Drive.Transfer(data.from.vessel, data.to.vessel, true); // forget vessel data DB.vessels.Remove(Lib.VesselID(data.from.vessel)); Drive.Purge(data.from.vessel); Cache.PurgeObjects(data.from.vessel); Cache.PurgeObjects(data.to.vessel); // execute script DB.Vessel(data.to.vessel).computer.Execute(data.to.vessel, ScriptType.eva_in); }
void VesselTerminated(ProtoVessel pv) { // forget all kerbals data foreach (ProtoCrewMember c in pv.GetVesselCrew()) { DB.KillKerbal(c.name, true); } DB.vessels.Remove(Lib.VesselID(pv)); // purge the caches ResourceCache.Purge(pv); Drive.Purge(pv); Cache.PurgeObjects(pv); }
void VesselDestroyed(Vessel v) { DB.vessels.Remove(Lib.VesselID(v)); // rescan the damn kerbals // - vessel crew is empty at destruction time // - we can't even use the flightglobal roster, because sometimes it isn't updated yet at this point HashSet <string> kerbals_alive = new HashSet <string>(); HashSet <string> kerbals_dead = new HashSet <string>(); foreach (Vessel ov in FlightGlobals.Vessels) { foreach (ProtoCrewMember c in Lib.CrewList(ov)) { kerbals_alive.Add(c.name); } } foreach (KeyValuePair <string, KerbalData> p in DB.Kerbals()) { if (!kerbals_alive.Contains(p.Key)) { kerbals_dead.Add(p.Key); } } foreach (string n in kerbals_dead) { // we don't know if the kerbal really is dead, or if it is just not currently assigned to a mission DB.KillKerbal(n, false); } // purge the caches ResourceCache.Purge(v); Drive.Purge(v); Cache.PurgeObjects(v); }